Changeset 3232 in MondoRescue for branches/3.2/mindi-busybox/modutils
- Timestamp:
- Jan 1, 2014, 12:47:38 AM (11 years ago)
- Location:
- branches/3.2/mindi-busybox/modutils
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.2/mindi-busybox/modutils/Config.src
r2725 r3232 5 5 6 6 menu "Linux Module Utilities" 7 depends on PLATFORM_LINUX8 7 9 8 INSERT … … 12 11 bool "Simplified modutils" 13 12 default y 13 select PLATFORM_LINUX 14 14 help 15 15 Simplified modutils. … … 46 46 default y 47 47 depends on MODPROBE_SMALL 48 select PLATFORM_LINUX 48 49 help 49 50 Allow insmod and modprobe take module options from command line. … … 60 61 default n 61 62 depends on !MODPROBE_SMALL 63 select PLATFORM_LINUX 62 64 help 63 65 insmod is used to load specified modules in the running kernel. … … 67 69 default n 68 70 depends on !MODPROBE_SMALL 71 select PLATFORM_LINUX 69 72 help 70 73 rmmod is used to unload specified modules from the kernel. … … 74 77 default n 75 78 depends on !MODPROBE_SMALL 79 select PLATFORM_LINUX 76 80 help 77 81 lsmod is used to display a list of loaded modules. … … 81 85 default n 82 86 depends on LSMOD 87 select PLATFORM_LINUX 83 88 help 84 89 This option makes output format of lsmod adjusted to … … 90 95 default n 91 96 depends on !MODPROBE_SMALL 97 select PLATFORM_LINUX 92 98 help 93 99 Handle the loading of modules, and their dependencies on a high … … 98 104 default n 99 105 depends on MODPROBE 106 select PLATFORM_LINUX 100 107 help 101 108 Say 'y' here to enable support for the 'blacklist' command in … … 109 116 default n 110 117 depends on !MODPROBE_SMALL 118 select PLATFORM_LINUX 111 119 help 112 120 depmod generates modules.dep (and potentially modules.alias … … 120 128 default n 121 129 depends on INSMOD || RMMOD || LSMOD 130 select PLATFORM_LINUX 122 131 help 123 132 Support module loading for 2.2.x and 2.4.x Linux kernels. … … 129 138 default n 130 139 depends on INSMOD || MODPROBE_SMALL 140 select PLATFORM_LINUX 131 141 help 132 142 This option causes module loading code to try to mmap … … 145 155 default n 146 156 depends on FEATURE_2_4_MODULES && (INSMOD || MODPROBE) 157 select PLATFORM_LINUX 147 158 help 148 159 Support checking of versions for modules. This is used to … … 153 164 default n 154 165 depends on FEATURE_2_4_MODULES && (INSMOD || MODPROBE) 166 select PLATFORM_LINUX 155 167 help 156 168 By adding module symbols to the kernel symbol table, Oops messages … … 164 176 default n 165 177 depends on FEATURE_2_4_MODULES && (INSMOD || MODPROBE) 178 select PLATFORM_LINUX 166 179 help 167 180 This is a special uClinux only memory optimization that lets insmod … … 174 187 default n 175 188 depends on FEATURE_2_4_MODULES && INSMOD 189 select PLATFORM_LINUX 176 190 help 177 191 Enabling this, one would be able to get a load map … … 185 199 default y 186 200 depends on FEATURE_INSMOD_LOAD_MAP && !MODPROBE_SMALL 201 select PLATFORM_LINUX 187 202 help 188 203 Without this option, -m will only output section … … 194 209 default y 195 210 depends on (LSMOD || FEATURE_2_4_MODULES) && !MODPROBE_SMALL 211 select PLATFORM_LINUX 196 212 help 197 213 Support checking for tainted modules. These are usually binary … … 204 220 default y 205 221 depends on DEPMOD || MODPROBE 222 select PLATFORM_LINUX 206 223 help 207 224 Generate and parse modules.alias containing aliases for bus … … 220 237 default y 221 238 depends on DEPMOD || MODPROBE 239 select PLATFORM_LINUX 222 240 help 223 241 Generate and parse modules.symbols containing aliases for -
branches/3.2/mindi-busybox/modutils/depmod.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_DEPMOD(APPLET(depmod, _BB_DIR_SBIN, _BB_SUID_DROP)) 12 13 //usage:#if !ENABLE_MODPROBE_SMALL 14 //usage:#define depmod_trivial_usage NOUSAGE_STR 15 //usage:#define depmod_full_usage "" 16 //usage:#endif 11 //applet:IF_DEPMOD(APPLET(depmod, BB_DIR_SBIN, BB_SUID_DROP)) 17 12 18 13 #include "libbb.h" … … 37 32 38 33 static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM, 39 34 void *data, int depth UNUSED_PARAM) 40 35 { 41 36 char modname[MODULE_NAME_LEN]; … … 101 96 102 97 static void order_dep_list(module_info *modules, module_info *start, 103 98 llist_t *add) 104 99 { 105 100 module_info *m; … … 132 127 } 133 128 134 /* Usage: 129 //usage:#if !ENABLE_MODPROBE_SMALL 130 //usage:#define depmod_trivial_usage "[-n] [-b BASE] [VERSION] [MODFILES]..." 131 //usage:#define depmod_full_usage "\n\n" 132 //usage: "Generate modules.dep, alias, and symbols files" 133 //usage: "\n" 134 //usage: "\n -b BASE Use BASE/lib/modules/VERSION" 135 //usage: "\n -n Dry run: print files to stdout" 136 //usage:#endif 137 138 /* Upstream usage: 135 139 * [-aAenv] [-C FILE or DIR] [-b BASE] [-F System.map] [VERSION] [MODFILES]... 136 140 * -a --all … … 143 147 * Path to /etc/depmod.conf or /etc/depmod.d/ 144 148 * -e --errsyms 145 * When combined with the -F option, this reports any symbols which149 * When combined with the -F option, this reports any symbols 146 150 * which are not supplied by other modules or kernel. 147 151 * -F --filesyms System.map … … 155 159 * -q No-op 156 160 * 157 * So far we only support: [-rn] [-b BASE] [VERSION] [MODFILES]... 158 * -aAeF are accepted but ignored. -vC are not accepted. 161 * So far we only support: [-n] [-b BASE] [VERSION] [MODFILES]... 162 * Accepted but ignored: 163 * -aAe 164 * -F System.map 165 * -C FILE/DIR 166 * 167 * Not accepted: -v 159 168 */ 160 169 enum { … … 208 217 } else { 209 218 recursive_action(".", ACTION_RECURSE, 210 219 parse_module, NULL, &modules, 0); 211 220 } 212 221 -
branches/3.2/mindi-busybox/modutils/insmod.c
r2725 r3232 8 8 */ 9 9 10 //applet:IF_INSMOD(APPLET(insmod, _BB_DIR_SBIN, _BB_SUID_DROP))10 //applet:IF_INSMOD(APPLET(insmod, BB_DIR_SBIN, BB_SUID_DROP)) 11 11 12 12 #include "libbb.h" … … 24 24 //usage: "Load the specified kernel modules into the kernel" 25 25 //usage: IF_FEATURE_2_4_MODULES( "\n" 26 //usage: "\nOptions:"27 26 //usage: "\n -f Force module to load into the wrong kernel version" 28 27 //usage: "\n -k Make module autoclean-able" … … 60 59 bb_show_usage(); 61 60 62 rc = bb_init_module(filename, parse_cmdline_module_options(argv ));61 rc = bb_init_module(filename, parse_cmdline_module_options(argv, /*quote_spaces:*/ 0)); 63 62 if (rc) 64 63 bb_error_msg("can't insert '%s': %s", filename, moderror(rc)); -
branches/3.2/mindi-busybox/modutils/lsmod.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP))11 //applet:IF_LSMOD(APPLET(lsmod, BB_DIR_SBIN, BB_SUID_DROP)) 12 12 13 13 //usage:#if !ENABLE_MODPROBE_SMALL … … 88 88 // or comma-separated list ended by comma 89 89 // so trimming the trailing char is just what we need! 90 token[3][strlen(token[3])-1] = '\0'; 90 if (token[3][0]) 91 token[3][strlen(token[3]) - 1] = '\0'; 91 92 # if ENABLE_UNICODE_SUPPORT 92 93 { -
branches/3.2/mindi-busybox/modutils/modinfo.c
r2725 r3232 7 7 */ 8 8 9 //applet:IF_MODINFO(APPLET(modinfo, _BB_DIR_SBIN, _BB_SUID_DROP))9 //applet:IF_MODINFO(APPLET(modinfo, BB_DIR_SBIN, BB_SUID_DROP)) 10 10 11 11 //kbuild:lib-$(CONFIG_MODINFO) += modinfo.o modutils.o … … 14 14 //config: bool "modinfo" 15 15 //config: default y 16 //config: select PLATFORM_LINUX 16 17 //config: help 17 18 //config: Show information about a Linux Kernel module … … 24 25 25 26 enum { 26 OPT_TAGS = (1 << 6) - 1,27 OPT_F = (1 << 6), /* field name */28 OPT_0 = (1 << 7),/* \0 as separator */27 OPT_TAGS = (1 << 12) - 1, /* shortcut count */ 28 OPT_F = (1 << 12), /* field name */ 29 OPT_0 = (1 << 13), /* \0 as separator */ 29 30 }; 30 31 … … 45 46 46 47 static void modinfo(const char *path, const char *version, 47 struct modinfo_env *env)48 const struct modinfo_env *env) 48 49 { 49 50 static const char *const shortcuts[] = { 50 51 "filename", 52 "license", 53 "author", 51 54 "description", 52 "author", 53 "license", 55 "version", 56 "alias", 57 "srcversion", 58 "depends", 59 "uts_release", 54 60 "vermagic", 55 61 "parm", 62 "firmware", 56 63 }; 57 64 size_t len; … … 81 88 tags |= OPT_F; 82 89 for (j = 1; (1<<j) & (OPT_TAGS + OPT_F); j++) { 83 const char *pattern = field; 90 const char *pattern; 91 92 if (!((1<<j) & tags)) 93 continue; 94 pattern = field; 84 95 if ((1<<j) & OPT_TAGS) 85 96 pattern = shortcuts[j]; 86 if (!((1<<j) & tags))87 continue;88 97 length = strlen(pattern); 89 98 ptr = the_module; … … 93 102 break; 94 103 if (strncmp(ptr, pattern, length) == 0 && ptr[length] == '=') { 95 ptr += length + 1; 96 ptr += display(ptr, pattern, (1<<j) != tags); 104 /* field prefixes are 0x80 or 0x00 */ 105 if ((ptr[-1] & 0x7F) == '\0') { 106 ptr += length + 1; 107 ptr += display(ptr, pattern, (1<<j) != tags); 108 } 97 109 } 98 110 ++ptr; … … 105 117 //usage: "[-adlp0] [-F keyword] MODULE" 106 118 //usage:#define modinfo_full_usage "\n\n" 107 //usage: "Options:" 108 //usage: "\n -a Shortcut for '-F author'" 119 //usage: " -a Shortcut for '-F author'" 109 120 //usage: "\n -d Shortcut for '-F description'" 110 121 //usage: "\n -l Shortcut for '-F license'" … … 128 139 env.field = NULL; 129 140 opt_complementary = "-1"; /* minimum one param */ 130 opts = getopt32(argv, " fdalvpF:0", &env.field);141 opts = getopt32(argv, "nladvAsDumpF:0", &env.field); 131 142 env.tags = opts & OPT_TAGS ? opts & OPT_TAGS : OPT_TAGS; 132 143 argv += optind; -
branches/3.2/mindi-busybox/modutils/modprobe-small.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_MODPROBE_SMALL(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP))12 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))13 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))14 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))15 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))11 //applet:IF_MODPROBE_SMALL(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) 12 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(depmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) 13 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(insmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) 14 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) 15 //applet:IF_MODPROBE_SMALL(APPLET_ODDNAME(rmmod, modprobe, BB_DIR_SBIN, BB_SUID_DROP, modprobe)) 16 16 17 17 #include "libbb.h" … … 595 595 goto ret; 596 596 } 597 /* N.B. we do not stop here - 597 598 if (applet_name[0] == 'r') { 599 /* rmmod: do not remove dependencies, exit */ 600 goto ret; 601 } 602 603 /* modprobe -r: we do not stop here - 598 604 * continue to unload modules on which the module depends: 599 605 * "-r --remove: option causes modprobe to remove a module. 600 606 * If the modules it depends on are also unused, modprobe 601 * will try to remove them, too." */ 607 * will try to remove them, too." 608 */ 602 609 } 603 610 … … 697 704 //usage:#if ENABLE_MODPROBE_SMALL 698 705 706 //// Note: currently, help system shows modprobe --help text for all aliased cmds 707 //// (see APPLET_ODDNAME macro definition). 708 //// All other help texts defined below are not used. FIXME? 709 699 710 //usage:#define depmod_trivial_usage NOUSAGE_STR 700 711 //usage:#define depmod_full_usage "" … … 712 723 //usage: "Load the specified kernel modules into the kernel" 713 724 //usage: IF_FEATURE_2_4_MODULES( "\n" 714 //usage: "\nOptions:"715 725 //usage: "\n -f Force module to load into the wrong kernel version" 716 726 //usage: "\n -k Make module autoclean-able" … … 728 738 //usage:#define rmmod_full_usage "\n\n" 729 739 //usage: "Unload kernel modules\n" 730 //usage: "\nOptions:"731 740 //usage: "\n -w Wait until the module is no longer used" 732 741 //usage: "\n -f Force unload" … … 739 748 //usage: "[-qfwrsv] MODULE [symbol=value]..." 740 749 //usage:#define modprobe_full_usage "\n\n" 741 //usage: "Options:" 742 //usage: "\n -r Remove MODULE (stacks) or do autoclean" 750 //usage: " -r Remove MODULE (stacks) or do autoclean" 743 751 //usage: "\n -q Quiet" 744 752 //usage: "\n -v Verbose" … … 809 817 /* only -q (quiet) and -r (rmmod), 810 818 * the rest are accepted and ignored (compat) */ 811 getopt32(argv, "qrfsvw ");819 getopt32(argv, "qrfsvwb"); 812 820 argv += optind; 813 821 -
branches/3.2/mindi-busybox/modutils/modprobe.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_MODPROBE(APPLET(modprobe, _BB_DIR_SBIN, _BB_SUID_DROP)) 11 //applet:IF_MODPROBE(APPLET(modprobe, BB_DIR_SBIN, BB_SUID_DROP)) 12 13 #include "libbb.h" 14 #include "modutils.h" 15 #include <sys/utsname.h> 16 #include <fnmatch.h> 17 18 //#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__) 19 #define DBG(...) ((void)0) 20 21 /* Note that unlike older versions of modules.dep/depmod (busybox and m-i-t), 22 * we expect the full dependency list to be specified in modules.dep. 23 * Older versions would only export the direct dependency list. 24 */ 25 12 26 13 27 //usage:#if !ENABLE_MODPROBE_SMALL … … 73 87 //usage: 74 88 //usage:#define modprobe_trivial_usage 75 //usage: "[-alrqvs" 76 //usage: IF_FEATURE_MODPROBE_BLACKLIST("b") 77 //usage: "] MODULE [symbol=value]..." 89 //usage: "[-alrqvsD" IF_FEATURE_MODPROBE_BLACKLIST("b") "]" 90 //usage: " MODULE [symbol=value]..." 78 91 //usage:#define modprobe_full_usage "\n\n" 79 //usage: "Options:" 80 //usage: "\n -a Load multiple MODULEs" 92 //usage: " -a Load multiple MODULEs" 81 93 //usage: "\n -l List (MODULE is a pattern)" 82 94 //usage: "\n -r Remove MODULE (stacks) or do autoclean" … … 84 96 //usage: "\n -v Verbose" 85 97 //usage: "\n -s Log to syslog" 98 //usage: "\n -D Show dependencies" 86 99 //usage: IF_FEATURE_MODPROBE_BLACKLIST( 87 100 //usage: "\n -b Apply blacklist to module names too" … … 89 102 //usage:#endif /* !ENABLE_MODPROBE_SMALL */ 90 103 91 #include "libbb.h" 92 #include "modutils.h" 93 #include <sys/utsname.h> 94 #include <fnmatch.h> 95 96 //#define DBG(fmt, ...) bb_error_msg("%s: " fmt, __func__, ## __VA_ARGS__) 97 #define DBG(...) ((void)0) 98 99 /* Note that unlike older versions of modules.dep/depmod (busybox and m-i-t), 100 * we expect the full dependency list to be specified in modules.dep. 101 * Older versions would only export the direct dependency list. 104 /* Note: usage text doesn't document various 2.4 options 105 * we pull in through INSMOD_OPTS define 106 * Note2: -b is always accepted, but if !FEATURE_MODPROBE_BLACKLIST, 107 * it is a no-op. 102 108 */ 103 104 /* Note that usage text doesn't document various 2.4 options 105 * we pull in through INSMOD_OPTS define */ 106 107 #define MODPROBE_COMPLEMENTARY "q-v:v-q:l--ar:a--lr:r--al" 108 #define MODPROBE_OPTS "alr" IF_FEATURE_MODPROBE_BLACKLIST("b") 109 #define MODPROBE_OPTS "alrDb" 110 /* -a and -D _are_ in fact compatible */ 111 #define MODPROBE_COMPLEMENTARY ("q-v:v-q:l--arD:r--alD:a--lr:D--rl") 112 //#define MODPROBE_OPTS "acd:lnrt:C:b" 109 113 //#define MODPROBE_COMPLEMENTARY "q-v:v-q:l--acr:a--lr:r--al" 110 //#define MODPROBE_OPTS "acd:lnrt:C:" IF_FEATURE_MODPROBE_BLACKLIST("b")111 114 enum { 112 MODPROBE_OPT_INSERT_ALL = (INSMOD_OPT_UNUSED << 0), /* a */ 113 //MODPROBE_OPT_DUMP_ONLY= (INSMOD_OPT_UNUSED << x), /* c */ 114 //MODPROBE_OPT_DIRNAME = (INSMOD_OPT_UNUSED << x), /* d */ 115 MODPROBE_OPT_LIST_ONLY = (INSMOD_OPT_UNUSED << 1), /* l */ 116 //MODPROBE_OPT_SHOW_ONLY= (INSMOD_OPT_UNUSED << x), /* n */ 117 MODPROBE_OPT_REMOVE = (INSMOD_OPT_UNUSED << 2), /* r */ 118 //MODPROBE_OPT_RESTRICT = (INSMOD_OPT_UNUSED << x), /* t */ 119 //MODPROBE_OPT_VERONLY = (INSMOD_OPT_UNUSED << x), /* V */ 120 //MODPROBE_OPT_CONFIGFILE=(INSMOD_OPT_UNUSED << x), /* C */ 121 MODPROBE_OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 3) * ENABLE_FEATURE_MODPROBE_BLACKLIST, 115 OPT_INSERT_ALL = (INSMOD_OPT_UNUSED << 0), /* a */ 116 //OPT_DUMP_ONLY = (INSMOD_OPT_UNUSED << x), /* c */ 117 //OPT_DIRNAME = (INSMOD_OPT_UNUSED << x), /* d */ 118 OPT_LIST_ONLY = (INSMOD_OPT_UNUSED << 1), /* l */ 119 //OPT_SHOW_ONLY = (INSMOD_OPT_UNUSED << x), /* n */ 120 OPT_REMOVE = (INSMOD_OPT_UNUSED << 2), /* r */ 121 //OPT_RESTRICT = (INSMOD_OPT_UNUSED << x), /* t */ 122 //OPT_VERONLY = (INSMOD_OPT_UNUSED << x), /* V */ 123 //OPT_CONFIGFILE = (INSMOD_OPT_UNUSED << x), /* C */ 124 OPT_SHOW_DEPS = (INSMOD_OPT_UNUSED << 3), /* D */ 125 OPT_BLACKLIST = (INSMOD_OPT_UNUSED << 4) * ENABLE_FEATURE_MODPROBE_BLACKLIST, 122 126 }; 127 #if ENABLE_LONG_OPTS 128 static const char modprobe_longopts[] ALIGN1 = 129 /* nobody asked for long opts (yet) */ 130 // "all\0" No_argument "a" 131 // "list\0" No_argument "l" 132 // "remove\0" No_argument "r" 133 // "quiet\0" No_argument "q" 134 // "verbose\0" No_argument "v" 135 // "syslog\0" No_argument "s" 136 /* module-init-tools 3.11.1 has only long opt --show-depends 137 * but no short -D, we provide long opt for scripts which 138 * were written for 3.11.1: */ 139 "show-depends\0" No_argument "D" 140 // "use-blacklist\0" No_argument "b" 141 ; 142 #endif 123 143 124 144 #define MODULE_FLAG_LOADED 0x0001 … … 139 159 }; 140 160 161 #define DB_HASH_SIZE 256 162 141 163 struct globals { 142 llist_t *db; /* MEs of all modules ever seen (caching for speed) */143 164 llist_t *probes; /* MEs of module(s) requested on cmdline */ 144 165 char *cmdline_mopts; /* module options from cmdline */ … … 146 167 /* bool. "Did we have 'symbol:FOO' requested on cmdline?" */ 147 168 smallint need_symbols; 169 struct utsname uts; 170 llist_t *db[DB_HASH_SIZE]; /* MEs of all modules ever seen (caching for speed) */ 148 171 } FIX_ALIASING; 149 #define G (*(struct globals*)&bb_common_bufsiz1) 150 #define INIT_G() do { } while (0) 172 #define G (*ptr_to_globals) 173 #define INIT_G() do { \ 174 SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); \ 175 } while (0) 151 176 152 177 … … 168 193 } 169 194 195 /* These three functions called many times, optimizing for speed. 196 * Users reported minute-long delays when they runn iptables repeatedly 197 * (iptables use modprobe to install needed kernel modules). 198 */ 170 199 static struct module_entry *helper_get_module(const char *module, int create) 171 200 { … … 173 202 struct module_entry *e; 174 203 llist_t *l; 204 unsigned i; 205 unsigned hash; 175 206 176 207 filename2modname(module, modname); 177 for (l = G.db; l != NULL; l = l->link) { 208 209 hash = 0; 210 for (i = 0; modname[i]; i++) 211 hash = ((hash << 5) + hash) + modname[i]; 212 hash %= DB_HASH_SIZE; 213 214 for (l = G.db[hash]; l; l = l->link) { 178 215 e = (struct module_entry *) l->data; 179 216 if (strcmp(e->modname, modname) == 0) … … 185 222 e = xzalloc(sizeof(*e)); 186 223 e->modname = xstrdup(modname); 187 llist_add_to(&G.db , e);224 llist_add_to(&G.db[hash], e); 188 225 189 226 return e; 190 227 } 191 static struct module_entry *get_or_add_modentry(const char *module)228 static ALWAYS_INLINE struct module_entry *get_or_add_modentry(const char *module) 192 229 { 193 230 return helper_get_module(module, 1); 194 231 } 195 static struct module_entry *get_modentry(const char *module)232 static ALWAYS_INLINE struct module_entry *get_modentry(const char *module) 196 233 { 197 234 return helper_get_module(module, 0); … … 203 240 204 241 m = get_or_add_modentry(name); 205 if (!(option_mask32 & MODPROBE_OPT_REMOVE)242 if (!(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS)) 206 243 && (m->flags & MODULE_FLAG_LOADED) 207 244 ) { … … 253 290 filename2modname(tokens[1], wildcard); 254 291 255 for (l = G.probes; l != NULL; l = l->link) {292 for (l = G.probes; l; l = l->link) { 256 293 m = (struct module_entry *) l->data; 257 294 if (fnmatch(wildcard, m->modname, 0) != 0) … … 354 391 static int do_modprobe(struct module_entry *m) 355 392 { 356 struct module_entry *m2 = m2; /* for compiler */357 char *fn, *options;358 393 int rc, first; 359 llist_t *l;360 394 361 395 if (!(m->flags & MODULE_FLAG_FOUND_IN_MODDEP)) { … … 367 401 DBG("do_modprob'ing %s", m->modname); 368 402 369 if (!(option_mask32 & MODPROBE_OPT_REMOVE))403 if (!(option_mask32 & OPT_REMOVE)) 370 404 m->deps = llist_rev(m->deps); 371 405 372 for (l = m->deps; l != NULL; l = l->link) 373 DBG("dep: %s", l->data); 406 if (0) { 407 llist_t *l; 408 for (l = m->deps; l; l = l->link) 409 DBG("dep: %s", l->data); 410 } 374 411 375 412 first = 1; 376 413 rc = 0; 377 414 while (m->deps) { 415 struct module_entry *m2; 416 char *fn, *options; 417 378 418 rc = 0; 379 419 fn = llist_pop(&m->deps); /* we leak it */ 380 420 m2 = get_or_add_modentry(fn); 381 421 382 if (option_mask32 & MODPROBE_OPT_REMOVE) {422 if (option_mask32 & OPT_REMOVE) { 383 423 /* modprobe -r */ 384 424 if (m2->flags & MODULE_FLAG_LOADED) { … … 400 440 } 401 441 402 if (m2->flags & MODULE_FLAG_LOADED) {403 DBG("%s is already loaded, skipping", fn);404 continue;405 }406 407 442 options = m2->options; 408 443 m2->options = NULL; … … 410 445 if (m == m2) 411 446 options = gather_options_str(options, G.cmdline_mopts); 447 448 if (option_mask32 & OPT_SHOW_DEPS) { 449 printf(options ? "insmod %s/%s/%s %s\n" 450 : "insmod %s/%s/%s\n", 451 CONFIG_DEFAULT_MODULES_DIR, G.uts.release, fn, 452 options); 453 free(options); 454 continue; 455 } 456 457 if (m2->flags & MODULE_FLAG_LOADED) { 458 DBG("%s is already loaded, skipping", fn); 459 free(options); 460 continue; 461 } 462 412 463 rc = bb_init_module(fn, options); 413 464 DBG("loaded %s '%s', rc:%d", fn, options, rc); … … 457 508 /* Optimization... */ 458 509 if ((m->flags & MODULE_FLAG_LOADED) 459 && !(option_mask32 & MODPROBE_OPT_REMOVE)510 && !(option_mask32 & (OPT_REMOVE | OPT_SHOW_DEPS)) 460 511 ) { 461 512 DBG("skip deps of %s, it's already loaded", tokens[0]); … … 478 529 int modprobe_main(int argc UNUSED_PARAM, char **argv) 479 530 { 480 struct utsname uts;481 531 int rc; 482 532 unsigned opt; 483 533 struct module_entry *me; 484 534 535 INIT_G(); 536 537 IF_LONG_OPTS(applet_long_options = modprobe_longopts;) 485 538 opt_complementary = MODPROBE_COMPLEMENTARY; 486 539 opt = getopt32(argv, INSMOD_OPTS MODPROBE_OPTS INSMOD_ARGS); … … 489 542 /* Goto modules location */ 490 543 xchdir(CONFIG_DEFAULT_MODULES_DIR); 491 uname(&uts); 492 xchdir(uts.release); 493 494 if (opt & MODPROBE_OPT_LIST_ONLY) { 544 uname(&G.uts); 545 xchdir(G.uts.release); 546 547 if (opt & OPT_LIST_ONLY) { 548 int i; 495 549 char name[MODULE_NAME_LEN]; 496 550 char *colon, *tokens[2]; 497 551 parser_t *p = config_open2(CONFIG_DEFAULT_DEPMOD_FILE, xfopen_for_read); 552 553 for (i = 0; argv[i]; i++) 554 replace(argv[i], '-', '_'); 498 555 499 556 while (config_read(p, tokens, 2, 1, "# \t", PARSE_NORMAL)) { … … 506 563 puts(tokens[0]); 507 564 else { 508 int i;509 565 for (i = 0; argv[i]; i++) { 510 566 if (fnmatch(argv[i], name, 0) == 0) { … … 522 578 523 579 if (!argv[0]) { 524 if (opt & MODPROBE_OPT_REMOVE) {580 if (opt & OPT_REMOVE) { 525 581 /* "modprobe -r" (w/o params). 526 582 * "If name is NULL, all unused modules marked … … 542 598 } 543 599 544 if (opt & ( MODPROBE_OPT_INSERT_ALL | MODPROBE_OPT_REMOVE)) {600 if (opt & (OPT_INSERT_ALL | OPT_REMOVE)) { 545 601 /* Each argument is a module name */ 546 602 do { … … 552 608 DBG("probing just module %s", *argv); 553 609 add_probe(argv[0]); 554 G.cmdline_mopts = parse_cmdline_module_options(argv );610 G.cmdline_mopts = parse_cmdline_module_options(argv, /*quote_spaces:*/ 1); 555 611 } 556 612 … … 576 632 * only if '-b' is given. 577 633 */ 578 if (!(opt & MODPROBE_OPT_BLACKLIST)634 if (!(opt & OPT_BLACKLIST) 579 635 || !(me->flags & MODULE_FLAG_BLACKLISTED) 580 636 ) { … … 593 649 if (!(m2->flags & MODULE_FLAG_BLACKLISTED) 594 650 && (!(m2->flags & MODULE_FLAG_LOADED) 595 || (opt & MODPROBE_OPT_REMOVE))651 || (opt & (OPT_REMOVE | OPT_SHOW_DEPS))) 596 652 ) { 597 653 //TODO: we can pass "me" as 2nd param to do_modprobe, -
branches/3.2/mindi-busybox/modutils/modutils-24.c
r2859 r3232 61 61 #include "libbb.h" 62 62 #include "modutils.h" 63 #include <libgen.h>64 63 #include <sys/utsname.h> 65 64 … … 2445 2444 2446 2445 /* Number of parameters */ 2446 min = max = 1; 2447 2447 if (isdigit(*pinfo)) { 2448 min = strtoul(pinfo, &pinfo, 10);2448 min = max = strtoul(pinfo, &pinfo, 10); 2449 2449 if (*pinfo == '-') 2450 2450 max = strtoul(pinfo + 1, &pinfo, 10); 2451 else 2452 max = min; 2453 } else 2454 min = max = 1; 2451 } 2455 2452 2456 2453 contents = f->sections[sym->secidx]->contents; … … 2474 2471 n = 0; 2475 2472 p = val; 2476 while (*p != 0) {2473 while (*p) { 2477 2474 char sv_ch; 2478 2475 char *endp; … … 2485 2482 len = strcspn(p, ","); 2486 2483 sv_ch = p[len]; 2487 p[len] = 0;2484 p[len] = '\0'; 2488 2485 obj_string_patch(f, sym->secidx, 2489 2486 loc - contents, p); … … 2495 2492 len = strcspn(p, ","); 2496 2493 sv_ch = p[len]; 2497 p[len] = 0;2494 p[len] = '\0'; 2498 2495 if (len >= charssize) 2499 2496 bb_error_msg_and_die("string too long for %s (max %ld)", param, -
branches/3.2/mindi-busybox/modutils/modutils.c
r2725 r3232 63 63 } 64 64 65 char* FAST_FUNC parse_cmdline_module_options(char **argv )65 char* FAST_FUNC parse_cmdline_module_options(char **argv, int quote_spaces) 66 66 { 67 67 char *options; … … 71 71 optlen = 0; 72 72 while (*++argv) { 73 options = xrealloc(options, optlen + 2 + strlen(*argv) + 2); 74 /* Spaces handled by "" pairs, but no way of escaping quotes */ 75 //TODO: module-init-tools version 3.11.1 quotes only value: 76 //it generates var="val with spaces", not "var=val with spaces" 77 //(and it won't quote var *name* even if it has spaces) 78 optlen += sprintf(options + optlen, (strchr(*argv, ' ') ? "\"%s\" " : "%s "), *argv); 79 } 73 const char *fmt; 74 const char *var; 75 const char *val; 76 77 var = *argv; 78 options = xrealloc(options, optlen + 2 + strlen(var) + 2); 79 fmt = "%.*s%s "; 80 val = strchrnul(var, '='); 81 if (quote_spaces) { 82 /* 83 * modprobe (module-init-tools version 3.11.1) compat: 84 * quote only value: 85 * var="val with spaces", not "var=val with spaces" 86 * (note: var *name* is not checked for spaces!) 87 */ 88 if (*val) { /* has var=val format. skip '=' */ 89 val++; 90 if (strchr(val, ' ')) 91 fmt = "%.*s\"%s\" "; 92 } 93 } 94 optlen += sprintf(options + optlen, fmt, (int)(val - var), var, val); 95 } 96 /* Remove trailing space. Disabled */ 97 /* if (optlen != 0) options[optlen-1] = '\0'; */ 80 98 return options; 81 99 } -
branches/3.2/mindi-busybox/modutils/modutils.h
r2725 r3232 22 22 int string_to_llist(char *string, llist_t **llist, const char *delim) FAST_FUNC; 23 23 char *filename2modname(const char *filename, char *modname) FAST_FUNC; 24 char *parse_cmdline_module_options(char **argv ) FAST_FUNC;24 char *parse_cmdline_module_options(char **argv, int quote_spaces) FAST_FUNC; 25 25 26 26 /* insmod for 2.4 and modprobe's options (insmod 2.6 has no options at all): */ -
branches/3.2/mindi-busybox/modutils/rmmod.c
r2725 r3232 9 9 */ 10 10 11 //applet:IF_RMMOD(APPLET(rmmod, _BB_DIR_SBIN, _BB_SUID_DROP))11 //applet:IF_RMMOD(APPLET(rmmod, BB_DIR_SBIN, BB_SUID_DROP)) 12 12 13 13 //usage:#if !ENABLE_MODPROBE_SMALL … … 16 16 //usage:#define rmmod_full_usage "\n\n" 17 17 //usage: "Unload kernel modules\n" 18 //usage: "\nOptions:"19 18 //usage: "\n -w Wait until the module is no longer used" 20 19 //usage: "\n -f Force unload" … … 62 61 if (bb_delete_module(modname, flags)) 63 62 bb_error_msg_and_die("can't unload '%s': %s", 64 63 modname, moderror(errno)); 65 64 } 66 65
Note:
See TracChangeset
for help on using the changeset viewer.