#include <unistd.h>
#include <ctype.h>
+#include "kmod.h"
+
#define DEFAULT_VERBOSE LOG_WARNING
static int verbose = DEFAULT_VERBOSE;
{ }
};
-static void help(const char *progname)
+static void help(void)
{
fprintf(stderr,
"Usage:\n"
"\t current kernel symbols.\n"
"\t-E, --symvers=FILE Use Module.symvers file to check\n"
"\t symbol versions.\n",
- progname);
+ binname);
}
static inline void _show(const char *fmt, ...)
break;
case 'h':
- help(basename(argv[0]));
+ help();
free(config_paths);
return EXIT_SUCCESS;
case 'V':
return EXIT_FAILURE;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_depmod = {
.name = "depmod",
.cmd = do_depmod,
#include <string.h>
#include "libkmod.h"
+#include "kmod.h"
+
#define LOGPREFIX "insmod: "
#define ERR(...) fprintf(stderr, LOGPREFIX "ERROR: " __VA_ARGS__)
{NULL, 0, 0, 0}
};
-static void help(const char *progname)
+static void help(void)
{
fprintf(stderr,
"Usage:\n"
"Options:\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- progname);
+ binname);
}
static const char *mod_strerror(int err)
/* ignored, for compatibility only */
break;
case 'h':
- help(basename(argv[0]));
+ help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_insmod = {
.name = "insmod",
.cmd = do_insmod,
#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' },
int main(int argc, char *argv[])
{
- const char *binname = basename(argv[0]);
int err;
+ binname = basename(argv[0]);
+
if (strcmp(binname, "kmod") == 0)
err = handle_kmod_commands(argc, argv);
else
extern const struct kmod_cmd kmod_cmd_compat_depmod;
extern const struct kmod_cmd kmod_cmd_list;
+
+/* kmod.c */
+extern const char *binname;
#include <string.h>
#include "libkmod.h"
+#include "kmod.h"
static int do_lsmod(int argc, char *argv[])
{
return EXIT_SUCCESS;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_lsmod = {
.name = "lsmod",
.cmd = do_lsmod,
#include <sys/stat.h>
#include "libkmod.h"
+#include "kmod.h"
+
#define LOGPREFIX "modinfo: "
#define ERR(...) fprintf(stderr, LOGPREFIX "ERROR: " __VA_ARGS__)
{NULL, 0, 0, 0}
};
-static void help(const char *progname)
+static void help(void)
{
fprintf(stderr,
"Usage:\n"
"\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",
- progname);
+ binname);
}
static bool is_module_filename(const char *name)
root = optarg;
break;
case 'h':
- help(basename(argv[0]));
+ help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_modinfo = {
.name = "modinfo",
.cmd = do_modinfo,
#include "libkmod-array.h"
#include "macro.h"
+#include "kmod.h"
+
static int log_priority = LOG_CRIT;
static int use_syslog = 0;
{NULL, 0, 0, 0}
};
-static void help(const char *progname)
+static void help(void)
{
fprintf(stderr,
"Usage:\n"
"\t-v, --verbose enables more messages\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- progname, progname, progname, progname, progname, progname);
+ binname, binname, binname, binname, binname, binname);
}
static inline void _show(const char *fmt, ...)
err = 0;
goto done;
case 'h':
- help(basename(argv[0]));
+ help();
err = 0;
goto done;
case '?':
return err >= 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_modprobe = {
.name = "modprobe",
.cmd = do_modprobe,
#include "libkmod.h"
#include "macro.h"
+#include "kmod.h"
+
#define DEFAULT_VERBOSE LOG_ERR
static int verbose = DEFAULT_VERBOSE;
static int use_syslog;
{NULL, 0, 0, 0}
};
-static void help(const char *progname)
+static void help(void)
{
fprintf(stderr,
"Usage:\n"
"\t-v, --verbose enables more messages\n"
"\t-V, --version show version\n"
"\t-h, --help show this help\n",
- progname);
+ binname);
}
static _always_inline_ const char *prio_to_str(int prio)
flags &= ~KMOD_REMOVE_NOWAIT;
break;
case 'h':
- help(basename(argv[0]));
+ help();
return EXIT_SUCCESS;
case 'V':
puts(PACKAGE " version " VERSION);
return r == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
-#include "kmod.h"
-
const struct kmod_cmd kmod_cmd_compat_rmmod = {
.name = "rmmod",
.cmd = do_rmmod,