]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
kmod_module_new_*: improve debugging.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Tue, 20 Dec 2011 15:04:10 +0000 (13:04 -0200)
committerLucas De Marchi <lucas.demarchi@profusion.mobi>
Tue, 20 Dec 2011 15:13:41 +0000 (13:13 -0200)
libkmod/libkmod-module.c

index a586201383d607db60c4611528f275d5443fe49e..2d20792b5866b65a41e418db95b276807ffcf2d5 100644 (file)
@@ -327,16 +327,21 @@ KMOD_EXPORT int kmod_module_new_from_path(struct kmod_ctx *ctx,
                return -ENOENT;
 
        abspath = path_make_absolute_cwd(path);
-       if (abspath == NULL)
+       if (abspath == NULL) {
+               DBG(ctx, "no absolute path for %s\n", path);
                return -ENOMEM;
+       }
 
        err = stat(abspath, &st);
        if (err < 0) {
+               err = -errno;
+               DBG(ctx, "stat %s: %s\n", path, strerror(errno));
                free(abspath);
-               return -errno;
+               return err;
        }
 
        if (path_to_modname(path, name, &namelen) == NULL) {
+               DBG(ctx, "could not get modname from path %s\n", path);
                free(abspath);
                return -ENOENT;
        }
@@ -477,29 +482,38 @@ KMOD_EXPORT int kmod_module_new_from_lookup(struct kmod_ctx *ctx,
                return -ENOSYS;
        }
 
-       if (alias_normalize(given_alias, alias, NULL) < 0)
+       if (alias_normalize(given_alias, alias, NULL) < 0) {
+               DBG(ctx, "invalid alias: %s\n", given_alias);
                return -EINVAL;
+       }
+
+       DBG(ctx, "input alias=%s, normalized=%s\n", given_alias, alias);
 
        /* Aliases from config file override all the others */
        err = kmod_lookup_alias_from_config(ctx, alias, list);
        CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
+       DBG(ctx, "lookup modules.dep %s\n", alias);
        err = kmod_lookup_alias_from_moddep_file(ctx, alias, list);
        CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
+       DBG(ctx, "lookup modules.symbols %s\n", alias);
        err = kmod_lookup_alias_from_symbols_file(ctx, alias, list);
        CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
+       DBG(ctx, "lookup install and remove commands %s\n", alias);
        err = kmod_lookup_alias_from_commands(ctx, alias, list);
        CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
+       DBG(ctx, "lookup modules.aliases %s\n", alias);
        err = kmod_lookup_alias_from_aliases_file(ctx, alias, list);
        CHECK_ERR_AND_FINISH(err, fail, list, finish);
 
 finish:
-
+       DBG(ctx, "lookup %s=%d, list=%p\n", alias, err, *list);
        return err;
 fail:
+       DBG(ctx, "Failed to lookup %s\n", alias);
        kmod_module_unref_list(*list);
        *list = NULL;
        return err;