aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauri Kasanen <curaga@operamail.com>2010-06-27 00:35:49 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-06-27 00:35:49 +0200
commit1b14cdb27ca5e8104a824424731be430c8592dd6 (patch)
tree1971c55f2f82ee5e17a371b6964b6e7538e93578
parentf6464000cab81639e76b45b861d828d3931a0b77 (diff)
downloadbusybox-w32-1b14cdb27ca5e8104a824424731be430c8592dd6.tar.gz
busybox-w32-1b14cdb27ca5e8104a824424731be430c8592dd6.tar.bz2
busybox-w32-1b14cdb27ca5e8104a824424731be430c8592dd6.zip
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 <curaga@operamail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--modutils/modinfo.c35
1 files changed, 24 insertions, 11 deletions
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)
43 return printf("%s%c", data, (option_mask32 & OPT_0) ? '\0' : '\n'); 43 return printf("%s%c", data, (option_mask32 & OPT_0) ? '\0' : '\n');
44} 44}
45 45
46static void modinfo(const char *path, struct modinfo_env *env) 46static void modinfo(const char *path, const char *version,
47 struct modinfo_env *env)
47{ 48{
48 static const char *const shortcuts[] = { 49 static const char *const shortcuts[] = {
49 "filename", 50 "filename",
@@ -62,10 +63,20 @@ static void modinfo(const char *path, struct modinfo_env *env)
62 if (tags & 1) { /* filename */ 63 if (tags & 1) { /* filename */
63 display(path, shortcuts[0], 1 != tags); 64 display(path, shortcuts[0], 1 != tags);
64 } 65 }
66
65 len = MAXINT(ssize_t); 67 len = MAXINT(ssize_t);
66 the_module = xmalloc_open_zipped_read_close(path, &len); 68 the_module = xmalloc_open_zipped_read_close(path, &len);
67 if (!the_module) 69 if (!the_module) {
68 return; 70 if (path[0] == '/')
71 return;
72 /* Newer depmod puts relative paths in modules.dep */
73 path = xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, version, path);
74 the_module = xmalloc_open_zipped_read_close(path, &len);
75 free((char*)path);
76 if (!the_module)
77 return;
78 }
79
69 if (field) 80 if (field)
70 tags |= OPT_F; 81 tags |= OPT_F;
71 for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) { 82 for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) {
@@ -109,7 +120,7 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
109 struct modinfo_env env; 120 struct modinfo_env env;
110 char name[MODULE_NAME_LEN]; 121 char name[MODULE_NAME_LEN];
111 struct utsname uts; 122 struct utsname uts;
112 parser_t *p; 123 parser_t *parser;
113 char *colon, *tokens[2]; 124 char *colon, *tokens[2];
114 unsigned opts; 125 unsigned opts;
115 unsigned i; 126 unsigned i;
@@ -121,14 +132,12 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
121 argv += optind; 132 argv += optind;
122 133
123 uname(&uts); 134 uname(&uts);
124 p = config_open2( 135 parser = config_open2(
125 concat_path_file( 136 xasprintf("%s/%s/%s", CONFIG_DEFAULT_MODULES_DIR, uts.release, CONFIG_DEFAULT_DEPMOD_FILE),
126 concat_path_file(CONFIG_DEFAULT_MODULES_DIR, uts.release),
127 CONFIG_DEFAULT_DEPMOD_FILE),
128 xfopen_for_read 137 xfopen_for_read
129 ); 138 );
130 139
131 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) { 140 while (config_read(parser, tokens, 2, 1, "# \t", PARSE_NORMAL)) {
132 colon = last_char_is(tokens[0], ':'); 141 colon = last_char_is(tokens[0], ':');
133 if (colon == NULL) 142 if (colon == NULL)
134 continue; 143 continue;
@@ -136,15 +145,19 @@ int modinfo_main(int argc UNUSED_PARAM, char **argv)
136 filename2modname(tokens[0], name); 145 filename2modname(tokens[0], name);
137 for (i = 0; argv[i]; i++) { 146 for (i = 0; argv[i]; i++) {
138 if (fnmatch(argv[i], name, 0) == 0) { 147 if (fnmatch(argv[i], name, 0) == 0) {
139 modinfo(tokens[0], &env); 148 modinfo(tokens[0], uts.release, &env);
140 argv[i] = (char *) ""; 149 argv[i] = (char *) "";
141 } 150 }
142 } 151 }
143 } 152 }
153 if (ENABLE_FEATURE_CLEAN_UP)
154 config_close(parser);
155
144 for (i = 0; argv[i]; i++) { 156 for (i = 0; argv[i]; i++) {
145 if (argv[i][0]) { 157 if (argv[i][0]) {
146 modinfo(argv[i], &env); 158 modinfo(argv[i], uts.release, &env);
147 } 159 }
148 } 160 }
161
149 return 0; 162 return 0;
150} 163}