]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
depmod: deal with relative root dir
authorLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 14 Jan 2012 04:46:58 +0000 (02:46 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Sat, 14 Jan 2012 04:46:58 +0000 (02:46 -0200)
module paths coming from libkmod are absolute. Make sure we store the
absolute dirname to compare later.

tools/kmod-depmod.c

index b8071d490ee1c5a585ceff8fe327777c1ac8b117..0cf28f6da43533597643b866623114ca79cf8467 100644 (file)
@@ -2521,8 +2521,8 @@ static int do_depmod(int argc, char *argv[])
 {
        FILE *out = NULL;
        int err = 0, all = 0, maybe_all = 0, n_config_paths = 0;
+       char *root = NULL;
        const char **config_paths = NULL;
-       const char *root = "";
        const char *system_map = NULL;
        const char *module_symvers = NULL;
        const char *null_kmod_config = NULL;
@@ -2547,7 +2547,7 @@ static int do_depmod(int argc, char *argv[])
                        maybe_all = 1;
                        break;
                case 'b':
-                       root = optarg;
+                       root = path_make_absolute_cwd(optarg);
                        break;
                case 'C': {
                        size_t bytes = sizeof(char *) * (n_config_paths + 2);
@@ -2632,7 +2632,7 @@ static int do_depmod(int argc, char *argv[])
 
        cfg.dirnamelen = snprintf(cfg.dirname, PATH_MAX,
                                  "%s" ROOTPREFIX "/lib/modules/%s",
-                                 root, cfg.kversion);
+                                 root == NULL ? "" : root, cfg.kversion);
 
        if (optind == argc)
                all = 1;
@@ -2750,6 +2750,7 @@ depmod_init_failed:
 cmdline_failed:
        cfg_free(&cfg);
        free(config_paths);
+       free(root);
        return EXIT_FAILURE;
 }