50
50
#include "testing.h"
52
int use_binary_indexes = 1; /* default to enabled. */
52
static int use_binary_indexes = 1; /* default to enabled. */
54
54
/* Limit do_softdep/do_modprobe recursion.
55
55
* This is a simple way to handle dependency loops
56
56
* caused by poorly written softdep commands.
58
58
static int recursion_depth = 0;
59
const int MAX_RECURSION = 50; /* Arbitrary choice */
59
static const int MAX_RECURSION = 50; /* Arbitrary choice */
61
61
extern long init_module(void *, unsigned long, const char *);
62
62
extern long delete_module(const char *, unsigned int);
1047
static int parse_config_scan(const char *filename,
1048
struct modprobe_conf *conf,
1048
static int parse_config_scan(struct modprobe_conf *conf,
1056
struct list_head node;
1060
struct file_entry *fe, *fe_tmp;
1061
LIST_HEAD(files_list);
1055
dir = opendir(filename);
1058
struct list_head node;
1061
LIST_HEAD(files_list);
1062
struct file_entry *fe, *fe_tmp;
1065
/* sort files from directory into list */
1066
while ((i = readdir(dir)) != NULL) {
1069
if (i->d_name[0] == '.')
1071
if (!config_filter(i->d_name))
1074
len = strlen(i->d_name);
1076
(strcmp(&i->d_name[len-5], ".conf") != 0 &&
1077
strcmp(&i->d_name[len-6], ".alias") != 0))
1078
warn("All config files need .conf: %s/%s, "
1079
"it will be ignored in a future release.\n",
1080
filename, i->d_name);
1081
fe = malloc(sizeof(struct file_entry) + len + 1);
1084
strcpy(fe->name, i->d_name);
1085
list_for_each_entry(fe_tmp, &files_list, node)
1086
if (strcmp(fe_tmp->name, fe->name) >= 0)
1088
list_add_tail(&fe->node, &fe_tmp->node);
1092
/* parse list of files */
1093
list_for_each_entry_safe(fe, fe_tmp, &files_list, node) {
1096
nofail_asprintf(&cfgfile, "%s/%s", filename, fe->name);
1097
if (!parse_config_file(cfgfile, conf,
1098
dump_only, removing))
1099
warn("Failed to open config file "
1100
"%s: %s\n", fe->name, strerror(errno));
1102
list_del(&fe->node);
1108
if (parse_config_file(filename, conf, dump_only, removing))
1064
va_start(filelist, removing);
1066
while ((filename = va_arg(filelist, char*))) {
1067
dir = opendir(filename);
1071
/* sort files from directories into list, ignoring duplicates */
1072
while ((i = readdir(dir)) != NULL) {
1076
if (i->d_name[0] == '.')
1078
if (!config_filter(i->d_name))
1081
len = strlen(i->d_name);
1083
(strcmp(&i->d_name[len-5], ".conf") != 0 &&
1084
strcmp(&i->d_name[len-6], ".alias") != 0))
1085
warn("All config files need .conf: %s/%s, "
1086
"it will be ignored in a future release.\n",
1087
filename, i->d_name);
1088
fe = malloc(sizeof(struct file_entry));
1092
list_for_each_entry(fe_tmp, &files_list, node)
1093
if ((cmp = strcmp(fe_tmp->name, i->d_name)) >= 0)
1097
fe->name = malloc(len + 1);
1098
fe->path = malloc(strlen(filename) + 1);
1099
strcpy(fe->name, i->d_name);
1100
strcpy(fe->path, filename);
1103
list_add_tail(&fe->node, &files_list);
1105
list_add_tail(&fe->node, &fe_tmp->node);
1107
info("Ignoring config file %s/%s\n", filename, i->d_name);
1114
if (parse_config_file(filename, conf, dump_only, removing))
1119
/* parse list of files */
1120
list_for_each_entry_safe(fe, fe_tmp, &files_list, node) {
1123
nofail_asprintf(&cfgfile, "%s/%s", fe->path, fe->name);
1124
if (!parse_config_file(cfgfile, conf,
1125
dump_only, removing))
1126
warn("Failed to open config file %s: %s\n",
1127
cfgfile, strerror(errno));
1129
list_del(&fe->node);
1130
1156
"all config files belong into /etc/modprobe.d/.\n");
1132
1158
/* default config */
1133
parse_config_scan("/etc/modprobe.d", conf, dump_only, removing);
1159
parse_config_scan(conf, dump_only, removing, "/run/modprobe.d",
1160
"/etc/modprobe.d", "/usr/local/lib/modprobe.d",
1161
"/lib/modprobe.d", NULL);
1136
1164
/* Read possible module arguments from the kernel command line. */
1137
static int parse_kcmdline(int dump_only, struct module_options **options)
1165
static int parse_kcmdline(int dump_only, struct modprobe_conf *conf)
1140
1168
unsigned int linenum = 0;
1141
1169
FILE *kcmdline;
1170
struct module_options **options = &conf->options;
1171
struct module_blacklist **blacklist = &conf->blacklist;
1143
1173
kcmdline = fopen("/proc/cmdline", "r");
1673
static struct option options[] = { { "version", 0, NULL, 'V' },
1714
static const struct option options[] = { { "version", 0, NULL, 'V' },
1674
1715
{ "verbose", 0, NULL, 'v' },
1675
1716
{ "quiet", 0, NULL, 'q' },
1676
1717
{ "syslog", 0, NULL, 's' },