aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-06 19:20:09 -0200
committerLucas De Marchi <lucas.demarchi@profusion.mobi>2012-11-06 19:30:16 -0200
commit7c04aeee40e9cced2656e286b2dc4bfbe8008a9f (patch)
treea5893622844427f2f393286fee4643d9b3634e84
parentc84127372112642464fe3d266ffe58bbc1bc37f3 (diff)
downloadkmod-7c04aeee40e9cced2656e286b2dc4bfbe8008a9f.tar.gz
tools: use program_invocation_short_name provided by libc
Thanks to Dave Reisner for pointing this out.
-rw-r--r--tools/depmod.c2
-rw-r--r--tools/insmod.c2
-rw-r--r--tools/kmod.c7
-rw-r--r--tools/kmod.h3
-rw-r--r--tools/log.c14
-rw-r--r--tools/modinfo.c2
-rw-r--r--tools/modprobe.c4
-rw-r--r--tools/rmmod.c2
8 files changed, 17 insertions, 19 deletions
diff --git a/tools/depmod.c b/tools/depmod.c
index 7d36a50..cc9346f 100644
--- a/tools/depmod.c
+++ b/tools/depmod.c
@@ -114,7 +114,7 @@ static void help(void)
"\t current kernel symbols.\n"
"\t-E, --symvers=FILE Use Module.symvers file to check\n"
"\t symbol versions.\n",
- binname);
+ program_invocation_short_name);
}
static inline void _show(const char *fmt, ...)
diff --git a/tools/insmod.c b/tools/insmod.c
index f358b93..427495a 100644
--- a/tools/insmod.c
+++ b/tools/insmod.c
@@ -40,7 +40,7 @@ static void help(void)
"Options:\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- binname);
+ program_invocation_short_name);
}
static const char *mod_strerror(int err)
diff --git a/tools/kmod.c b/tools/kmod.c
index 7de9511..5a6bc14 100644
--- a/tools/kmod.c
+++ b/tools/kmod.c
@@ -25,9 +25,6 @@
#include <libkmod.h>
#include "kmod.h"
-/* visible to all tools, compat or otherwise */
-const char *binname;
-
static const char options_s[] = "+hV";
static const struct option options[] = {
{ "help", no_argument, NULL, 'h' },
@@ -162,9 +159,7 @@ int main(int argc, char *argv[])
{
int err;
- binname = basename(argv[0]);
-
- if (strcmp(binname, "kmod") == 0)
+ if (strcmp(program_invocation_short_name, "kmod") == 0)
err = handle_kmod_commands(argc, argv);
else
err = handle_kmod_compat_commands(argc, argv);
diff --git a/tools/kmod.h b/tools/kmod.h
index ceff861..59a87e0 100644
--- a/tools/kmod.h
+++ b/tools/kmod.h
@@ -36,7 +36,4 @@ extern const struct kmod_cmd kmod_cmd_compat_depmod;
extern const struct kmod_cmd kmod_cmd_list;
-/* kmod.c */
-extern const char *binname;
-
#include "log.h"
diff --git a/tools/log.c b/tools/log.c
index 745f5b3..a28cebf 100644
--- a/tools/log.c
+++ b/tools/log.c
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
@@ -77,10 +78,12 @@ static void log_kmod(void *data, int priority, const char *file, int line,
#endif
} else {
#ifdef ENABLE_DEBUG
- fprintf(stderr, "%s: %s: %s:%d %s() %s", binname, prioname,
- file, line, fn, str);
+ fprintf(stderr, "%s: %s: %s:%d %s() %s",
+ program_invocation_short_name, prioname, file, line,
+ fn, str);
#else
- fprintf(stderr, "%s: %s: %s", binname, prioname, str);
+ fprintf(stderr, "%s: %s: %s", program_invocation_short_name,
+ prioname, str);
#endif
}
@@ -92,7 +95,7 @@ void log_open(bool use_syslog)
log_use_syslog = use_syslog;
if (log_use_syslog)
- openlog(binname, LOG_CONS, LOG_DAEMON);
+ openlog(program_invocation_short_name, LOG_CONS, LOG_DAEMON);
}
void log_close(void)
@@ -122,7 +125,8 @@ void log_printf(int prio, const char *fmt, ...)
if (log_use_syslog)
syslog(prio, "%s: %s", prioname, msg);
else
- fprintf(stderr, "%s: %s: %s", binname, prioname, msg);
+ fprintf(stderr, "%s: %s: %s", program_invocation_short_name,
+ prioname, msg);
free(msg);
if (prio <= LOG_CRIT)
diff --git a/tools/modinfo.c b/tools/modinfo.c
index 8cfe381..aec2608 100644
--- a/tools/modinfo.c
+++ b/tools/modinfo.c
@@ -341,7 +341,7 @@ static void help(void)
"\t-b, --basedir=DIR Use DIR as filesystem root for /lib/modules\n"
"\t-V, --version Show version\n"
"\t-h, --help Show this help\n",
- binname);
+ program_invocation_short_name);
}
static bool is_module_filename(const char *name)
diff --git a/tools/modprobe.c b/tools/modprobe.c
index 4b30759..437dea3 100644
--- a/tools/modprobe.c
+++ b/tools/modprobe.c
@@ -137,7 +137,9 @@ static void help(void)
"\t-v, --verbose enables more messages\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- binname, binname, binname, binname, binname, binname);
+ program_invocation_short_name, program_invocation_short_name,
+ program_invocation_short_name, program_invocation_short_name,
+ program_invocation_short_name, program_invocation_short_name);
}
static inline void _show(const char *fmt, ...)
diff --git a/tools/rmmod.c b/tools/rmmod.c
index 7be4604..0495463 100644
--- a/tools/rmmod.c
+++ b/tools/rmmod.c
@@ -57,7 +57,7 @@ static void help(void)
"\t-v, --verbose enables more messages\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- binname);
+ program_invocation_short_name);
}
static int check_module_inuse(struct kmod_module *mod) {