diff options
author | Topi Miettinen <toiwoton@gmail.com> | 2019-12-23 18:58:13 +0200 |
---|---|---|
committer | Lucas De Marchi <lucas.demarchi@intel.com> | 2019-12-29 16:13:35 -0800 |
commit | 81dbf2bee644ef035d054e2101fceea86c50e07d (patch) | |
tree | e85e6959dc38e6e89965ead3a3eaabcd1b591974 | |
parent | e7e2cb61fa9f1db3429d91ef6accff549500d268 (diff) | |
download | kmod-81dbf2bee644ef035d054e2101fceea86c50e07d.tar.gz kmod-81dbf2bee644ef035d054e2101fceea86c50e07d.tar.bz2 kmod-81dbf2bee644ef035d054e2101fceea86c50e07d.zip |
libkmod-module: convert return value from system() to errno
Don't use exit status of a command directly as errno code, callers
will be confused.
Signed-off-by: Topi Miettinen <toiwoton@gmail.com>
-rw-r--r-- | libkmod/libkmod-module.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c index 8044a8f..714ee21 100644 --- a/libkmod/libkmod-module.c +++ b/libkmod/libkmod-module.c @@ -980,14 +980,19 @@ static int command_do(struct kmod_module *mod, const char *type, err = system(cmd); unsetenv("MODPROBE_MODULE"); - if (err == -1 || WEXITSTATUS(err)) { - ERR(mod->ctx, "Error running %s command for %s\n", - type, modname); - if (err != -1) - err = -WEXITSTATUS(err); + if (err == -1) { + ERR(mod->ctx, "Could not run %s command '%s' for module %s: %m\n", + type, cmd, modname); + return -EINVAL; } - return err; + if (WEXITSTATUS(err)) { + ERR(mod->ctx, "Error running %s command '%s' for module %s: retcode %d\n", + type, cmd, modname, WEXITSTATUS(err)); + return -EINVAL; + } + + return 0; } struct probe_insert_cb { |