From 1b14cdb27ca5e8104a824424731be430c8592dd6 Mon Sep 17 00:00:00 2001 From: Lauri Kasanen Date: Sun, 27 Jun 2010 00:35:49 +0200 Subject: modinfo: support relative paths in modules.dep function old new delta modinfo 272 329 +57 modinfo_main 325 344 +19 Signed-off-by: Lauri Kasanen Signed-off-by: Denys Vlasenko --- modutils/modinfo.c | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'modutils/modinfo.c') diff --git a/modutils/modinfo.c b/modutils/modinfo.c index 321ad78f4..454a1b366 100644 --- a/modutils/modinfo.c +++ b/modutils/modinfo.c @@ -43,7 +43,8 @@ static int display(const char *data, const char *pattern, int flag) return printf("%s%c", data, (option_mask32 & OPT_0) ? '\0' : '\n'); } -static void modinfo(const char *path, struct modinfo_env *env) +static void modinfo(const char *path, const char *version, + struct modinfo_env *env) { static const char *const shortcuts[] = { "filename", @@ -62,10 +63,20 @@ static void modinfo(const char *path, struct modinfo_env *env) if (tags & 1) { /* filename */ display(path, shortcuts[0], 1 != tags); } + len = MAXINT(ssize_t); the_module = xmalloc_open_zipped_read_close(path, &len); - if (!the_module) - return; + if (!the_module) { + if (path[0] == '/') + return; + /* Newer depmod puts relative paths in modules.dep */ + path = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path); + the_module = xmalloc_open_zipped_read_close(path, &len); + free((char*)path); + if (!the_module) + return; + } + if (field) tags |= OPT_F; for (j = 1; (1<