aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-07-18 17:41:17 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-07-18 17:41:17 +0200
commit4cab7f3e63ff850bc478f96d0589a01dec878a00 (patch)
treee480cb7ef1d885efd8daa41ba0f45508259701b0
parentd1516c4d628dbded9e1abefaacc1535aaecef418 (diff)
downloadbusybox-w32-4cab7f3e63ff850bc478f96d0589a01dec878a00.tar.gz
busybox-w32-4cab7f3e63ff850bc478f96d0589a01dec878a00.tar.bz2
busybox-w32-4cab7f3e63ff850bc478f96d0589a01dec878a00.zip
depmod: generate "new-style" modules.dep with relative paths.
function old new delta parse_module 384 379 -5 depmod_main 590 559 -31 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 0/2 up/down: 0/-36) Total: -36 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--modutils/depmod.c76
1 files changed, 47 insertions, 29 deletions
diff --git a/modutils/depmod.c b/modutils/depmod.c
index c734f142b..694f9ea5a 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -28,16 +28,6 @@ typedef struct module_info {
28 struct module_info *dnext, *dprev; 28 struct module_info *dnext, *dprev;
29} module_info; 29} module_info;
30 30
31enum {
32 ARG_a = (1<<0), /* All modules, ignore mods in argv */
33 ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */
34 ARG_b = (1<<2), /* base directory when modules are in staging area */
35 ARG_e = (1<<3), /* with -F, print unresolved symbols */
36 ARG_F = (1<<4), /* System.map that contains the symbols */
37 ARG_n = (1<<5), /* dry-run, print to stdout only */
38 ARG_r = (1<<6) /* Compat dummy. Linux Makefile uses it */
39};
40
41static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM, 31static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
42 void *data, int depth UNUSED_PARAM) 32 void *data, int depth UNUSED_PARAM)
43{ 33{
@@ -58,7 +48,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
58 *first = info; 48 *first = info;
59 49
60 info->dnext = info->dprev = info; 50 info->dnext = info->dprev = info;
61 info->name = xasprintf("/%s", fname); 51 info->name = xstrdup(fname + 2); /* skip "./" */
62 info->modname = xstrdup(filename2modname(fname, modname)); 52 info->modname = xstrdup(filename2modname(fname, modname));
63 for (ptr = image; ptr < image + len - 10; ptr++) { 53 for (ptr = image; ptr < image + len - 10; ptr++) {
64 if (strncmp(ptr, "depends=", 8) == 0) { 54 if (strncmp(ptr, "depends=", 8) == 0) {
@@ -134,10 +124,44 @@ static void xfreopen_write(const char *file, FILE *f)
134 bb_perror_msg_and_die("can't open '%s'", file); 124 bb_perror_msg_and_die("can't open '%s'", file);
135} 125}
136 126
127/* Usage:
128 * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]...
129 * -a --all
130 * Probe all modules. Default if no MODFILES.
131 * -A --quick
132 * Check modules.dep's mtime against module files' mtimes.
133 * -b --basedir BASE
134 * Use $BASE/lib/modules/VERSION
135 * -C --config FILE or DIR
136 * Path to /etc/depmod.conf or /etc/depmod.d/
137 * -e --errsyms
138 * When combined with the -F option, this reports any symbols which
139 * which are not supplied by other modules or kernel.
140 * -F --filesyms System.map
141 * -n --dry-run
142 * Print modules.dep etc to standard output
143 * -v --verbose
144 * Print to stdout all the symbols each module depends on
145 * and the module's file name which provides that symbol.
146 * -r No-op
147 *
148 * So far we only support: [-rn] [-b BASE] [VERSION] [MODFILES]...
149 * -aAeF are accepted but ignored. -vC are not accepted.
150 */
151enum {
152 //OPT_a = (1 << 0), /* All modules, ignore mods in argv */
153 //OPT_A = (1 << 1), /* Only emit .ko that are newer than modules.dep file */
154 OPT_b = (1 << 2), /* base directory when modules are in staging area */
155 //OPT_e = (1 << 3), /* with -F, print unresolved symbols */
156 //OPT_F = (1 << 4), /* System.map that contains the symbols */
157 OPT_n = (1 << 5), /* dry-run, print to stdout only */
158 OPT_r = (1 << 6) /* Compat dummy. Linux Makefile uses it */
159};
160
137int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 161int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
138int depmod_main(int argc UNUSED_PARAM, char **argv) 162int depmod_main(int argc UNUSED_PARAM, char **argv)
139{ 163{
140 module_info *modules = NULL, *m, *dep; 164 module_info *modules, *m, *dep;
141 const char *moddir_base = "/"; 165 const char *moddir_base = "/";
142 char *moddir, *version; 166 char *moddir, *version;
143 struct utsname uts; 167 struct utsname uts;
@@ -152,36 +176,30 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
152 /* If a version is provided, then that kernel version's module directory 176 /* If a version is provided, then that kernel version's module directory
153 * is used, rather than the current kernel version (as returned by 177 * is used, rather than the current kernel version (as returned by
154 * "uname -r"). */ 178 * "uname -r"). */
155 if (*argv && sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3) { 179 if (*argv && sscanf(*argv, "%u.%u.%u", &tmp, &tmp, &tmp) == 3) {
156 version = *argv++; 180 version = *argv++;
157 } else { 181 } else {
158 uname(&uts); 182 uname(&uts);
159 version = uts.release; 183 version = uts.release;
160 } 184 }
161 moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version); 185 moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version);
186 xchdir(moddir);
187 if (ENABLE_FEATURE_CLEAN_UP)
188 free(moddir);
162 189
163 /* Scan modules */ 190 /* Scan modules */
191 modules = NULL;
164 if (*argv) { 192 if (*argv) {
165 char *modfile;
166 struct stat sb;
167 do { 193 do {
168 modfile = concat_path_file(moddir, *argv); 194 parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0);
169 xstat(modfile, &sb); 195 } while (*++argv);
170 parse_module(modfile, &sb, &modules, 0);
171 free(modfile);
172 } while (*(++argv));
173 } else { 196 } else {
174 recursive_action(moddir, ACTION_RECURSE, 197 recursive_action(".", ACTION_RECURSE,
175 parse_module, NULL, &modules, 0); 198 parse_module, NULL, &modules, 0);
176 } 199 }
177 200
178 /* Prepare for writing out the dep files */
179 xchdir(moddir);
180 if (ENABLE_FEATURE_CLEAN_UP)
181 free(moddir);
182
183 /* Generate dependency and alias files */ 201 /* Generate dependency and alias files */
184 if (!(option_mask32 & ARG_n)) 202 if (!(option_mask32 & OPT_n))
185 xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout); 203 xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
186 for (m = modules; m != NULL; m = m->next) { 204 for (m = modules; m != NULL; m = m->next) {
187 printf("%s:", m->name); 205 printf("%s:", m->name);
@@ -200,7 +218,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
200 } 218 }
201 219
202#if ENABLE_FEATURE_MODUTILS_ALIAS 220#if ENABLE_FEATURE_MODUTILS_ALIAS
203 if (!(option_mask32 & ARG_n)) 221 if (!(option_mask32 & OPT_n))
204 xfreopen_write("modules.alias", stdout); 222 xfreopen_write("modules.alias", stdout);
205 for (m = modules; m != NULL; m = m->next) { 223 for (m = modules; m != NULL; m = m->next) {
206 const char *fname = bb_basename(m->name); 224 const char *fname = bb_basename(m->name);
@@ -218,7 +236,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
218 } 236 }
219#endif 237#endif
220#if ENABLE_FEATURE_MODUTILS_SYMBOLS 238#if ENABLE_FEATURE_MODUTILS_SYMBOLS
221 if (!(option_mask32 & ARG_n)) 239 if (!(option_mask32 & OPT_n))
222 xfreopen_write("modules.symbols", stdout); 240 xfreopen_write("modules.symbols", stdout);
223 for (m = modules; m != NULL; m = m->next) { 241 for (m = modules; m != NULL; m = m->next) {
224 const char *fname = bb_basename(m->name); 242 const char *fname = bb_basename(m->name);