aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBen Greear <greearb@candelatech.com>2011-02-06 18:15:19 (GMT)
committerJouni Malinen <j@w1.fi>2011-02-06 18:15:19 (GMT)
commitac6912b5d13614a585d0b7ff6c8b653159c9725c (patch)
treefdfe1f08277708667560852c9b0b10ee00787a0f /src
parent3103f345761eb644e04f4337cec6c39062c04340 (diff)
downloadhostap-ac6912b5d13614a585d0b7ff6c8b653159c9725c.zip
hostap-ac6912b5d13614a585d0b7ff6c8b653159c9725c.tar.gz
hostap-ac6912b5d13614a585d0b7ff6c8b653159c9725c.tar.bz2
wpa_supplicant: Support 'relog' command to re-open log files
This allows rolling log files: mv log.txt log.txt.1 wpa_cli relog Signed-off-by: Ben Greear <greearb@candelatech.com>
Diffstat (limited to 'src')
-rw-r--r--src/utils/wpa_debug.c34
-rw-r--r--src/utils/wpa_debug.h1
2 files changed, 35 insertions, 0 deletions
diff --git a/src/utils/wpa_debug.c b/src/utils/wpa_debug.c
index 6f6fc69..560b85a 100644
--- a/src/utils/wpa_debug.c
+++ b/src/utils/wpa_debug.c
@@ -273,11 +273,43 @@ void wpa_hexdump_ascii_key(int level, const char *title, const u8 *buf,
}
+#ifdef CONFIG_DEBUG_FILE
+static char *last_path = NULL;
+#endif /* CONFIG_DEBUG_FILE */
+
+int wpa_debug_reopen_file(void)
+{
+#ifdef CONFIG_DEBUG_FILE
+ int rv;
+ if (last_path) {
+ char *tmp = os_strdup(last_path);
+ wpa_debug_close_file();
+ rv = wpa_debug_open_file(tmp);
+ os_free(tmp);
+ } else {
+ wpa_printf(MSG_ERROR, "Last-path was not set, cannot "
+ "re-open log file.");
+ rv = -1;
+ }
+ return rv;
+#else /* CONFIG_DEBUG_FILE */
+ return 0;
+#endif /* CONFIG_DEBUG_FILE */
+}
+
+
int wpa_debug_open_file(const char *path)
{
#ifdef CONFIG_DEBUG_FILE
if (!path)
return 0;
+
+ if (last_path == NULL || os_strcmp(last_path, path) != 0) {
+ /* Save our path to enable re-open */
+ os_free(last_path);
+ last_path = os_strdup(path);
+ }
+
out_file = fopen(path, "a");
if (out_file == NULL) {
wpa_printf(MSG_ERROR, "wpa_debug_open_file: Failed to open "
@@ -299,6 +331,8 @@ void wpa_debug_close_file(void)
return;
fclose(out_file);
out_file = NULL;
+ os_free(last_path);
+ last_path = NULL;
#endif /* CONFIG_DEBUG_FILE */
}
diff --git a/src/utils/wpa_debug.h b/src/utils/wpa_debug.h
index f2e8646..fb59ea5 100644
--- a/src/utils/wpa_debug.h
+++ b/src/utils/wpa_debug.h
@@ -40,6 +40,7 @@ enum {
#else /* CONFIG_NO_STDOUT_DEBUG */
int wpa_debug_open_file(const char *path);
+int wpa_debug_reopen_file(void);
void wpa_debug_close_file(void);
/**