diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-18 14:39:43 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-05-18 14:39:43 +0000 |
| commit | 9ddc8d54d18f33774dc9db80a26f82bbaff5747d (patch) | |
| tree | 28b640cfae5c704a771cf26d84281c4ca5bd371a /modutils | |
| parent | b6c4855f1db16af926a0616cf91e0f65b0e2a3c6 (diff) | |
| download | busybox-w32-9ddc8d54d18f33774dc9db80a26f82bbaff5747d.tar.gz busybox-w32-9ddc8d54d18f33774dc9db80a26f82bbaff5747d.tar.bz2 busybox-w32-9ddc8d54d18f33774dc9db80a26f82bbaff5747d.zip | |
modprobe: optional "blacklist" command support (by Natanael Copa)
is_conf_command - 56 +56
include_conf 898 917 +19
check_dep 348 356 +8
------------------------------------------------------------------------------
(add/remove: 1/0 grow/shrink: 2/0 up/down: 83/0) Total: 83 bytes
Diffstat (limited to 'modutils')
| -rw-r--r-- | modutils/Config.in | 12 | ||||
| -rw-r--r-- | modutils/modprobe.c | 31 |
2 files changed, 38 insertions, 5 deletions
diff --git a/modutils/Config.in b/modutils/Config.in index b2ef51a05..c5e596d1d 100644 --- a/modutils/Config.in +++ b/modutils/Config.in | |||
| @@ -117,6 +117,18 @@ config FEATURE_MODPROBE_FANCY_ALIAS | |||
| 117 | mismatch between module name and file name, along with bus-specific | 117 | mismatch between module name and file name, along with bus-specific |
| 118 | aliases (such as pci:... or usb:... aliases). | 118 | aliases (such as pci:... or usb:... aliases). |
| 119 | 119 | ||
| 120 | config FEATURE_MODPROBE_BLACKLIST | ||
| 121 | bool | ||
| 122 | prompt "Blacklist support" | ||
| 123 | default n | ||
| 124 | depends on MODPROBE && FEATURE_2_6_MODULES | ||
| 125 | help | ||
| 126 | Say 'y' here to enable support for the 'blacklist' command in | ||
| 127 | modprobe.conf. This prevents the alias resolver to resolve | ||
| 128 | blacklisted modules. This is useful if you want to prevent your | ||
| 129 | hardware autodetection scripts to load modules like evdev, frame | ||
| 130 | buffer drivers etc. | ||
| 131 | |||
| 120 | comment "Options common to multiple modutils" | 132 | comment "Options common to multiple modutils" |
| 121 | depends on INSMOD || RMMOD || MODPROBE || LSMOD | 133 | depends on INSMOD || RMMOD || MODPROBE || LSMOD |
| 122 | 134 | ||
diff --git a/modutils/modprobe.c b/modutils/modprobe.c index f6681a8d8..60dc92665 100644 --- a/modutils/modprobe.c +++ b/modutils/modprobe.c | |||
| @@ -29,7 +29,8 @@ struct dep_t { /* one-way list of dependency rules */ | |||
| 29 | struct mod_opt_t * m_options; /* the module options */ | 29 | struct mod_opt_t * m_options; /* the module options */ |
| 30 | 30 | ||
| 31 | int m_isalias : 1; /* the module is an alias */ | 31 | int m_isalias : 1; /* the module is an alias */ |
| 32 | int m_reserved : 15; /* stuffin' */ | 32 | int m_isblacklisted : 1; |
| 33 | int m_reserved : 14; /* stuffin' */ | ||
| 33 | 34 | ||
| 34 | int m_depcnt : 16; /* the number of dependable module(s) */ | 35 | int m_depcnt : 16; /* the number of dependable module(s) */ |
| 35 | char ** m_deparr; /* the list of dependable module(s) */ | 36 | char ** m_deparr; /* the list of dependable module(s) */ |
| @@ -230,6 +231,13 @@ static char *parse_command_string(char *src, char **dst) | |||
| 230 | #define parse_command_string(src, dst) (0) | 231 | #define parse_command_string(src, dst) (0) |
| 231 | #endif /* ENABLE_FEATURE_MODPROBE_MULTIPLE_OPTIONS */ | 232 | #endif /* ENABLE_FEATURE_MODPROBE_MULTIPLE_OPTIONS */ |
| 232 | 233 | ||
| 234 | static int is_conf_command(char *buffer, const char *command) | ||
| 235 | { | ||
| 236 | int len = strlen(command); | ||
| 237 | return ((strstr(buffer, command) == buffer) && | ||
| 238 | isspace(buffer[len])); | ||
| 239 | } | ||
| 240 | |||
| 233 | /* | 241 | /* |
| 234 | * This function reads aliases and default module options from a configuration file | 242 | * This function reads aliases and default module options from a configuration file |
| 235 | * (/etc/modprobe.conf syntax). It supports includes (only files, no directories). | 243 | * (/etc/modprobe.conf syntax). It supports includes (only files, no directories). |
| @@ -260,7 +268,7 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf | |||
| 260 | if (continuation_line) | 268 | if (continuation_line) |
| 261 | continue; | 269 | continue; |
| 262 | 270 | ||
| 263 | if ((strncmp(buffer, "alias", 5) == 0) && isspace(buffer[5])) { | 271 | if (is_conf_command(buffer, "alias")) { |
| 264 | char *alias, *mod; | 272 | char *alias, *mod; |
| 265 | 273 | ||
| 266 | if (parse_tag_value(buffer + 6, &alias, &mod)) { | 274 | if (parse_tag_value(buffer + 6, &alias, &mod)) { |
| @@ -284,7 +292,7 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf | |||
| 284 | } | 292 | } |
| 285 | /*(*current)->m_next = NULL; - done by xzalloc */ | 293 | /*(*current)->m_next = NULL; - done by xzalloc */ |
| 286 | } | 294 | } |
| 287 | } else if ((strncmp(buffer, "options", 7) == 0) && isspace(buffer[7])) { | 295 | } else if (is_conf_command(buffer, "options")) { |
| 288 | char *mod, *opt; | 296 | char *mod, *opt; |
| 289 | 297 | ||
| 290 | /* split the line in the module/alias name, and options */ | 298 | /* split the line in the module/alias name, and options */ |
| @@ -307,7 +315,7 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf | |||
| 307 | } | 315 | } |
| 308 | } | 316 | } |
| 309 | } | 317 | } |
| 310 | } else if ((strncmp(buffer, "include", 7) == 0) && isspace(buffer[7])) { | 318 | } else if (is_conf_command(buffer, "include")) { |
| 311 | int fdi; | 319 | int fdi; |
| 312 | char *filename; | 320 | char *filename; |
| 313 | 321 | ||
| @@ -317,6 +325,18 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf | |||
| 317 | include_conf(first, current, buffer, buflen, fdi); | 325 | include_conf(first, current, buffer, buflen, fdi); |
| 318 | close(fdi); | 326 | close(fdi); |
| 319 | } | 327 | } |
| 328 | } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST && | ||
| 329 | (is_conf_command(buffer, "blacklist"))) { | ||
| 330 | char *mod; | ||
| 331 | struct dep_t *dt; | ||
| 332 | |||
| 333 | mod = skip_whitespace(buffer + 10); | ||
| 334 | for (dt = *first; dt; dt = dt->m_next) { | ||
| 335 | if (dt->m_isalias && strcmp(dt->m_deparr[0], mod) == 0) | ||
| 336 | break; | ||
| 337 | } | ||
| 338 | if (dt) | ||
| 339 | dt->m_isblacklisted = 1; | ||
| 320 | } | 340 | } |
| 321 | } /* while (reads(...)) */ | 341 | } /* while (reads(...)) */ |
| 322 | } | 342 | } |
| @@ -728,7 +748,8 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t | |||
| 728 | 748 | ||
| 729 | // resolve alias names | 749 | // resolve alias names |
| 730 | while (dt->m_isalias) { | 750 | while (dt->m_isalias) { |
| 731 | if (dt->m_depcnt == 1) { | 751 | if (dt->m_depcnt == 1 && !(ENABLE_FEATURE_MODPROBE_BLACKLIST && |
| 752 | dt->m_isblacklisted)) { | ||
| 732 | struct dep_t *adt; | 753 | struct dep_t *adt; |
| 733 | 754 | ||
| 734 | for (adt = depend; adt; adt = adt->m_next) { | 755 | for (adt = depend; adt; adt = adt->m_next) { |
