From patchwork Sun Nov 6 12:09:59 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Lindner X-Patchwork-Id: 1363 Return-Path: Received: from nm15-vm0.bullet.mail.ukl.yahoo.com (nm15-vm0.bullet.mail.ukl.yahoo.com [217.146.183.252]) by open-mesh.org (Postfix) with SMTP id EBB9C60066A for ; Sun, 6 Nov 2011 13:10:09 +0100 (CET) Authentication-Results: open-mesh.org; dkim=pass (1024-bit key) header.i=@yahoo.de; dkim-adsp=none Received: from [217.146.183.180] by nm15.bullet.mail.ukl.yahoo.com with NNFMP; 06 Nov 2011 12:10:09 -0000 Received: from [77.238.184.77] by tm11.bullet.mail.ukl.yahoo.com with NNFMP; 06 Nov 2011 12:10:09 -0000 Received: from [127.0.0.1] by smtp146.mail.ukl.yahoo.com with NNFMP; 06 Nov 2011 12:10:09 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s1024; t=1320581409; bh=0JHIbla7HKmmjLpZaSHo4Rd1wbOCTIje+OkvZeQzzEM=; h=X-Yahoo-Newman-Id:X-Yahoo-Newman-Property:X-YMail-OSG:X-Yahoo-SMTP:Received:From:To:Cc:Subject:Date:Message-Id:X-Mailer; b=UE99fGhkLT8jfBV4hqwoftOohtJEK5iF036CuVv7Wb9hyuGuoodThlNkL6oeoAKDzgjhGGDqQGAh+mX+o42QGYXvkGp4gnkPr1MZLcmPoSgkncOhHO24q0uqakTvwOuBttlCvSJcDKP7VVB5Yyp3yK2NjvHoxuweUdPNvCg4I54= X-Yahoo-Newman-Id: 50440.5979.bm@smtp146.mail.ukl.yahoo.com X-Yahoo-Newman-Property: ymail-3 X-YMail-OSG: EzfjJH4VM1nfiSe_xUCyJwktcBCLH5sw5QrH7It7pU7F1xB ARQ9rZjWDBaZB.gK8i2PhEL0lvo5CB1X1s7sW_1.DcgG7iHQRi0tRx_R8.fv wqEQEjWgnKZVJUeA1nkoPhChNvAbW9tv6e7JebQb_6L4YfKY2XGUD1W93N.b au8msvPFjd29Ef3JrMEszofICDDywvq5Dx.K40ncUXy5Uil0ds0ssqsmCMJ1 mw98UpmpEjlXujPZH6DBDI2K2vy.JzNAqCb8OMm.naxiaUoI.gd3NBzxkRX8 hwqgti5BewIwmjEI5OFN6uLmWl7DzQSYcllSFFn0MzGCr8bh3EUBpQt4Eym3 lEJtwXGfMX69kChjDSkQlhlUmvHgYAOb4NIp3KzUPUIKSFdU- X-Yahoo-SMTP: tW.h3tiswBBMXO2coYcbPigGD5Lt6zY_.Zc- Received: from localhost (lindner_marek@210.177.7.38 with plain) by smtp146.mail.ukl.yahoo.com with SMTP; 06 Nov 2011 12:10:08 +0000 GMT From: Marek Lindner To: b.a.t.m.a.n@lists.open-mesh.org Date: Sun, 6 Nov 2011 20:09:59 +0800 Message-Id: <1320581400-8228-1-git-send-email-lindner_marek@yahoo.de> X-Mailer: git-send-email 1.7.5.4 Cc: Marek Lindner Subject: [B.A.T.M.A.N.] [PATCH 1/2] batctl: version also prints the kernel module version if available X-BeenThere: b.a.t.m.a.n@lists.open-mesh.org X-Mailman-Version: 2.1.13 Precedence: list Reply-To: The list for a Better Approach To Mobile Ad-hoc Networking List-Id: The list for a Better Approach To Mobile Ad-hoc Networking List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Nov 2011 12:10:10 -0000 Signed-off-by: Marek Lindner --- 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 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: