The following commit has been merged in the next branch:
commit 2026933a75bd25b42dade47e03097904d5ecdea3
Author: Marek Lindner <lindner_marek(a)yahoo.de>
Date: Thu Feb 9 18:02:14 2012 +0800
batctl: warn about options that are not compiled into batman-adv
Signed-off-by: Marek Lindner <lindner_marek(a)yahoo.de>
diff --git a/debug.c b/debug.c
index 155f499..928f81d 100644
--- a/debug.c
+++ b/debug.c
@@ -185,9 +185,5 @@ int log_print(char *mesh_iface, int argc, char **argv)
debugfs_make_path(DEBUG_BATIF_PATH_FMT "/", mesh_iface, full_path, sizeof(full_path));
res = read_file(full_path, DEBUG_LOG, read_opt, 0, 0);
-
- if ((res != EXIT_SUCCESS) && (errno == ENOENT))
- printf("To read the debug log you need to compile the module with debugging enabled (see the README)\n");
-
return res;
}
diff --git a/functions.c b/functions.c
index 69a1385..8ce2419 100644
--- a/functions.c
+++ b/functions.c
@@ -35,11 +35,19 @@
#include "main.h"
#include "functions.h"
#include "bat-hosts.h"
+#include "sys.h"
static struct timeval start_time;
static char *host_name;
char *line_ptr = NULL;
+const char *sysfs_compile_out_param[] = {
+ SYS_LOG,
+ SYS_LOG_LEVEL,
+ SYS_BRIDGE_LOOP_AVOIDANCE,
+ NULL,
+};
+
void start_timer(void)
{
gettimeofday(&start_time, NULL);
@@ -125,6 +133,7 @@ int read_file(char *dir, char *fname, int read_opt,
struct bat_host *bat_host;
int res = EXIT_FAILURE;
float last_seen;
+ const char **ptr;
char full_path[500], *buff_ptr, *space_ptr, extra_char;
size_t len = 0;
FILE *fp = NULL;
@@ -145,8 +154,21 @@ open:
fp = fopen(full_path, "r");
if (!fp) {
- if (!(read_opt & SILENCE_ERRORS))
+ if (!(read_opt & SILENCE_ERRORS)) {
+ for (ptr = sysfs_compile_out_param; *ptr; ptr++) {
+ if (strcmp(*ptr, fname) != 0)
+ continue;
+
+ break;
+ }
+
printf("Error - can't open file '%s': %s\n", full_path, strerror(errno));
+ if (*ptr) {
+ printf("The option you called seems not to be compiled into your batman-adv kernel module.\n");
+ printf("Consult the README if you wish to learn more about compiling options into batman-adv.\n");
+ }
+ }
+
goto out;
}
diff --git a/sys.c b/sys.c
index eeb7005..0b7ddf7 100644
--- a/sys.c
+++ b/sys.c
@@ -255,9 +255,6 @@ int handle_loglevel(char *mesh_iface, int argc, char **argv)
"messages related to bridge loop avoidance", "bla");
out:
- if (errno == ENOENT)
- printf("To increase the log level you need to compile the module with debugging enabled (see the README)\n");
-
free(path_buff);
return res;
}
--
batctl