#include "time-util.h"
#include "udev-util.h"
#include "udev.h"
+#include "udevadm-util.h"
static void print_help(void) {
- printf("%s control COMMAND\n\n"
+ printf("%s control OPTION\n\n"
"Control the udev daemon.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n"
+ " -V --version Show package version\n"
" -e --exit Instruct the daemon to cleanup and exit\n"
" -l --log-priority=LEVEL Set the udev log level for the daemon\n"
" -s --stop-exec-queue Do not execute events, queue only\n"
{ "env", required_argument, NULL, 'p' }, /* alias for -p */
{ "children-max", required_argument, NULL, 'm' },
{ "timeout", required_argument, NULL, 't' },
+ { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{}
};
if (uctrl == NULL)
return 2;
- while ((c = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "el:sSRp:m:t:Vh", options, NULL)) >= 0)
switch (c) {
case 'e':
if (udev_ctrl_send_exit(uctrl, timeout) < 0)
}
break;
}
+ case 'V':
+ print_version();
+ rc = 0;
+ break;
case 'h':
print_help();
rc = 0;
#include "strbuf.h"
#include "string-util.h"
#include "udev.h"
+#include "udevadm-util.h"
#include "util.h"
/*
}
static void help(void) {
- printf("Usage: udevadm hwdb OPTIONS\n"
- " -u,--update update the hardware database\n"
- " --usr generate in " UDEVLIBEXECDIR " instead of /etc/udev\n"
- " -t,--test=MODALIAS query database and print result\n"
- " -r,--root=PATH alternative root path in the filesystem\n"
- " -h,--help\n\n");
+ printf("%s hwdb [OPTIONS]\n\n"
+ " -h --help Print this message\n"
+ " -V --version Print version of the program\n"
+ " -u --update Update the hardware database\n"
+ " --usr Generate in " UDEVLIBEXECDIR " instead of /etc/udev\n"
+ " -t --test=MODALIAS Query database and print result\n"
+ " -r --root=PATH Alternative root path in the filesystem\n\n"
+ "NOTE:\n"
+ "The sub-command 'hwdb' is deprecated, and is left for backwards compatibility.\n"
+ "Please use systemd-hwdb instead.\n"
+ , program_invocation_short_name);
}
static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
};
static const struct option options[] = {
- { "update", no_argument, NULL, 'u' },
- { "usr", no_argument, NULL, ARG_USR },
- { "test", required_argument, NULL, 't' },
- { "root", required_argument, NULL, 'r' },
- { "help", no_argument, NULL, 'h' },
+ { "update", no_argument, NULL, 'u' },
+ { "usr", no_argument, NULL, ARG_USR },
+ { "test", required_argument, NULL, 't' },
+ { "root", required_argument, NULL, 'r' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
const char *test = NULL;
int err, c;
int rc = EXIT_SUCCESS;
- while ((c = getopt_long(argc, argv, "ut:r:h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "ut:r:Vh", options, NULL)) >= 0)
switch(c) {
case 'u':
update = true;
case 'r':
root = optarg;
break;
+ case 'V':
+ print_version();
+ return EXIT_SUCCESS;
case 'h':
help();
return EXIT_SUCCESS;
export_prefix = optarg;
break;
case 'V':
- printf("%s\n", PACKAGE_VERSION);
+ print_version();
return 0;
case 'h':
help();
#include "format-util.h"
#include "udev-util.h"
#include "udev.h"
+#include "udevadm-util.h"
static bool udev_exit;
}
static void help(void) {
- printf("%s monitor [--property] [--kernel] [--udev] [--help]\n\n"
+ printf("%s monitor [OPTIONS]\n\n"
"Listen to kernel and udev events.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n"
+ " -V --version Show package version\n"
" -p --property Print the event properties\n"
" -k --kernel Print kernel uevents\n"
" -u --udev Print udev events\n"
{ "udev", no_argument, NULL, 'u' },
{ "subsystem-match", required_argument, NULL, 's' },
{ "tag-match", required_argument, NULL, 't' },
+ { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{}
};
udev_list_init(udev, &subsystem_match_list, true);
udev_list_init(udev, &tag_match_list, true);
- while ((c = getopt_long(argc, argv, "pekus:t:h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "pekus:t:Vh", options, NULL)) >= 0)
switch (c) {
case 'p':
case 'e':
case 't':
udev_list_entry_add(&tag_match_list, optarg, NULL);
break;
+ case 'V':
+ print_version();
+ return 0;
case 'h':
help();
return 0;
#include "parse-util.h"
#include "udev.h"
+#include "udevadm-util.h"
#include "util.h"
static void help(void) {
- printf("%s settle OPTIONS\n\n"
+ printf("%s settle [OPTIONS]\n\n"
"Wait for pending udev events.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n"
+ " -V --version Show package version\n"
" -t --timeout=SECONDS Maximum time to wait for events\n"
" -E --exit-if-exists=FILE Stop waiting if file exists\n"
, program_invocation_short_name);
static const struct option options[] = {
{ "timeout", required_argument, NULL, 't' },
{ "exit-if-exists", required_argument, NULL, 'E' },
+ { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{ "seq-start", required_argument, NULL, 's' }, /* removed */
{ "seq-end", required_argument, NULL, 'e' }, /* removed */
struct udev_queue *queue;
int rc = EXIT_FAILURE;
- while ((c = getopt_long(argc, argv, "t:E:hs:e:q", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "t:E:Vhs:e:q", options, NULL)) >= 0) {
switch (c) {
case 't': {
exists = optarg;
break;
+ case 'V':
+ print_version();
+ return EXIT_SUCCESS;
+
case 'h':
help();
return EXIT_SUCCESS;
#include "path-util.h"
#include "string-util.h"
#include "udev.h"
+#include "udevadm-util.h"
static void help(struct udev *udev) {
- printf("%s builtin [--help] COMMAND SYSPATH\n\n"
+ printf("%s test-builtin [OPTIONS] COMMAND DEVPATH\n\n"
"Test a built-in command.\n\n"
" -h --help Print this message\n"
- " --version Print version of the program\n\n"
+ " -V --version Print version of the program\n\n"
"Commands:\n"
, program_invocation_short_name);
static int adm_builtin(struct udev *udev, int argc, char *argv[]) {
static const struct option options[] = {
- { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
char *command = NULL;
enum udev_builtin_cmd cmd;
int rc = EXIT_SUCCESS, c;
- while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "Vh", options, NULL)) >= 0)
switch (c) {
+ case 'V':
+ print_version();
+ goto out;
case 'h':
help(udev);
goto out;
#include "string-util.h"
#include "udev-util.h"
#include "udev.h"
+#include "udevadm-util.h"
static void help(void) {
- printf("%s test OPTIONS <syspath>\n\n"
- "Test an event run.\n"
+ printf("%s test [OPTIONS] DEVPATH\n\n"
+ "Test an event run.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n"
+ " -V --version Show package version\n"
" -a --action=ACTION Set action string\n"
" -N --resolve-names=early|late|never When to resolve names\n"
, program_invocation_short_name);
int rc = 0, c;
static const struct option options[] = {
- { "action", required_argument, NULL, 'a' },
+ { "action", required_argument, NULL, 'a' },
{ "resolve-names", required_argument, NULL, 'N' },
- { "help", no_argument, NULL, 'h' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
log_debug("version %s", PACKAGE_VERSION);
- while ((c = getopt_long(argc, argv, "a:N:h", options, NULL)) >= 0)
+ while ((c = getopt_long(argc, argv, "a:N:Vh", options, NULL)) >= 0)
switch (c) {
case 'a':
action = optarg;
exit(EXIT_FAILURE);
}
break;
+ case 'V':
+ print_version();
+ exit(EXIT_SUCCESS);
case 'h':
help();
exit(EXIT_SUCCESS);
}
static void help(void) {
- printf("%s trigger OPTIONS\n\n"
+ printf("%s trigger [OPTIONS] DEVPATH\n\n"
"Request events from the kernel.\n\n"
" -h --help Show this help\n"
- " --version Show package version\n"
+ " -V --version Show package version\n"
" -v --verbose Print the list of devices while running\n"
" -n --dry-run Do not actually trigger the events\n"
" -t --type= Type of events to trigger\n"
{ "sysname-match", required_argument, NULL, 'y' },
{ "name-match", required_argument, NULL, ARG_NAME },
{ "parent-match", required_argument, NULL, 'b' },
+ { "version", no_argument, NULL, 'V' },
{ "help", no_argument, NULL, 'h' },
{}
};
if (udev_enumerate == NULL)
return 1;
- while ((c = getopt_long(argc, argv, "vno:t:c:s:S:a:A:p:g:y:b:h", options, NULL)) >= 0) {
+ while ((c = getopt_long(argc, argv, "vnt:c:s:S:a:A:p:g:y:b:Vh", options, NULL)) >= 0) {
const char *key;
const char *val;
char buf[UTIL_PATH_SIZE];
break;
}
+ case 'V':
+ print_version();
+ return 0;
case 'h':
help();
return 0;
struct udev_device *find_device(struct udev *udev,
const char *id,
const char *prefix);
+
+static inline void print_version(void) {
+ printf("%s\n", PACKAGE_VERSION);
+}