mirror of
https://github.com/sheumann/hush.git
synced 2024-12-30 05:29:47 +00:00
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>
This commit is contained in:
parent
d1516c4d62
commit
4cab7f3e63
@ -28,16 +28,6 @@ typedef struct module_info {
|
||||
struct module_info *dnext, *dprev;
|
||||
} module_info;
|
||||
|
||||
enum {
|
||||
ARG_a = (1<<0), /* All modules, ignore mods in argv */
|
||||
ARG_A = (1<<1), /* Only emit .ko that are newer than modules.dep file */
|
||||
ARG_b = (1<<2), /* base directory when modules are in staging area */
|
||||
ARG_e = (1<<3), /* with -F, print unresolved symbols */
|
||||
ARG_F = (1<<4), /* System.map that contains the symbols */
|
||||
ARG_n = (1<<5), /* dry-run, print to stdout only */
|
||||
ARG_r = (1<<6) /* Compat dummy. Linux Makefile uses it */
|
||||
};
|
||||
|
||||
static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
|
||||
void *data, int depth UNUSED_PARAM)
|
||||
{
|
||||
@ -58,7 +48,7 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
|
||||
*first = info;
|
||||
|
||||
info->dnext = info->dprev = info;
|
||||
info->name = xasprintf("/%s", fname);
|
||||
info->name = xstrdup(fname + 2); /* skip "./" */
|
||||
info->modname = xstrdup(filename2modname(fname, modname));
|
||||
for (ptr = image; ptr < image + len - 10; ptr++) {
|
||||
if (strncmp(ptr, "depends=", 8) == 0) {
|
||||
@ -134,10 +124,44 @@ static void xfreopen_write(const char *file, FILE *f)
|
||||
bb_perror_msg_and_die("can't open '%s'", file);
|
||||
}
|
||||
|
||||
/* Usage:
|
||||
* [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]...
|
||||
* -a --all
|
||||
* Probe all modules. Default if no MODFILES.
|
||||
* -A --quick
|
||||
* Check modules.dep's mtime against module files' mtimes.
|
||||
* -b --basedir BASE
|
||||
* Use $BASE/lib/modules/VERSION
|
||||
* -C --config FILE or DIR
|
||||
* Path to /etc/depmod.conf or /etc/depmod.d/
|
||||
* -e --errsyms
|
||||
* When combined with the -F option, this reports any symbols which
|
||||
* which are not supplied by other modules or kernel.
|
||||
* -F --filesyms System.map
|
||||
* -n --dry-run
|
||||
* Print modules.dep etc to standard output
|
||||
* -v --verbose
|
||||
* Print to stdout all the symbols each module depends on
|
||||
* and the module's file name which provides that symbol.
|
||||
* -r No-op
|
||||
*
|
||||
* So far we only support: [-rn] [-b BASE] [VERSION] [MODFILES]...
|
||||
* -aAeF are accepted but ignored. -vC are not accepted.
|
||||
*/
|
||||
enum {
|
||||
//OPT_a = (1 << 0), /* All modules, ignore mods in argv */
|
||||
//OPT_A = (1 << 1), /* Only emit .ko that are newer than modules.dep file */
|
||||
OPT_b = (1 << 2), /* base directory when modules are in staging area */
|
||||
//OPT_e = (1 << 3), /* with -F, print unresolved symbols */
|
||||
//OPT_F = (1 << 4), /* System.map that contains the symbols */
|
||||
OPT_n = (1 << 5), /* dry-run, print to stdout only */
|
||||
OPT_r = (1 << 6) /* Compat dummy. Linux Makefile uses it */
|
||||
};
|
||||
|
||||
int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
||||
int depmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
{
|
||||
module_info *modules = NULL, *m, *dep;
|
||||
module_info *modules, *m, *dep;
|
||||
const char *moddir_base = "/";
|
||||
char *moddir, *version;
|
||||
struct utsname uts;
|
||||
@ -152,36 +176,30 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
/* If a version is provided, then that kernel version's module directory
|
||||
* is used, rather than the current kernel version (as returned by
|
||||
* "uname -r"). */
|
||||
if (*argv && sscanf(*argv, "%d.%d.%d", &tmp, &tmp, &tmp) == 3) {
|
||||
if (*argv && sscanf(*argv, "%u.%u.%u", &tmp, &tmp, &tmp) == 3) {
|
||||
version = *argv++;
|
||||
} else {
|
||||
uname(&uts);
|
||||
version = uts.release;
|
||||
}
|
||||
moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version);
|
||||
|
||||
/* Scan modules */
|
||||
if (*argv) {
|
||||
char *modfile;
|
||||
struct stat sb;
|
||||
do {
|
||||
modfile = concat_path_file(moddir, *argv);
|
||||
xstat(modfile, &sb);
|
||||
parse_module(modfile, &sb, &modules, 0);
|
||||
free(modfile);
|
||||
} while (*(++argv));
|
||||
} else {
|
||||
recursive_action(moddir, ACTION_RECURSE,
|
||||
parse_module, NULL, &modules, 0);
|
||||
}
|
||||
|
||||
/* Prepare for writing out the dep files */
|
||||
xchdir(moddir);
|
||||
if (ENABLE_FEATURE_CLEAN_UP)
|
||||
free(moddir);
|
||||
|
||||
/* Scan modules */
|
||||
modules = NULL;
|
||||
if (*argv) {
|
||||
do {
|
||||
parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0);
|
||||
} while (*++argv);
|
||||
} else {
|
||||
recursive_action(".", ACTION_RECURSE,
|
||||
parse_module, NULL, &modules, 0);
|
||||
}
|
||||
|
||||
/* Generate dependency and alias files */
|
||||
if (!(option_mask32 & ARG_n))
|
||||
if (!(option_mask32 & OPT_n))
|
||||
xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout);
|
||||
for (m = modules; m != NULL; m = m->next) {
|
||||
printf("%s:", m->name);
|
||||
@ -200,7 +218,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
|
||||
#if ENABLE_FEATURE_MODUTILS_ALIAS
|
||||
if (!(option_mask32 & ARG_n))
|
||||
if (!(option_mask32 & OPT_n))
|
||||
xfreopen_write("modules.alias", stdout);
|
||||
for (m = modules; m != NULL; m = m->next) {
|
||||
const char *fname = bb_basename(m->name);
|
||||
@ -218,7 +236,7 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
|
||||
}
|
||||
#endif
|
||||
#if ENABLE_FEATURE_MODUTILS_SYMBOLS
|
||||
if (!(option_mask32 & ARG_n))
|
||||
if (!(option_mask32 & OPT_n))
|
||||
xfreopen_write("modules.symbols", stdout);
|
||||
for (m = modules; m != NULL; m = m->next) {
|
||||
const char *fname = bb_basename(m->name);
|
||||
|
Loading…
Reference in New Issue
Block a user