diff options
author | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2012-01-07 19:37:37 -0200 |
---|---|---|
committer | Gustavo Sverzut Barbieri <barbieri@profusion.mobi> | 2012-01-31 22:01:00 -0200 |
commit | dfa96f154529a666bee177f4ac44e0d3a9811ad5 (patch) | |
tree | ea5f059f0cba2367604cf03436a063a816d696d1 | |
parent | e3cb0900dd58a4b3a5c85ef52983b1e65931150b (diff) | |
download | kmod-dfa96f154529a666bee177f4ac44e0d3a9811ad5.tar.gz kmod-dfa96f154529a666bee177f4ac44e0d3a9811ad5.zip |
improve logging to mention context.
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.
-rw-r--r-- | libkmod/libkmod-config.c | 2 | ||||
-rw-r--r-- | libkmod/libkmod-index.c | 7 | ||||
-rw-r--r-- | libkmod/libkmod.c | 15 |
3 files changed, 15 insertions, 9 deletions
diff --git a/libkmod/libkmod-config.c b/libkmod/libkmod-config.c index f970f9e..ac9c888 100644 --- a/libkmod/libkmod-config.c +++ b/libkmod/libkmod-config.c @@ -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; } diff --git a/libkmod/libkmod-index.c b/libkmod/libkmod-index.c index c1c3c99..07f3b8c 100644 --- a/libkmod/libkmod-index.c +++ b/libkmod/libkmod-index.c @@ -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; } diff --git a/libkmod/libkmod.c b/libkmod/libkmod.c index 9c7c701..4990d3e 100644 --- a/libkmod/libkmod.c +++ b/libkmod/libkmod.c @@ -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; } |