diff options
| author | Tanguy Pruvot <tanguy.pruvot@gmail.com> | 2012-05-30 08:00:46 +0200 |
|---|---|---|
| committer | Denys Vlasenko <vda.linux@googlemail.com> | 2012-06-12 16:26:03 +0200 |
| commit | 772f17a8433b8572e1bf08b024fbf1f4e78395a3 (patch) | |
| tree | 1c770f611dc2d537e953196c232a915454e451b6 /modutils | |
| parent | ac164dd2a7b7eefdc146ec2b0d448d029bc07ec0 (diff) | |
| download | busybox-w32-772f17a8433b8572e1bf08b024fbf1f4e78395a3.tar.gz busybox-w32-772f17a8433b8572e1bf08b024fbf1f4e78395a3.tar.bz2 busybox-w32-772f17a8433b8572e1bf08b024fbf1f4e78395a3.zip | |
modinfo: match more standard module fields and fix version field
Previously, -F version could match the srcversion= string.
before :
~ # modinfo -F version tiwlan_drv
version: 6.1.2012.05.29
version: 533BB7E5866E52F63B9ACCB
version: 0x%x, oui=0x%x, 0x%x, 0x%x
version: 0x%x
~ # modinfo tiwlan_drv
filename: tiwlan_drv.ko
author: Texas Instruments Inc - Retouched by CyanogenDefy
license: GPL
vermagic: 2.6.32.9 preempt mod_unload ARMv7
parm: g_sdio_debug_level:debug level
depends:
now :
~ # modinfo -F version tiwlan_drv
version: 6.1.2012.05.29
~ # modinfo tiwlan_drv
filename: tiwlan_drv.ko
license: GPL
author: Texas Instruments Inc - Retouched by CyanogenDefy
version: 6.1.2012.05.29
srcversion: 533BB7E5866E52F63B9ACCB
depends:
uts_release: 2.6.32.9-g306944c
vermagic: 2.6.32.9 preempt mod_unload ARMv7
parm: g_sdio_debug_level:debug level
This patch also add support for the old "-n" and some other helpers
Change-Id: Icb4e9ca513cbce46b075a6f038799a7a19fb7e22
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils')
| -rw-r--r-- | modutils/modinfo.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/modutils/modinfo.c b/modutils/modinfo.c index c0910ffed..7c978d1da 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c | |||
| @@ -24,9 +24,9 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | enum { | 26 | enum { |
| 27 | OPT_TAGS = (1 << 8) - 1, | 27 | OPT_TAGS = (1 << 12) - 1, /* shortcut count */ |
| 28 | OPT_F = (1 << 8), /* field name */ | 28 | OPT_F = (1 << 12), /* field name */ |
| 29 | OPT_0 = (1 << 9), /* \0 as separator */ | 29 | OPT_0 = (1 << 13), /* \0 as separator */ |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | struct modinfo_env { | 32 | struct modinfo_env { |
| @@ -49,13 +49,17 @@ static void modinfo(const char *path, const char *version, | |||
| 49 | { | 49 | { |
| 50 | static const char *const shortcuts[] = { | 50 | static const char *const shortcuts[] = { |
| 51 | "filename", | 51 | "filename", |
| 52 | "description", | ||
| 53 | "author", | ||
| 54 | "license", | 52 | "license", |
| 53 | "author", | ||
| 54 | "description", | ||
| 55 | "version", | ||
| 56 | "alias", | ||
| 57 | "srcversion", | ||
| 58 | "depends", | ||
| 59 | "uts_release", | ||
| 55 | "vermagic", | 60 | "vermagic", |
| 56 | "parm", | 61 | "parm", |
| 57 | "firmware", | 62 | "firmware", |
| 58 | "depends", | ||
| 59 | }; | 63 | }; |
| 60 | size_t len; | 64 | size_t len; |
| 61 | int j, length; | 65 | int j, length; |
| @@ -97,8 +101,11 @@ static void modinfo(const char *path, const char *version, | |||
| 97 | if (ptr == NULL) /* no occurance left, done */ | 101 | if (ptr == NULL) /* no occurance left, done */ |
| 98 | break; | 102 | break; |
| 99 | if (strncmp(ptr, pattern, length) == 0 && ptr[length] == '=') { | 103 | if (strncmp(ptr, pattern, length) == 0 && ptr[length] == '=') { |
| 100 | ptr += length + 1; | 104 | /* field prefixes are 0x80 or 0x00 */ |
| 101 | ptr += display(ptr, pattern, (1<<j) != tags); | 105 | if ((ptr[-1] & 0x7F) == '\0') { |
| 106 | ptr += length + 1; | ||
| 107 | ptr += display(ptr, pattern, (1<<j) != tags); | ||
| 108 | } | ||
| 102 | } | 109 | } |
| 103 | ++ptr; | 110 | ++ptr; |
| 104 | } | 111 | } |
| @@ -131,7 +138,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv) | |||
| 131 | 138 | ||
| 132 | env.field = NULL; | 139 | env.field = NULL; |
| 133 | opt_complementary = "-1"; /* minimum one param */ | 140 | opt_complementary = "-1"; /* minimum one param */ |
| 134 | opts = getopt32(argv, "fdalvpF:0", &env.field); | 141 | opts = getopt32(argv, "nladvAsDumpF:0", &env.field); |
| 135 | env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS; | 142 | env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS; |
| 136 | argv += optind; | 143 | argv += optind; |
| 137 | 144 | ||
