config->blacklists = kmod_list_remove(l);
}
+static void kcmdline_parse_result(struct kmod_config *config, char *modname,
+ char *param, char *value)
+{
+ if (modname == NULL || param == NULL || value == NULL)
+ return;
+
+ DBG(config->ctx, "%s %s\n", modname, param);
+
+ if (streq(modname, "modprobe") && !strncmp(param, "blacklist=", 10)) {
+ for (;;) {
+ char *t = strsep(&value, ",");
+ if (t == NULL)
+ break;
+
+ kmod_config_add_blacklist(config, t);
+ }
+ } else {
+ kmod_config_add_options(config,
+ underscores(config->ctx, modname), param);
+ }
+}
+
+static int kmod_config_parse_kcmdline(struct kmod_config *config)
+{
+ char buf[KCMD_LINE_SIZE];
+ int fd, err;
+ char *p, *modname, *param = NULL, *value = NULL;
+
+ fd = open("/proc/cmdline", O_RDONLY);
+ err = read_str_safe(fd, buf, sizeof(buf));
+ close(fd);
+ if (err < 0) {
+ ERR(config->ctx, "could not read from '/proc/cmdline': %s\n",
+ strerror(-err));
+ return err;
+ }
+
+ for (p = buf, modname = buf; *p != '\0' && *p != '\n'; p++) {
+ switch (*p) {
+ case ' ':
+ *p = '\0';
+ kcmdline_parse_result(config, modname, param, value);
+ param = value = NULL;
+ modname = p + 1;
+ break;
+ case '.':
+ *p = '\0';
+ param = p + 1;
+ break;
+ case '=':
+ value = p + 1;
+ break;
+ }
+ }
+
+ *p = '\0';
+ kcmdline_parse_result(config, modname, param, value);
+
+ return 0;
+}
+
/*
* Take an fd and own it. It will be closed on return. filename is used only
* for debug messages
closedir(d);
}
+ kmod_config_parse_kcmdline(config);
+
return 0;
}
#define KMOD_EXPORT __attribute__ ((visibility("default")))
+#define KCMD_LINE_SIZE 4096
+
void kmod_log(const struct kmod_ctx *ctx,
int priority, const char *file, int line, const char *fn,
const char *format, ...) __attribute__((format(printf, 6, 7))) __attribute__((nonnull(1, 3, 5)));