From 1ffabe284d9f5a4ac055941d9817af71be1e5b54 Mon Sep 17 00:00:00 2001 From: Parabola Date: Wed, 15 Feb 2012 20:35:57 +0000 Subject: Wed Feb 15 20:35:56 UTC 2012 --- ...-partially-fix-parsing-of-alias-with-dots.patch | 34 ---- ...odule-used-shared-code-in-module-creation.patch | 196 --------------------- ...handle-all-error-returns-from-init_module.patch | 34 ---- .../kmod/0004-modprobe-remove-0-refcnt-deps.patch | 52 ------ .../0005-continue-after-module-insert-fail.patch | 25 --- ...obe-remove-support-for-path-based-loading.patch | 79 --------- ...7-modinfo-handle-arguments-more-carefully.patch | 86 --------- ...e-realpath-to-canonicalize-provided-paths.patch | 163 ----------------- 8 files changed, 669 deletions(-) delete mode 100644 testing/kmod/0001-partially-fix-parsing-of-alias-with-dots.patch delete mode 100644 testing/kmod/0002-libkmod-module-used-shared-code-in-module-creation.patch delete mode 100644 testing/kmod/0003-modprobe-handle-all-error-returns-from-init_module.patch delete mode 100644 testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch delete mode 100644 testing/kmod/0005-continue-after-module-insert-fail.patch delete mode 100644 testing/kmod/0006-modprobe-remove-support-for-path-based-loading.patch delete mode 100644 testing/kmod/0007-modinfo-handle-arguments-more-carefully.patch delete mode 100644 testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch (limited to 'testing/kmod') diff --git a/testing/kmod/0001-partially-fix-parsing-of-alias-with-dots.patch b/testing/kmod/0001-partially-fix-parsing-of-alias-with-dots.patch deleted file mode 100644 index 73ed7801b..000000000 --- a/testing/kmod/0001-partially-fix-parsing-of-alias-with-dots.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 7b67a2c080e77acef0344d5a7518c07dbac830f1 Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Tue, 31 Jan 2012 00:12:32 -0500 -Subject: [PATCH 1/8] partially fix parsing of alias with dots - ---- - libkmod/libkmod-util.c | 4 +--- - 1 files changed, 1 insertions(+), 3 deletions(-) - -diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c -index 7c2611b..6a9f697 100644 ---- a/libkmod/libkmod-util.c -+++ b/libkmod/libkmod-util.c -@@ -134,8 +134,7 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) - case ']': - return -EINVAL; - case '[': -- while (alias[s] != ']' && -- alias[s] != '.' && alias[s] != '\0') -+ while (alias[s] != ']' && alias[s] != '\0') - s++; - - if (alias[s] != ']') -@@ -144,7 +143,6 @@ inline int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) - s++; - break; - case '\0': -- case '.': - goto finish; - default: - buf[s] = c; --- -1.7.9 - diff --git a/testing/kmod/0002-libkmod-module-used-shared-code-in-module-creation.patch b/testing/kmod/0002-libkmod-module-used-shared-code-in-module-creation.patch deleted file mode 100644 index 7019e5132..000000000 --- a/testing/kmod/0002-libkmod-module-used-shared-code-in-module-creation.patch +++ /dev/null @@ -1,196 +0,0 @@ -From 133132b6129f86c1f0aabdf3e807f56ea0190f8a Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Tue, 31 Jan 2012 00:13:43 -0500 -Subject: [PATCH 2/8] libkmod-module: used shared code in module creation - ---- - libkmod/libkmod-module.c | 135 ++++++++++++++++++++++++++------------------- - 1 files changed, 78 insertions(+), 57 deletions(-) - -diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c -index 47b1709..48e4aa1 100644 ---- a/libkmod/libkmod-module.c -+++ b/libkmod/libkmod-module.c -@@ -162,6 +162,76 @@ fail: - return err; - } - -+/* -+ * Memory layout with alias: -+ * -+ * struct kmod_module { -+ * hashkey -----. -+ * alias -----. | -+ * name ----. | | -+ * } | | | -+ * name <----------' | | -+ * alias <-----------' | -+ * name\alias <--------' -+ * -+ * Memory layout without alias: -+ * -+ * struct kmod_module { -+ * hashkey ---. -+ * alias -----|----> NULL -+ * name ----. | -+ * } | | -+ * name <----------'-' -+ * -+ * @key is "name\alias" or "name" (in which case alias == NULL) -+ */ -+static int kmod_module_new(struct kmod_ctx *ctx, const char *key, -+ const char *name, size_t namelen, -+ const char *alias, size_t aliaslen, -+ struct kmod_module **mod) -+{ -+ struct kmod_module *m; -+ size_t keylen; -+ -+ m = kmod_pool_get_module(ctx, key); -+ if (m != NULL) { -+ *mod = kmod_module_ref(m); -+ return 0; -+ } -+ -+ if (alias == NULL) -+ keylen = namelen; -+ else -+ keylen = namelen + aliaslen + 1; -+ -+ m = malloc(sizeof(*m) + (alias == NULL ? 1 : 2) * (keylen + 1)); -+ if (m == NULL) { -+ free(m); -+ return -ENOMEM; -+ } -+ -+ memset(m, 0, sizeof(*m)); -+ -+ m->ctx = kmod_ref(ctx); -+ m->name = (char *)m + sizeof(*m); -+ memcpy(m->name, key, keylen + 1); -+ if (alias == NULL) { -+ m->hashkey = m->name; -+ m->alias = NULL; -+ } else { -+ m->name[namelen] = '\0'; -+ m->alias = m->name + namelen + 1; -+ m->hashkey = m->name + keylen + 1; -+ memcpy(m->hashkey, key, keylen + 1); -+ } -+ -+ m->refcount = 1; -+ kmod_pool_add_module(ctx, m, m->hashkey); -+ *mod = m; -+ -+ return 0; -+} -+ - /** - * kmod_module_new_from_name: - * @ctx: kmod library context -@@ -188,54 +258,15 @@ KMOD_EXPORT int kmod_module_new_from_name(struct kmod_ctx *ctx, - const char *name, - struct kmod_module **mod) - { -- struct kmod_module *m; - size_t namelen; - char name_norm[PATH_MAX]; -- char *namesep; - - if (ctx == NULL || name == NULL || mod == NULL) - return -ENOENT; - -- if (alias_normalize(name, name_norm, &namelen) < 0) { -- DBG(ctx, "invalid alias: %s\n", name); -- return -EINVAL; -- } -+ modname_normalize(name, name_norm, &namelen); - -- m = kmod_pool_get_module(ctx, name_norm); -- if (m != NULL) { -- *mod = kmod_module_ref(m); -- return 0; -- } -- -- namesep = strchr(name_norm, '/'); -- m = malloc(sizeof(*m) + (namesep == NULL ? 1 : 2) * namelen + 2); -- if (m == NULL) { -- free(m); -- return -ENOMEM; -- } -- -- memset(m, 0, sizeof(*m)); -- -- m->ctx = kmod_ref(ctx); -- m->name = (char *)m + sizeof(*m); -- memcpy(m->name, name_norm, namelen + 1); -- -- if (namesep) { -- size_t len = namesep - name_norm; -- -- m->name[len] = '\0'; -- m->alias = m->name + len + 1; -- m->hashkey = m->name + namelen + 1; -- memcpy(m->hashkey, name_norm, namelen + 1); -- } else { -- m->hashkey = m->name; -- } -- -- m->refcount = 1; -- kmod_pool_add_module(ctx, m, m->hashkey); -- *mod = m; -- -- return 0; -+ return kmod_module_new(ctx, name_norm, name_norm, namelen, NULL, 0, mod); - } - - int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias, -@@ -251,9 +282,9 @@ int kmod_module_new_from_alias(struct kmod_ctx *ctx, const char *alias, - - memcpy(key, name, namelen); - memcpy(key + namelen + 1, alias, aliaslen + 1); -- key[namelen] = '/'; -+ key[namelen] = '\\'; - -- err = kmod_module_new_from_name(ctx, key, mod); -+ err = kmod_module_new(ctx, key, name, namelen, alias, aliaslen, mod); - if (err < 0) - return err; - -@@ -323,7 +354,7 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx, - free(abspath); - else { - ERR(ctx, "kmod_module '%s' already exists with different path: new-path='%s' old-path='%s'\n", -- name, abspath, m->path); -+ name, abspath, m->path); - free(abspath); - return -EEXIST; - } -@@ -332,21 +363,11 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx, - return 0; - } - -- m = malloc(sizeof(*m) + namelen + 1); -- if (m == NULL) -- return -errno; -- -- memset(m, 0, sizeof(*m)); -+ err = kmod_module_new(ctx, name, name, namelen, NULL, 0, &m); -+ if (err < 0) -+ return err; - -- m->ctx = kmod_ref(ctx); -- m->name = (char *)m + sizeof(*m); -- memcpy(m->name, name, namelen + 1); - m->path = abspath; -- m->hashkey = m->name; -- m->refcount = 1; -- -- kmod_pool_add_module(ctx, m, m->hashkey); -- - *mod = m; - - return 0; --- -1.7.9 - diff --git a/testing/kmod/0003-modprobe-handle-all-error-returns-from-init_module.patch b/testing/kmod/0003-modprobe-handle-all-error-returns-from-init_module.patch deleted file mode 100644 index f4754c5a7..000000000 --- a/testing/kmod/0003-modprobe-handle-all-error-returns-from-init_module.patch +++ /dev/null @@ -1,34 +0,0 @@ -From 2e42e3b3af219575dc855971f08d8bed226ebfa8 Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Mon, 30 Jan 2012 23:05:26 -0500 -Subject: [PATCH 3/8] modprobe: handle all error returns from init_module - ---- - tools/kmod-modprobe.c | 4 +++- - 1 files changed, 3 insertions(+), 1 deletions(-) - -diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c -index 3e51506..c882856 100644 ---- a/tools/kmod-modprobe.c -+++ b/tools/kmod-modprobe.c -@@ -551,6 +551,8 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts) - - err = kmod_module_insert_module(mod, flags, opts); - switch (err) { -+ case 0: -+ break; - case -EEXIST: - /* - * We checked for EEXIST with an earlier call to -@@ -564,7 +566,7 @@ static int insmod_do_insert_module(struct kmod_module *mod, const char *opts) - ERR("Module %s already in kernel.\n", - kmod_module_get_name(mod)); - break; -- case -EPERM: -+ default: - ERR("could not insert '%s': %s\n", kmod_module_get_name(mod), - strerror(-err)); - break; --- -1.7.9 - diff --git a/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch b/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch deleted file mode 100644 index a76b609b8..000000000 --- a/testing/kmod/0004-modprobe-remove-0-refcnt-deps.patch +++ /dev/null @@ -1,52 +0,0 @@ -From f169a0c3737b8ac69499240fca8314a2bd67a0a1 Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Mon, 30 Jan 2012 23:39:30 -0500 -Subject: [PATCH 4/8] modprobe: remove 0 refcnt deps - ---- - tools/kmod-modprobe.c | 15 +++++++++++++-- - 1 files changed, 13 insertions(+), 2 deletions(-) - -diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c -index c882856..bd991a5 100644 ---- a/tools/kmod-modprobe.c -+++ b/tools/kmod-modprobe.c -@@ -381,7 +381,7 @@ static int rmmod_do_deps_list(struct kmod_list *list, bool stop_on_errors) - static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies) - { - const char *modname = kmod_module_get_name(mod); -- struct kmod_list *pre = NULL, *post = NULL; -+ struct kmod_list *pre = NULL, *post = NULL, *deps, *itr; - const char *cmd = NULL; - int err; - -@@ -422,7 +422,7 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies) - rmmod_do_deps_list(post, false); - - if (do_dependencies && remove_dependencies) { -- struct kmod_list *deps = kmod_module_get_dependencies(mod); -+ deps = kmod_module_get_dependencies(mod); - - err = rmmod_do_deps_list(deps, true); - if (err < 0) -@@ -451,6 +451,17 @@ static int rmmod_do_module(struct kmod_module *mod, bool do_dependencies) - - rmmod_do_deps_list(pre, false); - -+ deps = kmod_module_get_dependencies(mod); -+ if (deps != NULL) { -+ kmod_list_foreach_reverse(itr, deps) { -+ struct kmod_module *dep = kmod_module_get_module(itr); -+ if (kmod_module_get_refcnt(dep) == 0) -+ rmmod_do_remove_module(dep); -+ kmod_module_unref(dep); -+ } -+ kmod_module_unref_list(deps); -+ } -+ - error: - kmod_module_unref_list(pre); - kmod_module_unref_list(post); --- -1.7.9 - diff --git a/testing/kmod/0005-continue-after-module-insert-fail.patch b/testing/kmod/0005-continue-after-module-insert-fail.patch deleted file mode 100644 index cdc0c87c5..000000000 --- a/testing/kmod/0005-continue-after-module-insert-fail.patch +++ /dev/null @@ -1,25 +0,0 @@ -From 1f386a0e357a8916713fe26acd96206be2159157 Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Wed, 1 Feb 2012 20:09:27 -0500 -Subject: [PATCH 5/8] continue after module insert fail - ---- - tools/kmod-modprobe.c | 2 -- - 1 files changed, 0 insertions(+), 2 deletions(-) - -diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c -index bd991a5..e70bf3d 100644 ---- a/tools/kmod-modprobe.c -+++ b/tools/kmod-modprobe.c -@@ -825,8 +825,6 @@ static int insmod_alias(struct kmod_ctx *ctx, const char *alias, - array_free_array(&recursion); - } - kmod_module_unref(mod); -- if (err < 0) -- break; - } - - kmod_module_unref_list(list); --- -1.7.9 - diff --git a/testing/kmod/0006-modprobe-remove-support-for-path-based-loading.patch b/testing/kmod/0006-modprobe-remove-support-for-path-based-loading.patch deleted file mode 100644 index b694413fb..000000000 --- a/testing/kmod/0006-modprobe-remove-support-for-path-based-loading.patch +++ /dev/null @@ -1,79 +0,0 @@ -From 658e2cafc2b88d1ab88f20b6183daabc113d3714 Mon Sep 17 00:00:00 2001 -From: Dave Reisner -Date: Sat, 4 Feb 2012 16:08:34 -0500 -Subject: [PATCH 6/8] modprobe: remove support for path based loading - -m-i-t doesn't support this, and it causes serious problems with local -files clashing with alias names. ---- - tools/kmod-modprobe.c | 35 ++--------------------------------- - 1 files changed, 2 insertions(+), 33 deletions(-) - -diff --git a/tools/kmod-modprobe.c b/tools/kmod-modprobe.c -index e70bf3d..b9943da 100644 ---- a/tools/kmod-modprobe.c -+++ b/tools/kmod-modprobe.c -@@ -737,27 +737,6 @@ error: - return err; - } - --static int insmod_path(struct kmod_ctx *ctx, const char *path, -- const char *extra_options) --{ -- struct kmod_module *mod; -- struct array recursion; -- int err; -- -- err = kmod_module_new_from_path(ctx, path, &mod); -- if (err < 0) { -- LOG("Module %s not found.\n", path); -- return err; -- } -- -- array_init(&recursion, INSMOD_RECURSION_STEP); -- err = insmod_do_module(mod, extra_options, true, &recursion); -- kmod_module_unref(mod); -- array_free_array(&recursion); -- -- return err; --} -- - static int handle_failed_lookup(struct kmod_ctx *ctx, const char *alias) - { - struct kmod_module *mod; -@@ -831,22 +810,12 @@ static int insmod_alias(struct kmod_ctx *ctx, const char *alias, - return err; - } - --static int insmod(struct kmod_ctx *ctx, const char *name, -- const char *extra_options) --{ -- struct stat st; -- if (stat(name, &st) == 0) -- return insmod_path(ctx, name, extra_options); -- else -- return insmod_alias(ctx, name, extra_options); --} -- - static int insmod_all(struct kmod_ctx *ctx, char **args, int nargs) - { - int i, err = 0; - - for (i = 0; i < nargs; i++) { -- int r = insmod(ctx, args[i], NULL); -+ int r = insmod_alias(ctx, args[i], NULL); - if (r < 0) - err = r; - } -@@ -1232,7 +1201,7 @@ static int do_modprobe(int argc, char **orig_argv) - char *opts; - err = options_from_array(args, nargs, &opts); - if (err == 0) { -- err = insmod(ctx, args[0], opts); -+ err = insmod_alias(ctx, args[0], opts); - free(opts); - } - } --- -1.7.9 - diff --git a/testing/kmod/0007-modinfo-handle-arguments-more-carefully.patch b/testing/kmod/0007-modinfo-handle-arguments-more-carefully.patch deleted file mode 100644 index 389008414..000000000 --- a/testing/kmod/0007-modinfo-handle-arguments-more-carefully.patch +++ /dev/null @@ -1,86 +0,0 @@ -From 2b77a48833818feb8cf35ffac3adcba8de503aec Mon Sep 17 00:00:00 2001 -From: Dan McGee -Date: Fri, 3 Feb 2012 20:20:21 -0600 -Subject: [PATCH 7/8] modinfo: handle arguments more carefully - -A simple case of breakage before this commit: - - $ touch aes - $ modinfo aes - filename: /tmp/aes - ERROR: could not get modinfo from 'aes': Invalid argument - -Add a new is_module_filename() function that attempts to do more than -just check if the passed argument is a regular file. We look at the name -for a '.ko' string, and if that is found, ensure it is either at the end -of the string or followed by another '.' (for .gz and .xz modules, for -instance). We don't make this second option conditional on the way the -tools are built with compression support; the file is a module file -regardless and should always be treated that way. - -When doing this, and noticed in the test suite output, we open the -system modules index unconditionally, even if it is never going to be -used during the modinfo call, which is the case when passing module -filenames directly. Delay the opening of the index file until we get an -argument that is not a module filename. - -With-help-from: Dave Reisner -Signed-off-by: Dan McGee ---- - tools/kmod-modinfo.c | 20 +++++++++++++++++--- - 1 files changed, 17 insertions(+), 3 deletions(-) - -diff --git a/tools/kmod-modinfo.c b/tools/kmod-modinfo.c -index 87483a5..ace5d3f 100644 ---- a/tools/kmod-modinfo.c -+++ b/tools/kmod-modinfo.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - #include - #include - #include -@@ -332,6 +333,21 @@ static void help(const char *progname) - progname); - } - -+static bool is_module_filename(const char *name) -+{ -+ struct stat st; -+ const char *ptr; -+ if (stat(name, &st) == 0 && S_ISREG(st.st_mode) && -+ (ptr = strstr(name, ".ko")) != NULL) { -+ /* we screened for .ko; make sure this is either at the end of the name -+ * or followed by another '.' (e.g. gz or xz modules) */ -+ if(ptr[3] != '\0' && ptr[3] != '.') -+ return false; -+ return true; -+ } -+ return false; -+} -+ - static int do_modinfo(int argc, char *argv[]) - { - struct kmod_ctx *ctx; -@@ -418,15 +434,13 @@ static int do_modinfo(int argc, char *argv[]) - fputs("Error: kmod_new() failed!\n", stderr); - return EXIT_FAILURE; - } -- kmod_load_resources(ctx); - - err = 0; - for (i = optind; i < argc; i++) { - const char *name = argv[i]; -- struct stat st; - int r; - -- if (stat(name, &st) == 0 && S_ISREG(st.st_mode)) -+ if (is_module_filename(name)) - r = modinfo_path_do(ctx, name); - else - r = modinfo_alias_do(ctx, name); --- -1.7.9 - diff --git a/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch b/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch deleted file mode 100644 index 652d2e854..000000000 --- a/testing/kmod/0008-Use-realpath-to-canonicalize-provided-paths.patch +++ /dev/null @@ -1,163 +0,0 @@ -From 4148d50c980e20a71b5e284e93863b4f36f4fbe4 Mon Sep 17 00:00:00 2001 -From: Dan McGee -Date: Fri, 3 Feb 2012 15:01:34 -0600 -Subject: [PATCH 8/8] Use realpath() to canonicalize provided paths - -The existing function choked in several corner cases: -* '/tmp/../tmp' was seen as absolute, so not cleaned up. -* '/tmp/' and '/tmp' were not equal, causing depmod to act differently - when called with the -b option for the two paths. - -Don't reinvent the wheel; just use the standard library function. - -Signed-off-by: Dan McGee ---- - libkmod/libkmod-module.c | 6 +++--- - libkmod/libkmod-util.c | 36 ------------------------------------ - libkmod/libkmod-util.h | 2 -- - libkmod/libkmod.c | 13 +++++++++---- - tools/kmod-depmod.c | 8 ++++++-- - 5 files changed, 18 insertions(+), 47 deletions(-) - -diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c -index 48e4aa1..48e7286 100644 ---- a/libkmod/libkmod-module.c -+++ b/libkmod/libkmod-module.c -@@ -326,10 +326,10 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx, - if (ctx == NULL || path == NULL || mod == NULL) - return -ENOENT; - -- abspath = path_make_absolute_cwd(path); -+ abspath = canonicalize_file_name(path); - if (abspath == NULL) { -- DBG(ctx, "no absolute path for %s\n", path); -- return -ENOMEM; -+ DBG(ctx, "no canonical filename returned for %s\n", path); -+ return -errno; - } - - err = stat(abspath, &st); -diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c -index 6a9f697..02b7f63 100644 ---- a/libkmod/libkmod-util.c -+++ b/libkmod/libkmod-util.c -@@ -301,42 +301,6 @@ char *strchr_replace(char *s, int c, char r) - return s; - } - --bool path_is_absolute(const char *p) --{ -- assert(p != NULL); -- -- return p[0] == '/'; --} -- --char *path_make_absolute_cwd(const char *p) --{ -- char *cwd, *r; -- size_t plen; -- size_t cwdlen; -- -- if (path_is_absolute(p)) -- return strdup(p); -- -- cwd = get_current_dir_name(); -- if (cwd == NULL) -- return NULL; -- -- plen = strlen(p); -- cwdlen = strlen(cwd); -- -- /* cwd + '/' + p + '\0' */ -- r = realloc(cwd, cwdlen + 1 + plen + 1); -- if (r == NULL) { -- free(cwd); -- return NULL; -- } -- -- r[cwdlen] = '/'; -- memcpy(&r[cwdlen + 1], p, plen + 1); -- -- return r; --} -- - #define USEC_PER_SEC 1000000ULL - #define NSEC_PER_USEC 1000ULL - unsigned long long ts_usec(const struct timespec *ts) -diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h -index c9a1a21..63c348f 100644 ---- a/libkmod/libkmod-util.h -+++ b/libkmod/libkmod-util.h -@@ -19,8 +19,6 @@ ssize_t write_str_safe(int fd, const char *buf, size_t buflen) __attribute__((no - int read_str_long(int fd, long *value, int base) __must_check __attribute__((nonnull(2))); - int read_str_ulong(int fd, unsigned long *value, int base) __must_check __attribute__((nonnull(2))); - char *strchr_replace(char *s, int c, char r); --bool path_is_absolute(const char *p) __must_check __attribute__((nonnull(1))); --char *path_make_absolute_cwd(const char *p) __must_check __attribute__((nonnull(1))); - int alias_normalize(const char *alias, char buf[PATH_MAX], size_t *len) __must_check __attribute__((nonnull(1,2))); - char *modname_normalize(const char *modname, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(1, 2))); - char *path_to_modname(const char *path, char buf[PATH_MAX], size_t *len) __attribute__((nonnull(2))); -diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c -index 800a178..c578afb 100644 ---- a/libkmod/libkmod.c -+++ b/libkmod/libkmod.c -@@ -160,13 +160,18 @@ static int log_priority(const char *priority) - - static const char *dirname_default_prefix = ROOTPREFIX "/lib/modules"; - --static char *get_kernel_release(const char *dirname) -+static char *get_kernel_release(struct kmod_ctx *ctx, const char *dirname) - { - struct utsname u; - char *p; - -- if (dirname != NULL) -- return path_make_absolute_cwd(dirname); -+ if (dirname != NULL) { -+ p = canonicalize_file_name(dirname); -+ if (p) -+ return p; -+ INFO(ctx, "could not canonicalize directory %s: %m\n", dirname); -+ return strdup(dirname); -+ } - - if (uname(&u) < 0) - return NULL; -@@ -215,7 +220,7 @@ KMOD_EXPORT struct kmod_ctx *kmod_new(const char *dirname, - ctx->log_data = stderr; - ctx->log_priority = LOG_ERR; - -- ctx->dirname = get_kernel_release(dirname); -+ ctx->dirname = get_kernel_release(ctx, dirname); - - /* environment overwrites config */ - env = getenv("KMOD_LOG"); -diff --git a/tools/kmod-depmod.c b/tools/kmod-depmod.c -index 0cf28f6..72180ef 100644 ---- a/tools/kmod-depmod.c -+++ b/tools/kmod-depmod.c -@@ -1160,7 +1160,7 @@ static int depmod_module_add(struct depmod *depmod, struct kmod_module *kmod) - } - } - -- DBG("add %p kmod=%p, path=%s\n", mod, kmod, mod->path); -+ DBG("add %p kmod=%p, path=%s, relpath=%s\n", mod, kmod, mod->path, mod->relpath); - - return 0; - } -@@ -2547,7 +2547,11 @@ static int do_depmod(int argc, char *argv[]) - maybe_all = 1; - break; - case 'b': -- root = path_make_absolute_cwd(optarg); -+ root = canonicalize_file_name(optarg); -+ if (!root) { -+ CRIT("could not resolve path %s\n", optarg); -+ goto cmdline_failed; -+ } - break; - case 'C': { - size_t bytes = sizeof(char *) * (n_config_paths + 2); --- -1.7.9 - -- cgit v1.2.3-54-g00ecf