]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
improve logging to mention context.
authorGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Sat, 7 Jan 2012 21:37:37 +0000 (19:37 -0200)
committerGustavo Sverzut Barbieri <barbieri@profusion.mobi>
Wed, 1 Feb 2012 00:01:00 +0000 (22:01 -0200)
Just printing the errno string such as "%m\n" is not enough to help
debug or users understand the problem.

Change to provide more context on the failing operation.

libkmod/libkmod-config.c
libkmod/libkmod-index.c
libkmod/libkmod.c

index f970f9e167e7eeea1485af67a8016a5ce33ea967..ac9c888dc7d41b54a31960047b1571ef676a6ab6 100644 (file)
@@ -808,7 +808,7 @@ static int conf_files_list(struct kmod_ctx *ctx, struct kmod_list **list,
 
        d = opendir(path);
        if (d == NULL) {
-               ERR(ctx, "%m\n");
+               ERR(ctx, "opendir(%s): %m\n", path);
                return -EINVAL;
        }
 
index c1c3c9942e93f0050936093a6edba4a7df2aa334..07f3b8c71eb90c0676cab34134105e767c3f9907 100644 (file)
@@ -788,12 +788,12 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
 
        idx = malloc(sizeof(*idx));
        if (idx == NULL) {
-               ERR(ctx, "%m\n");
+               ERR(ctx, "malloc: %m\n");
                return NULL;
        }
 
        if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) < 0) {
-               ERR(ctx, "%m\n");
+               ERR(ctx, "open(%s, O_RDONLY|O_CLOEXEC): %m\n", filename);
                goto fail_open;
        }
 
@@ -804,7 +804,8 @@ struct index_mm *index_mm_open(struct kmod_ctx *ctx, const char *filename,
 
        if ((idx->mm = mmap(0, st.st_size, PROT_READ, flags, fd, 0))
                                                        == MAP_FAILED) {
-               ERR(ctx, "%m\n");
+               ERR(ctx, "mmap(0, %zd, PROT_READ, %d, %d, 0): %m\n",
+                   (size_t)st.st_size, flags, fd);
                goto fail;
        }
 
index 9c7c7013e10a62ab9dfbf1aba9b5feaaca91ddb8..4990d3e5faf7d57f6a275271caf5fe5acce89f82 100644 (file)
@@ -441,7 +441,8 @@ static int kmod_lookup_alias_from_alias_bin(struct kmod_ctx *ctx,
 
                err = kmod_module_new_from_alias(ctx, name, realname->value, &mod);
                if (err < 0) {
-                       ERR(ctx, "%s\n", strerror(-err));
+                       ERR(ctx, "Could not create module for alias=%s realname=%s: %s\n",
+                           name, realname->value, strerror(-err));
                        goto fail;
                }
 
@@ -524,7 +525,8 @@ int kmod_lookup_alias_from_moddep_file(struct kmod_ctx *ctx, const char *name,
 
                n = kmod_module_new_from_name(ctx, name, &mod);
                if (n < 0) {
-                       ERR(ctx, "%s\n", strerror(-n));
+                       ERR(ctx, "Could not create module from name %s: %s\n",
+                           name, strerror(-n));
                        goto finish;
                }
 
@@ -555,7 +557,8 @@ int kmod_lookup_alias_from_config(struct kmod_ctx *ctx, const char *name,
                        err = kmod_module_new_from_alias(ctx, aliasname,
                                                                modname, &mod);
                        if (err < 0) {
-                               ERR(ctx, "%s\n", strerror(-err));
+                               ERR(ctx, "Could not create module for alias=%s modname=%s: %s\n",
+                                   name, modname, strerror(-err));
                                goto fail;
                        }
 
@@ -587,7 +590,8 @@ int kmod_lookup_alias_from_commands(struct kmod_ctx *ctx, const char *name,
 
                        err = kmod_module_new_from_name(ctx, modname, &mod);
                        if (err < 0) {
-                               ERR(ctx, "%s\n", strerror(-err));
+                               ERR(ctx, "Could not create module from name %s: %s\n",
+                                   modname, strerror(-err));
                                return err;
                        }
 
@@ -622,7 +626,8 @@ int kmod_lookup_alias_from_commands(struct kmod_ctx *ctx, const char *name,
 
                        err = kmod_module_new_from_name(ctx, modname, &mod);
                        if (err < 0) {
-                               ERR(ctx, "%s\n", strerror(-err));
+                               ERR(ctx, "Could not create module from name %s: %s\n",
+                                   modname, strerror(-err));
                                return err;
                        }