summaryrefslogtreecommitdiff
path: root/modutils/modprobe.c
diff options
context:
space:
mode:
authorDenis Vlasenko2008-05-18 14:39:43 +0000
committerDenis Vlasenko2008-05-18 14:39:43 +0000
commit9ddc8d54d18f33774dc9db80a26f82bbaff5747d (patch)
tree28b640cfae5c704a771cf26d84281c4ca5bd371a /modutils/modprobe.c
parentb6c4855f1db16af926a0616cf91e0f65b0e2a3c6 (diff)
downloadbusybox-9ddc8d54d18f33774dc9db80a26f82bbaff5747d.zip
busybox-9ddc8d54d18f33774dc9db80a26f82bbaff5747d.tar.gz
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/modprobe.c')
-rw-r--r--modutils/modprobe.c31
1 files changed, 26 insertions, 5 deletions
diff --git a/modutils/modprobe.c b/modutils/modprobe.c
index f6681a8..60dc926 100644
--- a/modutils/modprobe.c
+++ b/modutils/modprobe.c
@@ -29,7 +29,8 @@ struct dep_t { /* one-way list of dependency rules */
struct mod_opt_t * m_options; /* the module options */
int m_isalias : 1; /* the module is an alias */
- int m_reserved : 15; /* stuffin' */
+ int m_isblacklisted : 1;
+ int m_reserved : 14; /* stuffin' */
int m_depcnt : 16; /* the number of dependable module(s) */
char ** m_deparr; /* the list of dependable module(s) */
@@ -230,6 +231,13 @@ static char *parse_command_string(char *src, char **dst)
#define parse_command_string(src, dst) (0)
#endif /* ENABLE_FEATURE_MODPROBE_MULTIPLE_OPTIONS */
+static int is_conf_command(char *buffer, const char *command)
+{
+ int len = strlen(command);
+ return ((strstr(buffer, command) == buffer) &&
+ isspace(buffer[len]));
+}
+
/*
* This function reads aliases and default module options from a configuration file
* (/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
if (continuation_line)
continue;
- if ((strncmp(buffer, "alias", 5) == 0) && isspace(buffer[5])) {
+ if (is_conf_command(buffer, "alias")) {
char *alias, *mod;
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
}
/*(*current)->m_next = NULL; - done by xzalloc */
}
- } else if ((strncmp(buffer, "options", 7) == 0) && isspace(buffer[7])) {
+ } else if (is_conf_command(buffer, "options")) {
char *mod, *opt;
/* 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
}
}
}
- } else if ((strncmp(buffer, "include", 7) == 0) && isspace(buffer[7])) {
+ } else if (is_conf_command(buffer, "include")) {
int fdi;
char *filename;
@@ -317,6 +325,18 @@ static void include_conf(struct dep_t **first, struct dep_t **current, char *buf
include_conf(first, current, buffer, buflen, fdi);
close(fdi);
}
+ } else if (ENABLE_FEATURE_MODPROBE_BLACKLIST &&
+ (is_conf_command(buffer, "blacklist"))) {
+ char *mod;
+ struct dep_t *dt;
+
+ mod = skip_whitespace(buffer + 10);
+ for (dt = *first; dt; dt = dt->m_next) {
+ if (dt->m_isalias && strcmp(dt->m_deparr[0], mod) == 0)
+ break;
+ }
+ if (dt)
+ dt->m_isblacklisted = 1;
}
} /* while (reads(...)) */
}
@@ -728,7 +748,8 @@ static void check_dep(char *mod, struct mod_list_t **head, struct mod_list_t **t
// resolve alias names
while (dt->m_isalias) {
- if (dt->m_depcnt == 1) {
+ if (dt->m_depcnt == 1 && !(ENABLE_FEATURE_MODPROBE_BLACKLIST &&
+ dt->m_isblacklisted)) {
struct dep_t *adt;
for (adt = depend; adt; adt = adt->m_next) {