aboutsummaryrefslogtreecommitdiff
path: root/modutils
diff options
context:
space:
mode:
Diffstat (limited to 'modutils')
-rw-r--r--modutils/depmod.c39
-rw-r--r--modutils/modprobe.c6
2 files changed, 30 insertions, 15 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/modprobe.c b/modutils/modprobe.c
index 218a898a8..0339ebb40 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -109,7 +109,9 @@ static void add_probe(const char *name)
109 struct module_entry *m; 109 struct module_entry *m;
110 110
111 m = get_or_add_modentry(name); 111 m = get_or_add_modentry(name);
112 if (m->flags & MODULE_FLAG_LOADED) { 112 if (!(option_mask32 & MODPROBE_OPT_REMOVE)
113 && (m->flags & MODULE_FLAG_LOADED)
114 ) {
113 DBG("skipping %s, it is already loaded", name); 115 DBG("skipping %s, it is already loaded", name);
114 return; 116 return;
115 } 117 }
@@ -339,7 +341,7 @@ int modprobe_main(int argc UNUSED_PARAM, char **argv)
339 config_close(parser); 341 config_close(parser);
340 } 342 }
341 343
342 if (opt & MODPROBE_OPT_INSERT_ALL) { 344 if (opt & (MODPROBE_OPT_INSERT_ALL | MODPROBE_OPT_REMOVE)) {
343 /* Each argument is a module name */ 345 /* Each argument is a module name */
344 do { 346 do {
345 add_probe(*argv++); 347 add_probe(*argv++);