This allows overriding the default path "/lib/modules".  If used with '-d
basedir', the 'moduledir' setting is appended to 'basedir', the same way
"/lib/modules" would be appended.

Signed-off-by: Keegan McAllister <[email protected]>
---
 modprobe.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/modprobe.c b/modprobe.c
index cfc6f25..0823c8d 100644
--- a/modprobe.c
+++ b/modprobe.c
@@ -349,6 +349,7 @@ struct module_softdep
 
 struct modprobe_conf
 {
+       char *module_dir;
        struct module_options *options;
        struct module_command *commands;
        struct module_alias *aliases;
@@ -947,6 +948,14 @@ static int parse_config_file(const char *filename,
                                if (streq(tmp, "no"))
                                        use_binary_indexes = 0;
                        }
+               } else if (streq(cmd, "moduledir")) {
+                       char *module_dir = strsep_skipspace(&ptr, "\t ");
+                       if (!module_dir)
+                               goto syntax_error;
+                       /* FIXME: will leak a previously-set moduledir.
+                          Valgrind may complain. */
+                       conf->module_dir = module_dir;
+                       line = NULL; /* Don't free() this line. */
                } else {
 syntax_error:
                        grammar(cmd, filename, linenum);
@@ -1837,8 +1846,10 @@ int main(int argc, char *argv[])
        /* Read module options from kernel command line */
        parse_kcmdline(dump_config, &conf.options);
 
-       /* TODO: make MODULE_DIR configurable */
-       nofail_asprintf(&dirname, "%s%s/%s", basedir, MODULE_DIR, buf.release);
+       char *module_dir = conf.module_dir;
+       if (!module_dir)
+               module_dir = MODULE_DIR;
+       nofail_asprintf(&dirname, "%s%s/%s", basedir, module_dir, buf.release);
        
        if (dump_config) {
                char *aliasfilename, *symfilename;
-- 
1.7.2.3

--
To unsubscribe from this list: send the line "unsubscribe linux-modules" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to