Skip to content

Commit 31d6ecd

Browse files
committed
tools: improve error logs to specify in which dirname is the module missing
Currently if no module is found in MODULE_DIRECTORY, kmod will just print "Module %s not found", but now that we have two search path, it is worth specifying which is the path that was not found. TODO: ERR() produces a not so pleasant to see error which might confuse the user, especially if a module is in MODULE_ALTERNATIVE_DIRECTORY and not in MODULE_DIRECTORY, because we would have such output: modprobe: ERROR: Module %s not found in directory <MODULE_DIRECTORY> <output foud in MODULE_ALTERNATIVE_DIRECTORY> Signed-off-by: Emanuele Giuseppe Esposito <[email protected]>
1 parent 4be4b95 commit 31d6ecd

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

tools/modinfo.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,8 @@ static int modinfo_path_do(struct kmod_ctx *ctx, const char *path)
265265
struct kmod_module *mod;
266266
int err = kmod_module_new_from_path(ctx, path, &mod);
267267
if (err < 0) {
268-
ERR("Module file %s not found.\n", path);
268+
ERR("Module file %s not found in %s.\n", path,
269+
kmod_get_dirname(ctx));
269270
return err;
270271
}
271272
err = modinfo_do(mod);
@@ -280,7 +281,8 @@ static int modinfo_name_do(struct kmod_ctx *ctx, const char *name)
280281

281282
err = kmod_module_new_from_name_lookup(ctx, name, &mod);
282283
if (err < 0 || mod == NULL) {
283-
ERR("Module name %s not found.\n", name);
284+
ERR("Module name %s not found in %s.\n", name,
285+
kmod_get_dirname(ctx));
284286
return err < 0 ? err : -ENOENT;
285287
}
286288

@@ -295,12 +297,14 @@ static int modinfo_alias_do(struct kmod_ctx *ctx, const char *alias)
295297
struct kmod_list *l, *list = NULL;
296298
int err = kmod_module_new_from_lookup(ctx, alias, &list);
297299
if (err < 0) {
298-
ERR("Module alias %s not found.\n", alias);
300+
ERR("Module alias %s not found in %s.\n", alias,
301+
kmod_get_dirname(ctx));
299302
return err;
300303
}
301304

302305
if (list == NULL) {
303-
ERR("Module %s not found.\n", alias);
306+
ERR("Module %s not found in %s.\n", alias,
307+
kmod_get_dirname(ctx));
304308
return -ENOENT;
305309
}
306310

tools/modprobe.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,8 @@ static int show_modversions(struct kmod_ctx *ctx, const char *filename)
210210
struct kmod_module *mod;
211211
int err = kmod_module_new_from_path(ctx, filename, &mod);
212212
if (err < 0) {
213-
LOG("Module %s not found.\n", filename);
213+
LOG("Module %s not found in %s.\n", filename,
214+
kmod_get_dirname(ctx));
214215
return err;
215216
}
216217

@@ -237,7 +238,8 @@ static int show_exports(struct kmod_ctx *ctx, const char *filename)
237238
struct kmod_module *mod;
238239
int err = kmod_module_new_from_path(ctx, filename, &mod);
239240
if (err < 0) {
240-
LOG("Module %s not found.\n", filename);
241+
LOG("Module %s not found in %s.\n", filename,
242+
kmod_get_dirname(ctx));
241243
return err;
242244
}
243245

@@ -500,7 +502,7 @@ static int rmmod(struct kmod_ctx *ctx, const char *alias)
500502
return err;
501503

502504
if (list == NULL) {
503-
LOG("Module %s not found.\n", alias);
505+
LOG("Module %s not found in %s.\n", alias, kmod_get_dirname(ctx));
504506
err = -ENOENT;
505507
}
506508

0 commit comments

Comments
 (0)