aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-05-18 13:08:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-05-18 13:08:04 +0200
commit16bda3bd1f8e486ed93f5182fc777be1e813bce7 (patch)
treebf6571888d13007e3e51664b9e9eba9346bb7838
parentc396fe6306f9a769d3a91809eb03361640c2f2fc (diff)
downloadbusybox-w32-16bda3bd1f8e486ed93f5182fc777be1e813bce7.tar.gz
busybox-w32-16bda3bd1f8e486ed93f5182fc777be1e813bce7.tar.bz2
busybox-w32-16bda3bd1f8e486ed93f5182fc777be1e813bce7.zip
depmod: fix handling of .gz modules
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--modutils/depmod.c39
-rwxr-xr-xmodutils/depmod_process.sh20
-rw-r--r--modutils/modutils.c2
3 files changed, 47 insertions, 14 deletions
diff --git a/modutils/depmod.c b/modutils/depmod.c
index 405ba9e2a..5ec2a51dd 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -40,26 +40,28 @@ enum {
40 ARG_r = (1<<6) /* Compat dummy. Linux Makefile uses it */ 40 ARG_r = (1<<6) /* Compat dummy. Linux Makefile uses it */
41}; 41};
42 42
43static int FAST_FUNC parse_module(const char *fname, struct stat *sb, 43static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
44 void *data, int UNUSED_PARAM depth) 44 void *data, int depth UNUSED_PARAM)
45{ 45{
46 char modname[MODULE_NAME_LEN];
46 module_info **first = (module_info **) data; 47 module_info **first = (module_info **) data;
47 char *image, *ptr; 48 char *image, *ptr;
48 module_info *info; 49 module_info *info;
49 size_t len = sb->st_size; 50 /* Arbitrary. Was sb->st_size, but that breaks .gz etc */
51 size_t len = (64*1024*1024 - 4096);
50 52
51 if (strrstr(fname, ".ko") == NULL) 53 if (strrstr(fname, ".ko") == NULL)
52 return TRUE; 54 return TRUE;
53 55
54 image = xmalloc_open_zipped_read_close(fname, &len); 56 image = xmalloc_open_zipped_read_close(fname, &len);
55 info = xzalloc(sizeof(module_info)); 57 info = xzalloc(sizeof(*info));
56 58
57 info->next = *first; 59 info->next = *first;
58 *first = info; 60 *first = info;
59 61
60 info->dnext = info->dprev = info; 62 info->dnext = info->dprev = info;
61 info->name = xasprintf("/%s", fname); 63 info->name = xasprintf("/%s", fname);
62 info->modname = filename2modname(fname, NULL); 64 info->modname = xstrdup(filename2modname(fname, modname));
63 for (ptr = image; ptr < image + len - 10; ptr++) { 65 for (ptr = image; ptr < image + len - 10; ptr++) {
64 if (strncmp(ptr, "depends=", 8) == 0) { 66 if (strncmp(ptr, "depends=", 8) == 0) {
65 char *u; 67 char *u;
@@ -69,12 +71,14 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb,
69 if (*u == '-') 71 if (*u == '-')
70 *u = '_'; 72 *u = '_';
71 ptr += string_to_llist(ptr, &info->dependencies, ","); 73 ptr += string_to_llist(ptr, &info->dependencies, ",");
72 } else if (ENABLE_FEATURE_MODUTILS_ALIAS && 74 } else if (ENABLE_FEATURE_MODUTILS_ALIAS
73 strncmp(ptr, "alias=", 6) == 0) { 75 && strncmp(ptr, "alias=", 6) == 0
76 ) {
74 llist_add_to(&info->aliases, xstrdup(ptr + 6)); 77 llist_add_to(&info->aliases, xstrdup(ptr + 6));
75 ptr += strlen(ptr); 78 ptr += strlen(ptr);
76 } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS && 79 } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS
77 strncmp(ptr, "__ksymtab_", 10) == 0) { 80 && strncmp(ptr, "__ksymtab_", 10) == 0
81 ) {
78 ptr += 10; 82 ptr += 10;
79 if (strncmp(ptr, "gpl", 3) == 0 || 83 if (strncmp(ptr, "gpl", 3) == 0 ||
80 strcmp(ptr, "strings") == 0) 84 strcmp(ptr, "strings") == 0)
@@ -199,10 +203,17 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
199 if (!(option_mask32 & ARG_n)) 203 if (!(option_mask32 & ARG_n))
200 xfreopen_write("modules.alias", stdout); 204 xfreopen_write("modules.alias", stdout);
201 for (m = modules; m != NULL; m = m->next) { 205 for (m = modules; m != NULL; m = m->next) {
206 const char *fname = bb_basename(m->name);
207 int fnlen = strchrnul(fname, '.') - fname;
202 while (m->aliases) { 208 while (m->aliases) {
203 printf("alias %s %s\n", 209 /* Last word can well be m->modname instead,
210 * but depmod from module-init-tools 3.4
211 * uses module basename, i.e., no s/-/_/g.
212 * (pathname and .ko.* are still stripped)
213 * Mimicking that... */
214 printf("alias %s %.*s\n",
204 (char*)llist_pop(&m->aliases), 215 (char*)llist_pop(&m->aliases),
205 m->modname); 216 fnlen, fname);
206 } 217 }
207 } 218 }
208#endif 219#endif
@@ -210,10 +221,12 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
210 if (!(option_mask32 & ARG_n)) 221 if (!(option_mask32 & ARG_n))
211 xfreopen_write("modules.symbols", stdout); 222 xfreopen_write("modules.symbols", stdout);
212 for (m = modules; m != NULL; m = m->next) { 223 for (m = modules; m != NULL; m = m->next) {
224 const char *fname = bb_basename(m->name);
225 int fnlen = strchrnul(fname, '.') - fname;
213 while (m->symbols) { 226 while (m->symbols) {
214 printf("alias symbol:%s %s\n", 227 printf("alias symbol:%s %.*s\n",
215 (char*)llist_pop(&m->symbols), 228 (char*)llist_pop(&m->symbols),
216 m->modname); 229 fnlen, fname);
217 } 230 }
218 } 231 }
219#endif 232#endif
diff --git a/modutils/depmod_process.sh b/modutils/depmod_process.sh
new file mode 100755
index 000000000..f99b09153
--- /dev/null
+++ b/modutils/depmod_process.sh
@@ -0,0 +1,20 @@
1#!/bin/sh
2
3# Depmod output may be hard to diff.
4# This script sorts dependencies within "xx.ko: yy.ko zz.ko" lines,
5# and sorts all lines too.
6# Usage:
7#
8# [./busybox] depmod -n | ./depmod_process.sh | sort >OUTFILE
9#
10# and then you can diff OUTFILEs. Useful for comparing bbox depmod
11# with module-init-tools depmod and such.
12
13while read -r word rest; do
14 if ! test "${word/*:/}"; then
15 echo -n "$word "
16 echo "$rest" | xargs -n1 | sort | xargs
17 else
18 echo "$word $rest";
19 fi
20done
diff --git a/modutils/modutils.c b/modutils/modutils.c
index 0f6cb0f2d..f437a9829 100644
--- a/modutils/modutils.c
+++ b/modutils/modutils.c
@@ -57,7 +57,7 @@ char * FAST_FUNC filename2modname(const char *filename, char *modname)
57 from = bb_get_last_path_component_nostrip(filename); 57 from = bb_get_last_path_component_nostrip(filename);
58 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++) 58 for (i = 0; i < (MODULE_NAME_LEN-1) && from[i] != '\0' && from[i] != '.'; i++)
59 modname[i] = (from[i] == '-') ? '_' : from[i]; 59 modname[i] = (from[i] == '-') ? '_' : from[i];
60 modname[i] = 0; 60 modname[i] = '\0';
61 61
62 return modname; 62 return modname;
63} 63}