summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--man/udevadm.xml176
-rw-r--r--src/udev/scsi_id/scsi_id.c33
-rw-r--r--src/udev/udevadm-control.c59
-rw-r--r--src/udev/udevadm-hwdb.c37
-rw-r--r--src/udev/udevadm-info.c60
-rw-r--r--src/udev/udevadm-monitor.c41
-rw-r--r--src/udev/udevadm-settle.c61
-rw-r--r--src/udev/udevadm-test-builtin.c17
-rw-r--r--src/udev/udevadm-test.c25
-rw-r--r--src/udev/udevadm-trigger.c85
10 files changed, 326 insertions, 268 deletions
diff --git a/man/udevadm.xml b/man/udevadm.xml
index 30a6ac423a..6fc4e8d50c 100644
--- a/man/udevadm.xml
+++ b/man/udevadm.xml
@@ -82,6 +82,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -89,26 +90,28 @@
</varlistentry>
</variablelist>
- <refsect2><title>udevadm info <replaceable>options</replaceable></title>
+ <refsect2><title>udevadm info <optional><replaceable>OPTIONS</replaceable></optional> <optional><replaceable>DEVPATH</replaceable>|<replaceable>FILE</replaceable></optional></title>
<para>Queries the udev database for device information
stored in the udev database. It can also query the properties
of a device from its sysfs representation to help creating udev
rules that match this device.</para>
<variablelist>
<varlistentry>
- <term><option>--query=<replaceable>type</replaceable></option></term>
+ <term><option>-q</option></term>
+ <term><option>--query=<replaceable>TYPE</replaceable></option></term>
<listitem>
<para>Query the database for the specified type of device
data. It needs the <option>--path</option> or
- <option>--name</option> to identify the specified
- device. Valid queries are: <constant>name</constant>,
- <constant>symlink</constant>, <constant>path</constant>,
- <constant>property</constant>,
+ <option>--name</option> to identify the specified device.
+ Valid <replaceable>TYPE</replaceable>s are:
+ <constant>name</constant>, <constant>symlink</constant>,
+ <constant>path</constant>, <constant>property</constant>,
<constant>all</constant>.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--path=<replaceable>devpath</replaceable></option></term>
+ <term><option>-p</option></term>
+ <term><option>--path=<replaceable>DEVPATH</replaceable></option></term>
<listitem>
<para>The <filename>/sys</filename> path of the device to
query, e.g.
@@ -121,7 +124,8 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--name=<replaceable>file</replaceable></option></term>
+ <term><option>-n</option></term>
+ <term><option>--name=<replaceable>FILE</replaceable></option></term>
<listitem>
<para>The name of the device node or a symlink to query,
e.g. <filename><optional>/dev</optional>/sda</filename>.
@@ -132,6 +136,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-r</option></term>
<term><option>--root</option></term>
<listitem>
<para>Print absolute paths in <command>name</command> or <command>symlink</command>
@@ -139,6 +144,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-a</option></term>
<term><option>--attribute-walk</option></term>
<listitem>
<para>Print all sysfs properties of the specified device that can be used
@@ -147,31 +153,36 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-x</option></term>
<term><option>--export</option></term>
<listitem>
<para>Print output as key/value pairs. Values are enclosed in single quotes.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--export-prefix=<replaceable>name</replaceable></option></term>
+ <term><option>-P</option></term>
+ <term><option>--export-prefix=<replaceable>NAME</replaceable></option></term>
<listitem>
<para>Add a prefix to the key name of exported values.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--device-id-of-file=<replaceable>file</replaceable></option></term>
+ <term><option>-d</option></term>
+ <term><option>--device-id-of-file=<replaceable>FILE</replaceable></option></term>
<listitem>
<para>Print major/minor numbers of the underlying device, where the file
lives on.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-e</option></term>
<term><option>--export-db</option></term>
<listitem>
<para>Export the content of the udev database.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-c</option></term>
<term><option>--cleanup-db</option></term>
<listitem>
<para>Cleanup the udev database.</para>
@@ -184,6 +195,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -196,19 +208,22 @@
<para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
<variablelist>
<varlistentry>
+ <term><option>-v</option></term>
<term><option>--verbose</option></term>
<listitem>
<para>Print the list of devices which will be triggered.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-n</option></term>
<term><option>--dry-run</option></term>
<listitem>
<para>Do not actually trigger the event.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--type=<replaceable>type</replaceable></option></term>
+ <term><option>-t</option></term>
+ <term><option>--type=<replaceable>TYPE</replaceable></option></term>
<listitem>
<para>Trigger a specific type of devices. Valid types are:
<command>devices</command>, <command>subsystems</command>.
@@ -216,68 +231,95 @@
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--action=<replaceable>action</replaceable></option></term>
+ <term><option>-c</option></term>
+ <term><option>--action=<replaceable>ACTION</replaceable></option></term>
<listitem>
- <para>Type of event to be triggered. The default value is <command>change</command>.</para>
+ <para>Type of event to be triggered. The default value is
+ <command>change</command>.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--subsystem-match=<replaceable>subsystem</replaceable></option></term>
+ <term><option>-s</option></term>
+ <term><option>--subsystem-match=<replaceable>SUBSYSTEM</replaceable></option></term>
<listitem>
- <para>Trigger events for devices which belong to a matching subsystem. This option
- can be specified multiple times and supports shell style pattern matching.</para>
+ <para>Trigger events for devices which belong to a
+ matching subsystem. This option can be specified multiple
+ times and supports shell style pattern matching.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--subsystem-nomatch=<replaceable>subsystem</replaceable></option></term>
+ <term><option>-S</option></term>
+ <term><option>--subsystem-nomatch=<replaceable>SUBSYSTEM</replaceable></option></term>
<listitem>
<para>Do not trigger events for devices which belong to a matching subsystem. This option
can be specified multiple times and supports shell style pattern matching.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--attr-match=<replaceable>attribute</replaceable>=<replaceable>value</replaceable></option></term>
+ <term><option>-a</option></term>
+ <term><option>--attr-match=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
<listitem>
- <para>Trigger events for devices with a matching sysfs attribute. If a value is specified
- along with the attribute name, the content of the attribute is matched against the given
- value using shell style pattern matching. If no value is specified, the existence of the
- sysfs attribute is checked. This option can be specified multiple times.</para>
+ <para>Trigger events for devices with a matching sysfs
+ attribute. If a value is specified along with the
+ attribute name, the content of the attribute is matched
+ against the given value using shell style pattern
+ matching. If no value is specified, the existence of the
+ sysfs attribute is checked. This option can be specified
+ multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--attr-nomatch=<replaceable>attribute</replaceable>=<replaceable>value</replaceable></option></term>
+ <term><option>-A</option></term>
+ <term><option>--attr-nomatch=<replaceable>ATTRIBUTE</replaceable>=<replaceable>VALUE</replaceable></option></term>
<listitem>
- <para>Do not trigger events for devices with a matching sysfs attribute. If a value is
- specified along with the attribute name, the content of the attribute is matched against
- the given value using shell style pattern matching. If no value is specified, the existence
- of the sysfs attribute is checked. This option can be specified multiple times.</para>
+ <para>Do not trigger events for devices with a matching
+ sysfs attribute. If a value is specified along with the
+ attribute name, the content of the attribute is matched
+ against the given value using shell style pattern
+ matching. If no value is specified, the existence of the
+ sysfs attribute is checked. This option can be specified
+ multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--property-match=<replaceable>property</replaceable>=<replaceable>value</replaceable></option></term>
+ <term><option>-p</option></term>
+ <term><option>--property-match=<replaceable>PROPERTY</replaceable>=<replaceable>VALUE</replaceable></option></term>
<listitem>
- <para>Trigger events for devices with a matching property value. This option can be
- specified multiple times and supports shell style pattern matching.</para>
+ <para>Trigger events for devices with a matching property
+ value. This option can be specified multiple times and
+ supports shell style pattern matching.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--tag-match=<replaceable>property</replaceable></option></term>
+ <term><option>-g</option></term>
+ <term><option>--tag-match=<replaceable>PROPERTY</replaceable></option></term>
<listitem>
- <para>Trigger events for devices with a matching tag. This option can be
- specified multiple times.</para>
+ <para>Trigger events for devices with a matching tag. This
+ option can be specified multiple times.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--sysname-match=<replaceable>name</replaceable></option></term>
+ <term><option>-y</option></term>
+ <term><option>--sysname-match=<replaceable>NAME</replaceable></option></term>
<listitem>
- <para>Trigger events for devices with a matching sys device name. This option can be
- specified multiple times and supports shell style pattern matching.</para>
+ <para>Trigger events for devices with a matching sys
+ device name. This option can be specified multiple times
+ and supports shell style pattern matching.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--parent-match=<replaceable>syspath</replaceable></option></term>
+ <term><option>-b</option></term>
+ <term><option>--parent-match=<replaceable>SYSPATH</replaceable></option></term>
<listitem>
- <para>Trigger events for all children of a given device.</para>
+ <para>Trigger events for all children of a given
+ device.</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>-h</option></term>
+ <term><option>--help</option></term>
+ <listitem>
+ <para>Print help text.</para>
</listitem>
</varlistentry>
</variablelist>
@@ -287,38 +329,46 @@
<para>Watches the udev event queue, and exits if all current events are handled.</para>
<variablelist>
<varlistentry>
- <term><option>--timeout=<replaceable>seconds</replaceable></option></term>
+ <term><option>-t</option></term>
+ <term><option>--timeout=<replaceable>SECONDS</replaceable></option></term>
<listitem>
- <para>Maximum number of seconds to wait for the event queue to become empty.
- The default value is 120 seconds. A value of 0 will check if the queue is empty
- and always return immediately.</para>
+ <para>Maximum number of seconds to wait for the event
+ queue to become empty. The default value is 120 seconds. A
+ value of 0 will check if the queue is empty and always
+ return immediately.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--seq-start=<replaceable>seqnum</replaceable></option></term>
+ <term><option>-s</option></term>
+ <term><option>--seq-start=<replaceable>SEQNUM</replaceable></option></term>
<listitem>
- <para>Wait only for events after the given sequence number.</para>
+ <para>Wait only for events after the given sequence
+ number.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--seq-end=<replaceable>seqnum</replaceable></option></term>
+ <term><option>-e</option></term>
+ <term><option>--seq-end=<replaceable>SEQNUM</replaceable></option></term>
<listitem>
<para>Wait only for events before the given sequence number.</para>
</listitem>
</varlistentry>
<varlistentry>
- <term><option>--exit-if-exists=<replaceable>file</replaceable></option></term>
+ <term><option>-E</option></term>
+ <term><option>--exit-if-exists=<replaceable>FILE</replaceable></option></term>
<listitem>
<para>Stop waiting if file exists.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-q</option></term>
<term><option>--quiet</option></term>
<listitem>
<para>Do not print any output, like the remaining queue entries when reaching the timeout.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -331,12 +381,14 @@
<para>Modify the internal state of the running udev daemon.</para>
<variablelist>
<varlistentry>
+ <term><option>-x</option></term>
<term><option>--exit</option></term>
<listitem>
<para>Signal and wait for systemd-udevd to exit.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-l</option></term>
<term><option>--log-priority=<replaceable>value</replaceable></option></term>
<listitem>
<para>Set the internal log level of systemd-udevd. Valid values are the numerical
@@ -345,6 +397,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-s</option></term>
<term><option>--stop-exec-queue</option></term>
<listitem>
<para>Signal systemd-udevd to stop executing new events. Incoming events
@@ -352,12 +405,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-S</option></term>
<term><option>--start-exec-queue</option></term>
<listitem>
<para>Signal systemd-udevd to enable the execution of events.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-R</option></term>
<term><option>--reload</option></term>
<listitem>
<para>Signal systemd-udevd to reload the rules files and other databases like the kernel
@@ -366,12 +421,14 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-p</option></term>
<term><option>--property=<replaceable>KEY</replaceable>=<replaceable>value</replaceable></option></term>
<listitem>
<para>Set a global property for all events.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-m</option></term>
<term><option>--children-max=</option><replaceable>value</replaceable></term>
<listitem>
<para>Set the maximum number of events, systemd-udevd will handle at the
@@ -385,6 +442,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -400,36 +458,42 @@
</para>
<variablelist>
<varlistentry>
+ <term><option>-k</option></term>
<term><option>--kernel</option></term>
<listitem>
<para>Print the kernel uevents.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-u</option></term>
<term><option>--udev</option></term>
<listitem>
<para>Print the udev event after the rule processing.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-p</option></term>
<term><option>--property</option></term>
<listitem>
<para>Also print the properties of the event.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-s</option></term>
<term><option>--subsystem-match=<replaceable>string[/string]</replaceable></option></term>
<listitem>
<para>Filter events by subsystem[/devtype]. Only udev events with a matching subsystem value will pass.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-t</option></term>
<term><option>--tag-match=<replaceable>string</replaceable></option></term>
<listitem>
<para>Filter events by property. Only udev events with a given tag attached will pass.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -442,6 +506,7 @@
<para>Maintain the hardware database index in <filename>/etc/udev/hwdb.bin</filename>.</para>
<variablelist>
<varlistentry>
+ <term><option>-u</option></term>
<term><option>--update</option></term>
<listitem>
<para>Compile the hardware database information located in /usr/lib/udev/hwdb.d/,
@@ -452,6 +517,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-t</option></term>
<term><option>--test=<replaceable>string</replaceable></option></term>
<listitem>
<para>Query the database with a modalias string, and print the
@@ -459,11 +525,19 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-r</option></term>
<term><option>--root=<replaceable>string</replaceable></option></term>
<listitem>
<para>Alternative root path in the filesystem for reading and writing files.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-h</option></term>
+ <term><option>--help</option></term>
+ <listitem>
+ <para>Print help text.</para>
+ </listitem>
+ </varlistentry>
</variablelist>
</refsect2>
@@ -471,12 +545,14 @@
<para>Simulate a udev event run for the given device, and print debug output.</para>
<variablelist>
<varlistentry>
+ <term><option>-a</option></term>
<term><option>--action=<replaceable>string</replaceable></option></term>
<listitem>
<para>The action string.</para>
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-N</option></term>
<term><option>--resolve-names=<constant>early</constant>|<constant>late</constant>|<constant>never</constant></option></term>
<listitem>
<para>Specify when udevadm should resolve names of users
@@ -489,6 +565,7 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
@@ -497,10 +574,13 @@
</variablelist>
</refsect2>
- <refsect2><title>udevadm test-builtin <optional>options</optional> <replaceable>command</replaceable> <replaceable>devpath</replaceable></title>
- <para>Run a built-in command for the given device, and print debug output.</para>
+ <refsect2><title>udevadm test-builtin <optional>options</optional> <replaceable>COMMAND</replaceable> <replaceable>DEVPATH</replaceable></title>
+ <para>Run a built-in command <replaceable>COMMAND</replaceable>
+ for device <replaceable>DEVPATH</replaceable>, and print debug
+ output.</para>
<variablelist>
<varlistentry>
+ <term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<para>Print help text.</para>
diff --git a/src/udev/scsi_id/scsi_id.c b/src/udev/scsi_id/scsi_id.c
index f005638463..6a4cf0c09e 100644
--- a/src/udev/scsi_id/scsi_id.c
+++ b/src/udev/scsi_id/scsi_id.c
@@ -44,7 +44,7 @@ static const struct option options[] = {
{ "replace-whitespace", no_argument, NULL, 'u' },
{ "sg-version", required_argument, NULL, 's' },
{ "verbose", no_argument, NULL, 'v' },
- { "version", no_argument, NULL, 'V' },
+ { "version", no_argument, NULL, 'V' }, /* don't advertise -V */
{ "export", no_argument, NULL, 'x' },
{ "help", no_argument, NULL, 'h' },
{}
@@ -313,6 +313,22 @@ static int get_file_options(struct udev *udev,
return retval;
}
+static void help(void) {
+ printf("Usage: scsi_id [OPTION...] DEVICE\n"
+ " -d,--device= device node for SG_IO commands\n"
+ " -f,--config= location of config file\n"
+ " -p,--page=0x80|0x83|pre-spc3-83 SCSI page (0x80, 0x83, pre-spc3-83)\n"
+ " -s,--sg-version=3|4 use SGv3 or SGv4\n"
+ " -b,--blacklisted threat device as blacklisted\n"
+ " -g,--whitelisted threat device as whitelisted\n"
+ " -u,--replace-whitespace replace all whitespace by underscores\n"
+ " -v,--verbose verbose logging\n"
+ " --version print version\n"
+ " -x,--export print values as environment keys\n"
+ " -h,--help print this help text\n\n");
+
+}
+
static int set_options(struct udev *udev,
int argc, char **argv,
char *maj_min_dev)
@@ -325,7 +341,7 @@ static int set_options(struct udev *udev,
* file) we have to reset this back to 1.
*/
optind = 1;
- while ((option = getopt_long(argc, argv, "d:f:ghp:uvVx", options, NULL)) >= 0)
+ while ((option = getopt_long(argc, argv, "d:f:gp:uvVxh", options, NULL)) >= 0)
switch (option) {
case 'b':
all_good = false;
@@ -345,18 +361,7 @@ static int set_options(struct udev *udev,
break;
case 'h':
- printf("Usage: scsi_id [OPTION...] DEVICE\n"
- " --device= device node for SG_IO commands\n"
- " --config= location of config file\n"
- " --page=0x80|0x83|pre-spc3-83 SCSI page (0x80, 0x83, pre-spc3-83)\n"
- " --sg-version=3|4 use SGv3 or SGv4\n"
- " --blacklisted threat device as blacklisted\n"
- " --whitelisted threat device as whitelisted\n"
- " --replace-whitespace replace all whitespace by underscores\n"
- " --verbose verbose logging\n"
- " --version print version\n"
- " --export print values as environment keys\n"
- " --help print this help text\n\n");
+ help();
exit(0);
case 'p':
diff --git a/src/udev/udevadm-control.c b/src/udev/udevadm-control.c
index c5a189257d..00a909fc31 100644
--- a/src/udev/udevadm-control.c
+++ b/src/udev/udevadm-control.c
@@ -30,35 +30,35 @@
static void print_help(void)
{
printf("Usage: udevadm control COMMAND\n"
- " --exit instruct the daemon to cleanup and exit\n"
- " --log-priority=<level> set the udev log level for the daemon\n"
- " --stop-exec-queue do not execute events, queue only\n"
- " --start-exec-queue execute events, flush queue\n"
- " --reload reload rules and databases\n"
- " --property=<KEY>=<value> set a global property for all events\n"
- " --children-max=<N> maximum number of children\n"
- " --timeout=<seconds> maximum time to block for a reply\n"
- " --help print this help text\n\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"
+ " -S,--start-exec-queue execute events, flush queue\n"
+ " -R,--reload reload rules and databases\n"
+ " -p,--property=KEY=VALUE set a global property for all events\n"
+ " -m,--children-max=N maximum number of children\n"
+ " --timeout=SECONDS maximum time to block for a reply\n"
+ " -h,--help print this help text\n\n");
}
static int adm_control(struct udev *udev, int argc, char *argv[])
{
struct udev_ctrl *uctrl = NULL;
int timeout = 60;
- int rc = 1;
+ int rc = 1, c;
static const struct option options[] = {
- { "exit", no_argument, NULL, 'e' },
- { "log-priority", required_argument, NULL, 'l' },
- { "stop-exec-queue", no_argument, NULL, 's' },
- { "start-exec-queue", no_argument, NULL, 'S' },
- { "reload", no_argument, NULL, 'R' },
- { "reload-rules", no_argument, NULL, 'R' },
- { "property", required_argument, NULL, 'p' },
- { "env", required_argument, NULL, 'p' },
- { "children-max", required_argument, NULL, 'm' },
- { "timeout", required_argument, NULL, 't' },
- { "help", no_argument, NULL, 'h' },
+ { "exit", no_argument, NULL, 'e' },
+ { "log-priority", required_argument, NULL, 'l' },
+ { "stop-exec-queue", no_argument, NULL, 's' },
+ { "start-exec-queue", no_argument, NULL, 'S' },
+ { "reload", no_argument, NULL, 'R' },
+ { "reload-rules", no_argument, NULL, 'R' }, /* alias for -R */
+ { "property", required_argument, NULL, 'p' },
+ { "env", required_argument, NULL, 'p' }, /* alias for -p */
+ { "children-max", required_argument, NULL, 'm' },
+ { "timeout", required_argument, NULL, 't' },
+ { "help", no_argument, NULL, 'h' },
{}
};
@@ -71,14 +71,8 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
if (uctrl == NULL)
return 2;
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while ((c = getopt_long(argc, argv, "el:sSRp:m:h", options, NULL)) >= 0)
+ switch (c) {
case 'e':
if (udev_ctrl_send_exit(uctrl, timeout) < 0)
rc = 2;
@@ -157,12 +151,11 @@ static int adm_control(struct udev *udev, int argc, char *argv[])
rc = 0;
break;
}
- }
- if (argv[optind] != NULL)
- fprintf(stderr, "unknown option\n");
+ if (optind < argc)
+ fprintf(stderr, "Extraneous argument: %s\n", argv[optind]);
else if (optind == 1)
- fprintf(stderr, "missing option\n");
+ fprintf(stderr, "Option missing\n");
out:
udev_ctrl_unref(uctrl);
return rc;
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index d0cce84859..61a3b08199 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -526,35 +526,29 @@ static int import_file(struct udev *udev, struct trie *trie, const char *filenam
static void help(void) {
printf("Usage: udevadm hwdb OPTIONS\n"
- " --update update the hardware database\n"
- " --test=<modalias> query database and print result\n"
- " --root=<path> alternative root path in the filesystem\n"
- " --help\n\n");
+ " -u,--update update the hardware database\n"
+ " -t,--test=MODALIAS query database and print result\n"
+ " -r,--root=PATH alternative root path in the filesystem\n"
+ " -h,--help\n\n");
}
static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
static const struct option options[] = {
- { "update", no_argument, NULL, 'u' },
- { "root", required_argument, NULL, 'r' },
- { "test", required_argument, NULL, 't' },
- { "help", no_argument, NULL, 'h' },
+ { "update", no_argument, NULL, 'u' },
+ { "test", required_argument, NULL, 't' },
+ { "root", required_argument, NULL, 'r' },
+ { "help", no_argument, NULL, 'h' },
{}
};
const char *test = NULL;
const char *root = "";
bool update = false;
struct trie *trie = NULL;
- int err;
+ int err, c;
int rc = EXIT_SUCCESS;
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "ut:r:h", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while ((c = getopt_long(argc, argv, "ut:r:h", options, NULL)) >= 0)
+ switch(c) {
case 'u':
update = true;
break;
@@ -567,12 +561,15 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
case 'h':
help();
return EXIT_SUCCESS;
+ case '?':
+ return EXIT_FAILURE;
+ default:
+ assert_not_reached("Unknown option");
}
- }
if (!update && !test) {
- help();
- return EXIT_SUCCESS;
+ log_error("Either --update or --test must be used");
+ return EXIT_FAILURE;
}
if (update) {
diff --git a/src/udev/udevadm-info.c b/src/udev/udevadm-info.c
index 2ee59fe075..2d2cf4336e 100644
--- a/src/udev/udevadm-info.c
+++ b/src/udev/udevadm-info.c
@@ -302,43 +302,44 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
const char *export_prefix = NULL;
char name[UTIL_PATH_SIZE];
struct udev_list_entry *list_entry;
- int rc = 0;
+ int rc = 0, c;
static const struct option options[] = {
- { "name", required_argument, NULL, 'n' },
- { "path", required_argument, NULL, 'p' },
- { "query", required_argument, NULL, 'q' },
- { "attribute-walk", no_argument, NULL, 'a' },
- { "cleanup-db", no_argument, NULL, 'c' },
- { "export-db", no_argument, NULL, 'e' },
- { "root", no_argument, NULL, 'r' },
+ { "name", required_argument, NULL, 'n' },
+ { "path", required_argument, NULL, 'p' },
+ { "query", required_argument, NULL, 'q' },
+ { "attribute-walk", no_argument, NULL, 'a' },
+ { "cleanup-db", no_argument, NULL, 'c' },
+ { "export-db", no_argument, NULL, 'e' },
+ { "root", no_argument, NULL, 'r' },
{ "device-id-of-file", required_argument, NULL, 'd' },
- { "export", no_argument, NULL, 'x' },
- { "export-prefix", required_argument, NULL, 'P' },
- { "version", no_argument, NULL, 'V' },
- { "help", no_argument, NULL, 'h' },
+ { "export", no_argument, NULL, 'x' },
+ { "export-prefix", required_argument, NULL, 'P' },
+ { "version", no_argument, NULL, 'V' },
+ { "help", no_argument, NULL, 'h' },
{}
};
static const char *usage =
- "Usage: udevadm info OPTIONS\n"
- " --query=<type> query device information:\n"
+ "Usage: udevadm info [OPTIONS] [DEVPATH|FILE]\n"
+ " -q,--query=TYPE query device information:\n"
" name name of device node\n"
" symlink pointing to node\n"
" path sys device path\n"
" property the device properties\n"
" all all values\n"
- " --path=<syspath> sys device path used for query or attribute walk\n"
- " --name=<name> node or symlink name used for query or attribute walk\n"
- " --root prepend dev directory to path names\n"
- " --attribute-walk print all key matches while walking along the chain\n"
+ " -p,--path=SYSPATH sys device path used for query or attribute walk\n"
+ " -n,--name=NAME node or symlink name used for query or attribute walk\n"
+ " -r,--root prepend dev directory to path names\n"
+ " -a,--attribute-walk print all key matches walking along the chain\n"
" of parent devices\n"
- " --device-id-of-file=<file> print major:minor of device containing this file\n"
- " --export export key/value pairs\n"
- " --export-prefix export the key name with a prefix\n"
- " --export-db export the content of the udev database\n"
- " --cleanup-db cleanup the udev database\n"
- " --help\n";
+ " -d,--device-id-of-file=FILE print major:minor of device containing this file\n"
+ " -x,--export export key/value pairs\n"
+ " -P,--export-prefix export the key name with a prefix\n"
+ " -e,--export-db export the content of the udev database\n"
+ " -c,--cleanup-db cleanup the udev database\n"
+ " --version print version of the program\n"
+ " -h,--help print this message\n";
enum action_type {
ACTION_QUERY,
@@ -354,14 +355,8 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
QUERY_ALL,
} query = QUERY_ALL;
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "aced:n:p:q:rxP:RVh", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while ((c = getopt_long(argc, argv, "aced:n:p:q:rxP:RVh", options, NULL)) >= 0)
+ switch (c) {
case 'n': {
if (device != NULL) {
fprintf(stderr, "device already specified\n");
@@ -441,7 +436,6 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
rc = 1;
goto exit;
}
- }
switch (action) {
case ACTION_QUERY:
diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c
index 4d6af49b96..2c200b7068 100644
--- a/src/udev/udevadm-monitor.c
+++ b/src/udev/udevadm-monitor.c
@@ -64,6 +64,16 @@ static void print_device(struct udev_device *device, const char *source, int pro
}
}
+static void help(void) {
+ printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
+ " -p,--property print the event properties\n"
+ " -k,--kernel print kernel uevents\n"
+ " -u,--udev print udev events\n"
+ " -s,--subsystem-match=SUBSYSTEM[/DEVTYPE] filter events by subsystem\n"
+ " -t,--tag-match=TAG filter events by tag\n"
+ " -h,--help\n\n");
+}
+
static int adm_monitor(struct udev *udev, int argc, char *argv[])
{
struct sigaction act = {};
@@ -79,28 +89,24 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
int fd_ep = -1;
int fd_kernel = -1, fd_udev = -1;
struct epoll_event ep_kernel, ep_udev;
- int rc = 0;
+ int rc = 0, c;
static const struct option options[] = {
- { "property", no_argument, NULL, 'p' },
- { "environment", no_argument, NULL, 'e' },
- { "kernel", no_argument, NULL, 'k' },
- { "udev", no_argument, NULL, 'u' },
+ { "property", no_argument, NULL, 'p' },
+ { "environment", no_argument, NULL, 'e' }, /* alias for -p */
+ { "kernel", no_argument, NULL, 'k' },
+ { "udev", no_argument, NULL, 'u' },
{ "subsystem-match", required_argument, NULL, 's' },
- { "tag-match", required_argument, NULL, 't' },
- { "help", no_argument, NULL, 'h' },
+ { "tag-match", required_argument, NULL, 't' },
+ { "help", no_argument, NULL, 'h' },
{}
};
udev_list_init(udev, &subsystem_match_list, true);
udev_list_init(udev, &tag_match_list, true);
- for (;;) {
- option = getopt_long(argc, argv, "pekus:t:h", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while((c = getopt_long(argc, argv, "pekus:t:h", options, NULL)) >= 0)
+ switch (c) {
case 'p':
case 'e':
prop = true;
@@ -129,19 +135,12 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[])
udev_list_entry_add(&tag_match_list, optarg, NULL);
break;
case 'h':
- printf("Usage: udevadm monitor [--property] [--kernel] [--udev] [--help]\n"
- " --property print the event properties\n"
- " --kernel print kernel uevents\n"
- " --udev print udev events\n"
- " --subsystem-match=<subsystem[/devtype]> filter events by subsystem\n"
- " --tag-match=<tag> filter events by tag\n"
- " --help\n\n");
+ help();
goto out;
default:
rc = 1;
goto out;
}
- }
if (!print_kernel && !print_udev) {
print_kernel = true;
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
index 1468f0358f..362c3b2f98 100644
--- a/src/udev/udevadm-settle.c
+++ b/src/udev/udevadm-settle.c
@@ -37,15 +37,25 @@
#include "udev.h"
#include "util.h"
+static void help(void) {
+ printf("Usage: udevadm settle OPTIONS\n"
+ " -t,--timeout=<seconds> maximum time to wait for events\n"
+ " -s,--seq-start=<seqnum> first seqnum to wait for\n"
+ " -e,--seq-end=<seqnum> last seqnum to wait for\n"
+ " -E,--exit-if-exists=<file> stop waiting if file exists\n"
+ " -q,--quiet do not print list after timeout\n"
+ " -h,--help\n\n");
+}
+
static int adm_settle(struct udev *udev, int argc, char *argv[])
{
static const struct option options[] = {
- { "seq-start", required_argument, NULL, 's' },
- { "seq-end", required_argument, NULL, 'e' },
- { "timeout", required_argument, NULL, 't' },
+ { "seq-start", required_argument, NULL, 's' },
+ { "seq-end", required_argument, NULL, 'e' },
+ { "timeout", required_argument, NULL, 't' },
{ "exit-if-exists", required_argument, NULL, 'E' },
- { "quiet", no_argument, NULL, 'q' },
- { "help", no_argument, NULL, 'h' },
+ { "quiet", no_argument, NULL, 'q' },
+ { "help", no_argument, NULL, 'h' },
{}
};
usec_t start_usec = now(CLOCK_MONOTONIC);
@@ -56,21 +66,10 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
unsigned int timeout = 120;
struct pollfd pfd[1] = { {.fd = -1}, };
struct udev_queue *udev_queue = NULL;
- int rc = EXIT_FAILURE;
-
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL);
- if (option == -1) {
- if (optind < argc) {
- fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
- exit(EXIT_FAILURE);
- }
- break;
- }
+ int rc = EXIT_FAILURE, c;
- switch (option) {
+ while ((c = getopt_long(argc, argv, "s:e:t:E:qh", options, NULL)) >= 0)
+ switch (c) {
case 's':
start = strtoull(optarg, NULL, 0);
break;
@@ -87,25 +86,25 @@ static int adm_settle(struct udev *udev, int argc, char *argv[])
exit(EXIT_FAILURE);
};
break;
- };
- case 'q':
- quiet = 1;
- break;
+ }
case 'E':
exists = optarg;
break;
+ case 'q':
+ quiet = 1;
+ break;
case 'h':
- printf("Usage: udevadm settle OPTIONS\n"
- " --timeout=<seconds> maximum time to wait for events\n"
- " --seq-start=<seqnum> first seqnum to wait for\n"
- " --seq-end=<seqnum> last seqnum to wait for\n"
- " --exit-if-exists=<file> stop waiting if file exists\n"
- " --quiet do not print list after timeout\n"
- " --help\n\n");
+ help();
exit(EXIT_SUCCESS);
- default:
+ case '?':
exit(EXIT_FAILURE);
+ default:
+ assert_not_reached("Unkown argument");
}
+
+ if (optind < argc) {
+ fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
+ exit(EXIT_FAILURE);
}
udev_queue = udev_queue_new(udev);
diff --git a/src/udev/udevadm-test-builtin.c b/src/udev/udevadm-test-builtin.c
index f4aa21ee72..80418783ff 100644
--- a/src/udev/udevadm-test-builtin.c
+++ b/src/udev/udevadm-test-builtin.c
@@ -37,7 +37,7 @@
static void help(struct udev *udev)
{
fprintf(stderr, "\n");
- fprintf(stderr, "Usage: udevadm builtin [--help] <command> <syspath>\n");
+ fprintf(stderr, "Usage: udevadm builtin [--help] COMMAND SYSPATH\n");
udev_builtin_list(udev);
fprintf(stderr, "\n");
}
@@ -53,21 +53,14 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[])
char filename[UTIL_PATH_SIZE];
struct udev_device *dev = NULL;
enum udev_builtin_cmd cmd;
- int rc = EXIT_SUCCESS;
+ int rc = EXIT_SUCCESS, c;
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "h", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while ((c = getopt_long(argc, argv, "h", options, NULL)) >= 0)
+ switch (c) {
case 'h':
help(udev);
goto out;
}
- }
command = argv[optind++];
if (command == NULL) {
@@ -79,7 +72,7 @@ static int adm_builtin(struct udev *udev, int argc, char *argv[])
syspath = argv[optind++];
if (syspath == NULL) {
- fprintf(stderr, "syspath missing\n\n");
+ fprintf(stderr, "syspath missing\n");
rc = 3;
goto out;
}
diff --git a/src/udev/udevadm-test.c b/src/udev/udevadm-test.c
index df1409bff6..cd75fad674 100644
--- a/src/udev/udevadm-test.c
+++ b/src/udev/udevadm-test.c
@@ -43,7 +43,7 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
struct udev_list_entry *entry;
sigset_t mask, sigmask_orig;
int err;
- int rc = 0;
+ int rc = 0, c;
static const struct option options[] = {
{ "action", required_argument, NULL, 'a' },
@@ -54,14 +54,8 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
log_debug("version %s\n", VERSION);
- for (;;) {
- int option;
-
- option = getopt_long(argc, argv, "a:s:N:fh", options, NULL);
- if (option == -1)
- break;
-
- switch (option) {
+ while((c = getopt_long(argc, argv, "a:N:h", options, NULL)) >= 0)
+ switch (c) {
case 'a':
action = optarg;
break;
@@ -80,15 +74,18 @@ static int adm_test(struct udev *udev, int argc, char *argv[])
break;
case 'h':
printf("Usage: udevadm test OPTIONS <syspath>\n"
- " --action=<string> set action string\n"
- " --help\n\n");
+ " -a,--action=ACTION set action string\n"
+ " -N,--resolve-names=early|late|never when to resolve names\n"
+ " -h,--help print this help string\n"
+ "\n");
exit(EXIT_SUCCESS);
- default:
+ case '?':
exit(EXIT_FAILURE);
+ default:
+ assert_not_reached("Unknown option");
}
- }
- syspath = argv[optind];
+ syspath = argv[optind];
if (syspath == NULL) {
fprintf(stderr, "syspath parameter missing\n");
rc = 2;
diff --git a/src/udev/udevadm-trigger.c b/src/udev/udevadm-trigger.c
index d10ca59cca..3608c35cd0 100644
--- a/src/udev/udevadm-trigger.c
+++ b/src/udev/udevadm-trigger.c
@@ -73,22 +73,41 @@ static const char *keyval(const char *str, const char **val, char *buf, size_t s
return buf;
}
+static void help(void) {
+ printf("Usage: udevadm trigger OPTIONS\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"
+ " devices sys devices (default)\n"
+ " subsystems sys subsystems and drivers\n"
+ " -c,--action=<action> event action value, default is \"change\"\n"
+ " -s,--subsystem-match=<subsystem> trigger devices from a matching subsystem\n"
+ " -S,--subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n"
+ " -a,--attr-match=<file[=<value>]> trigger devices with a matching attribute\n"
+ " -A,--attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n"
+ " -p,--property-match=<key>=<value> trigger devices with a matching property\n"
+ " -g,--tag-match=<key>=<value> trigger devices with a matching property\n"
+ " -y,--sysname-match=<name> trigger devices with a matching name\n"
+ " -b,--parent-match=<name> trigger devices with that parent device\n"
+ " -h,--help\n\n");
+}
+
static int adm_trigger(struct udev *udev, int argc, char *argv[])
{
static const struct option options[] = {
- { "verbose", no_argument, NULL, 'v' },
- { "dry-run", no_argument, NULL, 'n' },
- { "type", required_argument, NULL, 't' },
- { "action", required_argument, NULL, 'c' },
- { "subsystem-match", required_argument, NULL, 's' },
+ { "verbose", no_argument, NULL, 'v' },
+ { "dry-run", no_argument, NULL, 'n' },
+ { "type", required_argument, NULL, 't' },
+ { "action", required_argument, NULL, 'c' },
+ { "subsystem-match", required_argument, NULL, 's' },
{ "subsystem-nomatch", required_argument, NULL, 'S' },
- { "attr-match", required_argument, NULL, 'a' },
- { "attr-nomatch", required_argument, NULL, 'A' },
- { "property-match", required_argument, NULL, 'p' },
- { "tag-match", required_argument, NULL, 'g' },
- { "sysname-match", required_argument, NULL, 'y' },
- { "parent-match", required_argument, NULL, 'b' },
- { "help", no_argument, NULL, 'h' },
+ { "attr-match", required_argument, NULL, 'a' },
+ { "attr-nomatch", required_argument, NULL, 'A' },
+ { "property-match", required_argument, NULL, 'p' },
+ { "tag-match", required_argument, NULL, 'g' },
+ { "sysname-match", required_argument, NULL, 'y' },
+ { "parent-match", required_argument, NULL, 'b' },
+ { "help", no_argument, NULL, 'h' },
{}
};
enum {
@@ -98,6 +117,7 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
const char *action = "change";
struct udev_enumerate *udev_enumerate;
int rc = 0;
+ int c;
udev_enumerate = udev_enumerate_new(udev);
if (udev_enumerate == NULL) {
@@ -105,23 +125,12 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
goto exit;
}
- for (;;) {
- int option;
+ while ((c = getopt_long(argc, argv, "vno:t:c:s:S:a:A:p:g:y:b:h", options, NULL)) >= 0) {
const char *key;
const char *val;
char buf[UTIL_PATH_SIZE];
- option = getopt_long(argc, argv, "vng:o:t:hc:p:s:S:a:A:y:b:", options, NULL);
- if (option == -1) {
- if (optind < argc) {
- fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
- rc = 1;
- goto exit;
- }
- break;
- }
-
- switch (option) {
+ switch (c) {
case 'v':
verbose = 1;
break;
@@ -194,29 +203,21 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
break;
}
case 'h':
- printf("Usage: udevadm trigger OPTIONS\n"
- " --verbose print the list of devices while running\n"
- " --dry-run do not actually trigger the events\n"
- " --type= type of events to trigger\n"
- " devices sys devices (default)\n"
- " subsystems sys subsystems and drivers\n"
- " --action=<action> event action value, default is \"change\"\n"
- " --subsystem-match=<subsystem> trigger devices from a matching subsystem\n"
- " --subsystem-nomatch=<subsystem> exclude devices from a matching subsystem\n"
- " --attr-match=<file[=<value>]> trigger devices with a matching attribute\n"
- " --attr-nomatch=<file[=<value>]> exclude devices with a matching attribute\n"
- " --property-match=<key>=<value> trigger devices with a matching property\n"
- " --tag-match=<key>=<value> trigger devices with a matching property\n"
- " --sysname-match=<name> trigger devices with a matching name\n"
- " --parent-match=<name> trigger devices with that parent device\n"
- " --help\n\n");
+ help();
goto exit;
- default:
+ case '?':
rc = 1;
goto exit;
+ default:
+ assert_not_reached("Unknown option");
}
}
+ if (optind < argc) {
+ fprintf(stderr, "Extraneous argument: '%s'\n", argv[optind]);
+ return 1;
+ }
+
switch (device_type) {
case TYPE_SUBSYSTEMS:
udev_enumerate_scan_subsystems(udev_enumerate);