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] batctl: Print compat version when querying the version
@ 2012-10-03 17:31 Sven Eckelmann
  2012-10-16 13:31 ` [B.A.T.M.A.N.] [PATCH-rebased] " Sven Eckelmann
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Eckelmann @ 2012-10-03 17:31 UTC (permalink / raw)
  To: b.a.t.m.a.n

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
 main.c |   53 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/main.c b/main.c
index 01a435b..eaaec0a 100644
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@
 #include "main.h"
 #include "sys.h"
 #include "debug.h"
+#include "debugfs.h"
 #include "ping.h"
 #include "traceroute.h"
 #include "tcpdump.h"
@@ -42,6 +43,7 @@
 
 char mesh_dfl_iface[] = "bat0";
 char module_ver_path[] = "/sys/module/batman_adv/version";
+char module_compat_ver_file[] = "batman_adv/compat_version";
 
 void print_usage(void)
 {
@@ -90,6 +92,44 @@ void print_usage(void)
 #endif
 }
 
+static void print_version(void)
+{
+	int ret;
+	char *debugfs_mnt;
+
+	printf("batctl %s [", 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("batman-adv: %s", line_ptr);
+	} else {
+		printf("module not loaded");
+		goto out;
+	}
+
+	free(line_ptr);
+	line_ptr = NULL;
+
+	debugfs_mnt = debugfs_mount(NULL);
+	if (!debugfs_mnt)
+		goto out;
+
+	ret = read_file(debugfs_mnt, module_compat_ver_file, 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(", compat: %s", line_ptr);
+
+out:
+	free(line_ptr);
+	line_ptr = NULL;
+	printf("]\n");
+}
+
 int main(int argc, char **argv)
 {
 	int i, ret = EXIT_FAILURE;
@@ -116,18 +156,7 @@ int main(int argc, char **argv)
 		goto err;
 
 	if (strcmp(argv[1], "-v") == 0) {
-		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);
+		print_version();
 		exit(EXIT_SUCCESS);
 	}
 
-- 
1.7.10.4


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

* [B.A.T.M.A.N.] [PATCH-rebased] batctl: Print compat version when querying the version
  2012-10-03 17:31 [B.A.T.M.A.N.] [PATCH] batctl: Print compat version when querying the version Sven Eckelmann
@ 2012-10-16 13:31 ` Sven Eckelmann
  2012-10-16 20:38   ` Marek Lindner
  0 siblings, 1 reply; 3+ messages in thread
From: Sven Eckelmann @ 2012-10-16 13:31 UTC (permalink / raw)
  To: b.a.t.m.a.n

Signed-off-by: Sven Eckelmann <sven@narfation.org>
---
patch rebased on top of ipv4 patches... just in case you want to merge the ipv4
patchset and this patch ;)

 main.c |   53 +++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 41 insertions(+), 12 deletions(-)

diff --git a/main.c b/main.c
index 647818d..d37a46c 100644
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@
 #include "main.h"
 #include "sys.h"
 #include "debug.h"
+#include "debugfs.h"
 #include "ping.h"
 #include "traceroute.h"
 #include "tcpdump.h"
@@ -42,6 +43,7 @@
 
 char mesh_dfl_iface[] = "bat0";
 char module_ver_path[] = "/sys/module/batman_adv/version";
+char module_compat_ver_file[] = "batman_adv/compat_version";
 
 void print_usage(void)
 {
@@ -90,6 +92,44 @@ void print_usage(void)
 #endif
 }
 
+static void print_version(void)
+{
+	int ret;
+	char *debugfs_mnt;
+
+	printf("batctl %s [", SOURCE_VERSION);
+
+	ret = read_file("", module_ver_path, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
+	if ((line_ptr) && (line_ptr[strlen(line_ptr) - 1] == '\n'))
+		line_ptr[strlen(line_ptr) - 1] = '\0';
+
+	if (ret == EXIT_SUCCESS) {
+		printf("batman-adv: %s", line_ptr);
+	} else {
+		printf("module not loaded");
+		goto out;
+	}
+
+	free(line_ptr);
+	line_ptr = NULL;
+
+	debugfs_mnt = debugfs_mount(NULL);
+	if (!debugfs_mnt)
+		goto out;
+
+	ret = read_file(debugfs_mnt, module_compat_ver_file, USE_READ_BUFF | SILENCE_ERRORS, 0, 0, 0);
+	if ((line_ptr) && (line_ptr[strlen(line_ptr) - 1] == '\n'))
+		line_ptr[strlen(line_ptr) - 1] = '\0';
+
+	if (ret == EXIT_SUCCESS)
+		printf(", compat: %s", line_ptr);
+
+out:
+	free(line_ptr);
+	line_ptr = NULL;
+	printf("]\n");
+}
+
 int main(int argc, char **argv)
 {
 	int i, ret = EXIT_FAILURE;
@@ -116,18 +156,7 @@ int main(int argc, char **argv)
 		goto err;
 
 	if (strcmp(argv[1], "-v") == 0) {
-		printf("batctl %s [batman-adv: ", SOURCE_VERSION);
-
-		ret = read_file("", module_ver_path, USE_READ_BUFF | SILENCE_ERRORS, 0, 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);
+		print_version();
 		exit(EXIT_SUCCESS);
 	}
 
-- 
1.7.10.4


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

* Re: [B.A.T.M.A.N.] [PATCH-rebased] batctl: Print compat version when querying the version
  2012-10-16 13:31 ` [B.A.T.M.A.N.] [PATCH-rebased] " Sven Eckelmann
@ 2012-10-16 20:38   ` Marek Lindner
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Lindner @ 2012-10-16 20:38 UTC (permalink / raw)
  To: b.a.t.m.a.n

On Tuesday, October 16, 2012 21:31:34 Sven Eckelmann wrote:
> Signed-off-by: Sven Eckelmann <sven@narfation.org>
> ---
> patch rebased on top of ipv4 patches... just in case you want to merge the
> ipv4 patchset and this patch ;)
> 
>  main.c |   53 +++++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 41 insertions(+), 12 deletions(-)

Applied in revision a88e6b7.

Thanks,
Marek

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

end of thread, other threads:[~2012-10-16 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-03 17:31 [B.A.T.M.A.N.] [PATCH] batctl: Print compat version when querying the version Sven Eckelmann
2012-10-16 13:31 ` [B.A.T.M.A.N.] [PATCH-rebased] " Sven Eckelmann
2012-10-16 20:38   ` Marek Lindner

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