From 2514d503fb6853cd440532728cbf16f2ce55bda9 Mon Sep 17 00:00:00 2001 From: Peter Hurley Date: Sat, 18 Jun 2011 12:27:35 -0400 Subject: [PATCH] Added mechanism for per-kernel version module options Often module parameters change or are moved into a different module. For example, for kernel versions 2.6.39+, the bluetooth 'sco' protocol module code was moved into the 'bluetooth' module. The 'sco' module parameter, disable_esco, was moved into the 'bluetooth' module as well. Consequently, it is not possible to have an 'options bluetooth disable_esco=Y' in /etc/modprobe.d/*.conf files without causing a module load failure in pre-2.6.39 kernels. This patch adds a scan for *.conf files in the directory /etc/modprobe.d/`uname -r` Signed-off-by: Peter Hurley --- modprobe.c | 13 ++++++++++--- 1 files changed, 10 insertions(+), 3 deletions(-) diff --git a/modprobe.c b/modprobe.c index 5464f45..3e6e660 100644 --- a/modprobe.c +++ b/modprobe.c @@ -1409,8 +1409,11 @@ static int parse_config_scan(struct modprobe_conf *conf, static void parse_toplevel_config(const char *filename, struct modprobe_conf *conf, int dump_only, - int removing) + int removing, + struct utsname *buf) { + char *dirname; + if (filename) { if (!parse_config_scan(conf, dump_only, removing, filename, NULL)) @@ -1425,10 +1428,14 @@ static void parse_toplevel_config(const char *filename, warn("Deprecated config file /etc/modprobe.conf, " "all config files belong into /etc/modprobe.d/.\n"); + /* also scan in /etc/modprobe.d/`utsname -r` */ + nofail_asprintf(&dirname, "/etc/modprobe.d/%s", buf->release); + /* default config */ parse_config_scan(conf, dump_only, removing, "/run/modprobe.d", "/etc/modprobe.d", "/usr/local/lib/modprobe.d", - "/lib/modprobe.d", NULL); + "/lib/modprobe.d", dirname, NULL); + free(dirname); } /** @@ -2252,7 +2259,7 @@ int main(int argc, char *argv[]) } /* Read aliases, options etc. */ - parse_toplevel_config(configname, &conf, dump_config, flags & mit_remove); + parse_toplevel_config(configname, &conf, dump_config, flags & mit_remove, &buf); /* Read module options from kernel command line */ parse_kcmdline(dump_config, &conf); -- 1.7.4.1