Loading system/hci/src/btsnoop.c +12 −3 Original line number Diff line number Diff line Loading @@ -141,11 +141,20 @@ static void update_logging() { if (should_log) { btsnoop_net_open(); const char *path = stack_config->get_btsnoop_log_path(); logfile_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); const char *log_path = stack_config->get_btsnoop_log_path(); // Save the old log if configured to do so if (stack_config->get_btsnoop_should_save_last()) { char last_log_path[PATH_MAX]; snprintf(last_log_path, PATH_MAX, "%s.last", log_path); if (!rename(log_path, last_log_path) && errno != ENOENT) LOG_ERROR("%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno)); } logfile_fd = open(log_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); if (logfile_fd == INVALID_FD) { LOG_ERROR("%s unable to open '%s': %s", __func__, path, strerror(errno)); LOG_ERROR("%s unable to open '%s': %s", __func__, log_path, strerror(errno)); is_logging = false; return; } Loading system/include/stack_config.h +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ static const char STACK_CONFIG_MODULE[] = "stack_config_module"; typedef struct { const char *(*get_btsnoop_log_path)(void); bool (*get_btsnoop_turned_on)(void); bool (*get_btsnoop_should_save_last)(void); bool (*get_trace_config_enabled)(void); config_t *(*get_all)(void); } stack_config_t; Loading system/main/stack_config.c +6 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ const char *BTSNOOP_LOG_PATH_KEY = "BtSnoopFileName"; const char *BTSNOOP_TURNED_ON_KEY = "BtSnoopLogOutput"; const char *BTSNOOP_SHOULD_SAVE_LAST_KEY = "BtSnoopSaveLog"; const char *TRACE_CONFIG_ENABLED_KEY = "TraceConf"; static config_t *config; Loading Loading @@ -73,6 +74,10 @@ static bool get_btsnoop_turned_on(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_TURNED_ON_KEY, false); } static bool get_btsnoop_should_save_last(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_SHOULD_SAVE_LAST_KEY, false); } static bool get_trace_config_enabled(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, TRACE_CONFIG_ENABLED_KEY, false); } Loading @@ -84,6 +89,7 @@ static config_t *get_all(void) { const stack_config_t interface = { get_btsnoop_log_path, get_btsnoop_turned_on, get_btsnoop_should_save_last, get_trace_config_enabled, get_all }; Loading Loading
system/hci/src/btsnoop.c +12 −3 Original line number Diff line number Diff line Loading @@ -141,11 +141,20 @@ static void update_logging() { if (should_log) { btsnoop_net_open(); const char *path = stack_config->get_btsnoop_log_path(); logfile_fd = open(path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); const char *log_path = stack_config->get_btsnoop_log_path(); // Save the old log if configured to do so if (stack_config->get_btsnoop_should_save_last()) { char last_log_path[PATH_MAX]; snprintf(last_log_path, PATH_MAX, "%s.last", log_path); if (!rename(log_path, last_log_path) && errno != ENOENT) LOG_ERROR("%s unable to rename '%s' to '%s': %s", __func__, log_path, last_log_path, strerror(errno)); } logfile_fd = open(log_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH); if (logfile_fd == INVALID_FD) { LOG_ERROR("%s unable to open '%s': %s", __func__, path, strerror(errno)); LOG_ERROR("%s unable to open '%s': %s", __func__, log_path, strerror(errno)); is_logging = false; return; } Loading
system/include/stack_config.h +1 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ static const char STACK_CONFIG_MODULE[] = "stack_config_module"; typedef struct { const char *(*get_btsnoop_log_path)(void); bool (*get_btsnoop_turned_on)(void); bool (*get_btsnoop_should_save_last)(void); bool (*get_trace_config_enabled)(void); config_t *(*get_all)(void); } stack_config_t; Loading
system/main/stack_config.c +6 −0 Original line number Diff line number Diff line Loading @@ -26,6 +26,7 @@ const char *BTSNOOP_LOG_PATH_KEY = "BtSnoopFileName"; const char *BTSNOOP_TURNED_ON_KEY = "BtSnoopLogOutput"; const char *BTSNOOP_SHOULD_SAVE_LAST_KEY = "BtSnoopSaveLog"; const char *TRACE_CONFIG_ENABLED_KEY = "TraceConf"; static config_t *config; Loading Loading @@ -73,6 +74,10 @@ static bool get_btsnoop_turned_on(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_TURNED_ON_KEY, false); } static bool get_btsnoop_should_save_last(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, BTSNOOP_SHOULD_SAVE_LAST_KEY, false); } static bool get_trace_config_enabled(void) { return config_get_bool(config, CONFIG_DEFAULT_SECTION, TRACE_CONFIG_ENABLED_KEY, false); } Loading @@ -84,6 +89,7 @@ static config_t *get_all(void) { const stack_config_t interface = { get_btsnoop_log_path, get_btsnoop_turned_on, get_btsnoop_should_save_last, get_trace_config_enabled, get_all }; Loading