Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
| 2 | /* |
| 3 | * depmod - generate modules.dep |
Bernhard Reutner-Fischer | 6c4dade | 2008-09-25 12:13:34 +0000 | [diff] [blame] | 4 | * Copyright (c) 2008 Bernhard Reutner-Fischer |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 5 | * Copyrihgt (c) 2008 Timo Teras <timo.teras@iki.fi> |
| 6 | * Copyright (c) 2008 Vladimir Dronnikov |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 7 | * |
Denys Vlasenko | 0ef64bd | 2010-08-16 20:14:46 +0200 | [diff] [blame] | 8 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 9 | */ |
Denys Vlasenko | e32b64c | 2016-11-23 07:54:52 +0100 | [diff] [blame] | 10 | //config:config DEPMOD |
Denys Vlasenko | 4eed2c6 | 2017-07-18 22:01:24 +0200 | [diff] [blame^] | 11 | //config: bool "depmod (26 kb)" |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 12 | //config: default y |
Denys Vlasenko | e32b64c | 2016-11-23 07:54:52 +0100 | [diff] [blame] | 13 | //config: select PLATFORM_LINUX |
| 14 | //config: help |
| 15 | //config: depmod generates modules.dep (and potentially modules.alias |
| 16 | //config: and modules.symbols) that contain dependency information |
| 17 | //config: for modprobe. |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 18 | |
Denys Vlasenko | a1cd0d9 | 2016-12-23 15:12:27 +0100 | [diff] [blame] | 19 | //applet:IF_DEPMOD(IF_NOT_MODPROBE_SMALL(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP))) |
Denys Vlasenko | c15613c | 2010-10-15 11:29:02 +0200 | [diff] [blame] | 20 | |
Denys Vlasenko | 1f71014 | 2017-01-01 13:12:48 +0100 | [diff] [blame] | 21 | //kbuild:ifneq ($(CONFIG_MODPROBE_SMALL),y) |
Denys Vlasenko | e32b64c | 2016-11-23 07:54:52 +0100 | [diff] [blame] | 22 | //kbuild:lib-$(CONFIG_DEPMOD) += depmod.o modutils.o |
Denys Vlasenko | 1f71014 | 2017-01-01 13:12:48 +0100 | [diff] [blame] | 23 | //kbuild:endif |
Denys Vlasenko | e32b64c | 2016-11-23 07:54:52 +0100 | [diff] [blame] | 24 | |
Denys Vlasenko | 043b1e5 | 2009-09-06 12:47:55 +0200 | [diff] [blame] | 25 | #include "libbb.h" |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 26 | #include "modutils.h" |
Denys Vlasenko | 043b1e5 | 2009-09-06 12:47:55 +0200 | [diff] [blame] | 27 | #include <sys/utsname.h> /* uname() */ |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 28 | |
Bernhard Reutner-Fischer | cf18010 | 2008-05-26 15:12:01 +0000 | [diff] [blame] | 29 | /* |
| 30 | * Theory of operation: |
| 31 | * - iterate over all modules and record their full path |
| 32 | * - iterate over all modules looking for "depends=" entries |
| 33 | * for each depends, look through our list of full paths and emit if found |
| 34 | */ |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 35 | |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 36 | static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM, |
Denys Vlasenko | 6967578 | 2013-01-14 01:34:48 +0100 | [diff] [blame] | 37 | void *data, int depth UNUSED_PARAM) |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 38 | { |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 39 | module_db *modules = data; |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 40 | char *image, *ptr; |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 41 | module_entry *e; |
| 42 | |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 43 | /* Arbitrary. Was sb->st_size, but that breaks .gz etc */ |
| 44 | size_t len = (64*1024*1024 - 4096); |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 45 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 46 | if (strrstr(fname, ".ko") == NULL) |
| 47 | return TRUE; |
Bernhard Reutner-Fischer | 634b022 | 2008-05-28 14:20:20 +0000 | [diff] [blame] | 48 | |
Denis Vlasenko | fc66892 | 2008-11-06 02:32:31 +0000 | [diff] [blame] | 49 | image = xmalloc_open_zipped_read_close(fname, &len); |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 50 | |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 51 | e = moddb_get_or_create(modules, bb_get_last_path_component_nostrip(fname)); |
| 52 | e->name = xstrdup(fname + 2); /* skip "./" */ |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 53 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 54 | for (ptr = image; ptr < image + len - 10; ptr++) { |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 55 | if (is_prefixed_with(ptr, "depends=")) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 56 | char *u; |
| 57 | |
| 58 | ptr += 8; |
| 59 | for (u = ptr; *u; u++) |
| 60 | if (*u == '-') |
| 61 | *u = '_'; |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 62 | ptr += string_to_llist(ptr, &e->deps, ","); |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 63 | } else if (ENABLE_FEATURE_MODUTILS_ALIAS |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 64 | && is_prefixed_with(ptr, "alias=") |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 65 | ) { |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 66 | llist_add_to(&e->aliases, xstrdup(ptr + 6)); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 67 | ptr += strlen(ptr); |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 68 | } else if (ENABLE_FEATURE_MODUTILS_SYMBOLS |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 69 | && is_prefixed_with(ptr, "__ksymtab_") |
Denys Vlasenko | 16bda3b | 2009-05-18 13:08:04 +0200 | [diff] [blame] | 70 | ) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 71 | ptr += 10; |
Denys Vlasenko | 8dff01d | 2015-03-12 17:48:34 +0100 | [diff] [blame] | 72 | if (is_prefixed_with(ptr, "gpl") |
Denys Vlasenko | 6b9f163 | 2010-01-28 02:24:24 +0100 | [diff] [blame] | 73 | || strcmp(ptr, "strings") == 0 |
| 74 | ) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 75 | continue; |
Denys Vlasenko | 6b9f163 | 2010-01-28 02:24:24 +0100 | [diff] [blame] | 76 | } |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 77 | llist_add_to(&e->symbols, xstrdup(ptr)); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 78 | ptr += strlen(ptr); |
| 79 | } |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 80 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 81 | free(image); |
| 82 | |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 83 | return TRUE; |
| 84 | } |
| 85 | |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 86 | static void order_dep_list(module_db *modules, module_entry *start, llist_t *add) |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 87 | { |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 88 | module_entry *m; |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 89 | llist_t *n; |
| 90 | |
| 91 | for (n = add; n != NULL; n = n->link) { |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 92 | m = moddb_get(modules, n->data); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 93 | if (m == NULL) |
| 94 | continue; |
| 95 | |
| 96 | /* unlink current entry */ |
| 97 | m->dnext->dprev = m->dprev; |
| 98 | m->dprev->dnext = m->dnext; |
| 99 | |
| 100 | /* and add it to tail */ |
| 101 | m->dnext = start; |
| 102 | m->dprev = start->dprev; |
| 103 | start->dprev->dnext = m; |
| 104 | start->dprev = m; |
| 105 | |
| 106 | /* recurse */ |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 107 | order_dep_list(modules, start, m->deps); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 108 | } |
| 109 | } |
| 110 | |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 111 | static void xfreopen_write(const char *file, FILE *f) |
| 112 | { |
| 113 | if (freopen(file, "w", f) == NULL) |
| 114 | bb_perror_msg_and_die("can't open '%s'", file); |
| 115 | } |
| 116 | |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 117 | //usage:#if !ENABLE_MODPROBE_SMALL |
| 118 | //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..." |
| 119 | //usage:#define depmod_full_usage "\n\n" |
| 120 | //usage: "Generate modules.dep, alias, and symbols files" |
| 121 | //usage: "\n" |
| 122 | //usage: "\n -b BASE Use BASE/lib/modules/VERSION" |
| 123 | //usage: "\n -n Dry run: print files to stdout" |
| 124 | //usage:#endif |
| 125 | |
| 126 | /* Upstream usage: |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 127 | * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]... |
| 128 | * -a --all |
| 129 | * Probe all modules. Default if no MODFILES. |
| 130 | * -A --quick |
| 131 | * Check modules.dep's mtime against module files' mtimes. |
| 132 | * -b --basedir BASE |
| 133 | * Use $BASE/lib/modules/VERSION |
| 134 | * -C --config FILE or DIR |
| 135 | * Path to /etc/depmod.conf or /etc/depmod.d/ |
| 136 | * -e --errsyms |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 137 | * When combined with the -F option, this reports any symbols |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 138 | * which are not supplied by other modules or kernel. |
| 139 | * -F --filesyms System.map |
| 140 | * -n --dry-run |
| 141 | * Print modules.dep etc to standard output |
| 142 | * -v --verbose |
| 143 | * Print to stdout all the symbols each module depends on |
| 144 | * and the module's file name which provides that symbol. |
| 145 | * -r No-op |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 146 | * -u No-op |
| 147 | * -q No-op |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 148 | * |
Lauri Kasanen | 5a5db93 | 2012-02-19 16:33:37 +0100 | [diff] [blame] | 149 | * So far we only support: [-n] [-b BASE] [VERSION] [MODFILES]... |
| 150 | * Accepted but ignored: |
| 151 | * -aAe |
| 152 | * -F System.map |
| 153 | * -C FILE/DIR |
| 154 | * |
| 155 | * Not accepted: -v |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 156 | */ |
| 157 | enum { |
| 158 | //OPT_a = (1 << 0), /* All modules, ignore mods in argv */ |
| 159 | //OPT_A = (1 << 1), /* Only emit .ko that are newer than modules.dep file */ |
| 160 | OPT_b = (1 << 2), /* base directory when modules are in staging area */ |
| 161 | //OPT_e = (1 << 3), /* with -F, print unresolved symbols */ |
| 162 | //OPT_F = (1 << 4), /* System.map that contains the symbols */ |
| 163 | OPT_n = (1 << 5), /* dry-run, print to stdout only */ |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 164 | OPT_r = (1 << 6), /* Compat dummy. Linux Makefile uses it */ |
| 165 | OPT_u = (1 << 7), /* -u,--unresolved-error: ignored */ |
| 166 | OPT_q = (1 << 8), /* -q,--quiet: ignored */ |
| 167 | OPT_C = (1 << 9), /* -C,--config etc_modules_conf: ignored */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 168 | }; |
| 169 | |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 170 | int depmod_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 171 | int depmod_main(int argc UNUSED_PARAM, char **argv) |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 172 | { |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 173 | module_db modules; |
| 174 | module_entry *m, *dep; |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 175 | const char *moddir_base = "/"; |
| 176 | char *moddir, *version; |
| 177 | struct utsname uts; |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 178 | unsigned i; |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 179 | int tmp; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 180 | |
Pascal Bellard | cadf901 | 2010-10-18 00:51:16 +0200 | [diff] [blame] | 181 | getopt32(argv, "aAb:eF:nruqC:", &moddir_base, NULL, NULL); |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 182 | argv += optind; |
Bernhard Reutner-Fischer | c21d9c7 | 2008-05-28 10:35:51 +0000 | [diff] [blame] | 183 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 184 | /* goto modules location */ |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 185 | xchdir(moddir_base); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 186 | |
| 187 | /* If a version is provided, then that kernel version's module directory |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 188 | * is used, rather than the current kernel version (as returned by |
| 189 | * "uname -r"). */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 190 | if (*argv && sscanf(*argv, "%u.%u.%u", &tmp, &tmp, &tmp) == 3) { |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 191 | version = *argv++; |
Bernhard Reutner-Fischer | 1ea2568 | 2008-05-26 21:33:05 +0000 | [diff] [blame] | 192 | } else { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 193 | uname(&uts); |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 194 | version = uts.release; |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 195 | } |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 196 | moddir = concat_path_file(&CONFIG_DEFAULT_MODULES_DIR[1], version); |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 197 | xchdir(moddir); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 198 | if (ENABLE_FEATURE_CLEAN_UP) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 199 | free(moddir); |
Bernhard Reutner-Fischer | 6bb55cf | 2008-05-26 17:04:01 +0000 | [diff] [blame] | 200 | |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 201 | /* Scan modules */ |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 202 | memset(&modules, 0, sizeof(modules)); |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 203 | if (*argv) { |
| 204 | do { |
| 205 | parse_module(*argv, /*sb (unused):*/ NULL, &modules, 0); |
| 206 | } while (*++argv); |
| 207 | } else { |
| 208 | recursive_action(".", ACTION_RECURSE, |
Denys Vlasenko | 6967578 | 2013-01-14 01:34:48 +0100 | [diff] [blame] | 209 | parse_module, NULL, &modules, 0); |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 210 | } |
| 211 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 212 | /* Generate dependency and alias files */ |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 213 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 214 | xfreopen_write(CONFIG_DEFAULT_DEPMOD_FILE, stdout); |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 215 | |
| 216 | moddb_foreach_module(&modules, m, i) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 217 | printf("%s:", m->name); |
| 218 | |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 219 | order_dep_list(&modules, m, m->deps); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 220 | while (m->dnext != m) { |
| 221 | dep = m->dnext; |
| 222 | printf(" %s", dep->name); |
| 223 | |
| 224 | /* unlink current entry */ |
| 225 | dep->dnext->dprev = dep->dprev; |
| 226 | dep->dprev->dnext = dep->dnext; |
| 227 | dep->dnext = dep->dprev = dep; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 228 | } |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 229 | bb_putchar('\n'); |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 232 | #if ENABLE_FEATURE_MODUTILS_ALIAS |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 233 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 234 | xfreopen_write("modules.alias", stdout); |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 235 | moddb_foreach_module(&modules, m, i) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 236 | while (m->aliases) { |
Denys Vlasenko | cc70b6f | 2015-01-24 22:30:30 +0100 | [diff] [blame] | 237 | /* |
| 238 | * Last word used to be a basename |
| 239 | * (filename with path and .ko.* stripped) |
| 240 | * at the time of module-init-tools 3.4. |
| 241 | * kmod v.12 uses module name, i.e., s/-/_/g. |
| 242 | */ |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 243 | printf("alias %s %s\n", |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 244 | (char*)llist_pop(&m->aliases), |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 245 | m->modname); |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 246 | } |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 247 | } |
| 248 | #endif |
| 249 | #if ENABLE_FEATURE_MODUTILS_SYMBOLS |
Denys Vlasenko | 4cab7f3 | 2010-07-18 17:41:17 +0200 | [diff] [blame] | 250 | if (!(option_mask32 & OPT_n)) |
Denis Vlasenko | 3526115 | 2009-01-12 22:12:22 +0000 | [diff] [blame] | 251 | xfreopen_write("modules.symbols", stdout); |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 252 | moddb_foreach_module(&modules, m, i) { |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 253 | while (m->symbols) { |
Denys Vlasenko | 08364da | 2015-01-07 14:39:01 +0100 | [diff] [blame] | 254 | printf("alias symbol:%s %s\n", |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 255 | (char*)llist_pop(&m->symbols), |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 256 | m->modname); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 257 | } |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 258 | } |
Bernhard Reutner-Fischer | c2741e1 | 2008-06-02 18:59:16 +0000 | [diff] [blame] | 259 | #endif |
Bernhard Reutner-Fischer | beac1bd | 2008-06-02 13:28:47 +0000 | [diff] [blame] | 260 | |
Timo Teräs | 48dc80b | 2015-11-05 18:54:55 +0100 | [diff] [blame] | 261 | if (ENABLE_FEATURE_CLEAN_UP) |
| 262 | moddb_free(&modules); |
Denis Vlasenko | ba1315d | 2008-09-13 14:59:38 +0000 | [diff] [blame] | 263 | |
| 264 | return EXIT_SUCCESS; |
Bernhard Reutner-Fischer | 55e547e | 2008-05-26 12:01:49 +0000 | [diff] [blame] | 265 | } |