depmod: fix recent breakage in modules.dep generation

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2015-01-07 14:39:01 +01:00
parent e5cae08f12
commit 08364dab75

View File

@ -51,7 +51,11 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
info->dnext = info->dprev = info; info->dnext = info->dprev = info;
info->name = xstrdup(fname + 2); /* skip "./" */ info->name = xstrdup(fname + 2); /* skip "./" */
info->modname = xstrdup(filename2modname(fname, modname)); info->modname = xstrdup(
filename2modname(
bb_get_last_path_component_nostrip(fname),
modname
));
for (ptr = image; ptr < image + len - 10; ptr++) { for (ptr = image; ptr < image + len - 10; ptr++) {
if (strncmp(ptr, "depends=", 8) == 0) { if (strncmp(ptr, "depends=", 8) == 0) {
char *u; char *u;
@ -242,17 +246,18 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
if (!(option_mask32 & OPT_n)) if (!(option_mask32 & OPT_n))
xfreopen_write("modules.alias", stdout); xfreopen_write("modules.alias", stdout);
for (m = modules; m != NULL; m = m->next) { for (m = modules; m != NULL; m = m->next) {
char modname[MODULE_NAME_LEN];
const char *fname = bb_basename(m->name); const char *fname = bb_basename(m->name);
int fnlen = strchrnul(fname, '.') - fname; filename2modname(fname, modname);
while (m->aliases) { while (m->aliases) {
/* Last word can well be m->modname instead, /* Last word can well be m->modname instead,
* but depmod from module-init-tools 3.4 * but depmod from module-init-tools 3.4
* uses module basename, i.e., no s/-/_/g. * uses module basename, i.e., no s/-/_/g.
* (pathname and .ko.* are still stripped) * (pathname and .ko.* are still stripped)
* Mimicking that... */ * Mimicking that... */
printf("alias %s %.*s\n", printf("alias %s %s\n",
(char*)llist_pop(&m->aliases), (char*)llist_pop(&m->aliases),
fnlen, fname); modname);
} }
} }
#endif #endif
@ -260,12 +265,13 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
if (!(option_mask32 & OPT_n)) if (!(option_mask32 & OPT_n))
xfreopen_write("modules.symbols", stdout); xfreopen_write("modules.symbols", stdout);
for (m = modules; m != NULL; m = m->next) { for (m = modules; m != NULL; m = m->next) {
char modname[MODULE_NAME_LEN];
const char *fname = bb_basename(m->name); const char *fname = bb_basename(m->name);
int fnlen = strchrnul(fname, '.') - fname; filename2modname(fname, modname);
while (m->symbols) { while (m->symbols) {
printf("alias symbol:%s %.*s\n", printf("alias symbol:%s %s\n",
(char*)llist_pop(&m->symbols), (char*)llist_pop(&m->symbols),
fnlen, fname); modname);
} }
} }
#endif #endif