public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH 1/2] batctl: version also prints the kernel module version if available
@ 2011-11-06 12:09 Marek Lindner
  2011-11-06 12:10 ` [B.A.T.M.A.N.] [PATCH 2/2] batctl: remove unused SINGLE_READ flag Marek Lindner
  2011-11-08 17:08 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: version also prints the kernel module version if available Marek Lindner
  0 siblings, 2 replies; 4+ messages in thread
From: Marek Lindner @ 2011-11-06 12:09 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Marek Lindner

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
 main.c       |   15 ++++++++++++++-
 man/batctl.8 |    2 +-
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index a1e6f4d..7f6d1a3 100644
--- a/main.c
+++ b/main.c
@@ -36,9 +36,11 @@
 #include "tcpdump.h"
 #include "bisect.h"
 #include "vis.h"
+#include "functions.h"
 #include <err.h>
 
 char mesh_dfl_iface[] = "bat0";
+char module_ver_path[] = "/sys/module/batman_adv/version";
 
 void print_usage(void) {
 	printf("Usage: batctl [options] commands \n");
@@ -96,7 +98,18 @@ int main(int argc, char **argv)
 		goto err;
 
 	if (strcmp(argv[1], "-v") == 0) {
-		printf("batctl %s\n", SOURCE_VERSION);
+		printf("batctl %s [batman-adv: ", SOURCE_VERSION);
+
+		ret = read_file("", module_ver_path, USE_READ_BUFF | SILENCE_ERRORS, 0, 0);
+		if ((line_ptr) && (line_ptr[strlen(line_ptr) - 1] == '\n'))
+			line_ptr[strlen(line_ptr) - 1] = '\0';
+
+		if (ret == EXIT_SUCCESS)
+			printf("%s]\n", line_ptr);
+		else
+			printf("module not loaded]\n");
+
+		free(line_ptr);
 		exit(EXIT_SUCCESS);
 	}
 
diff --git a/man/batctl.8 b/man/batctl.8
index b0c6fc6..928c7e3 100644
--- a/man/batctl.8
+++ b/man/batctl.8
@@ -51,7 +51,7 @@ protocol.
 .br
 \-h     print general batctl help
 .br
-\-v     print batctl version
+\-v     print batctl version and batman-adv version (if the module is loaded)
 .br
 .TP
 .I \fBcommands:
-- 
1.7.5.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-11-08 17:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-06 12:09 [B.A.T.M.A.N.] [PATCH 1/2] batctl: version also prints the kernel module version if available Marek Lindner
2011-11-06 12:10 ` [B.A.T.M.A.N.] [PATCH 2/2] batctl: remove unused SINGLE_READ flag Marek Lindner
2011-11-08 17:10   ` Marek Lindner
2011-11-08 17:08 ` [B.A.T.M.A.N.] [PATCH 1/2] batctl: version also prints the kernel module version if available Marek Lindner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox