chiark / gitweb /
udevadm,scsi_id: add short options to help strings and to the man page
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Wed, 18 Dec 2013 02:48:14 +0000 (21:48 -0500)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Thu, 19 Dec 2013 04:58:23 +0000 (23:58 -0500)
Also clean things up a bit here and there.

man/udevadm.xml
src/udev/scsi_id/scsi_id.c
src/udev/udevadm-control.c
src/udev/udevadm-hwdb.c
src/udev/udevadm-info.c
src/udev/udevadm-monitor.c
src/udev/udevadm-settle.c
src/udev/udevadm-test-builtin.c
src/udev/udevadm-test.c
src/udev/udevadm-trigger.c

index 30a6ac4..6fc4e8d 100644 (file)
@@ -82,6 +82,7 @@
         </listitem>
       </varlistentry>
       <varlistentry>
         </listitem>
       </varlistentry>
       <varlistentry>
+        <term><option>-h</option></term>
         <term><option>--help</option></term>
         <listitem>
           <para>Print help text.</para>
         <term><option>--help</option></term>
         <listitem>
           <para>Print help text.</para>
       </varlistentry>
     </variablelist>
 
       </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>
       <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
           <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>
             <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.
           <listitem>
             <para>The <filename>/sys</filename> path of the device to
             query, e.g.
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>.
           <listitem>
             <para>The name of the device node or a symlink to query,
             e.g. <filename><optional>/dev</optional>/sda</filename>.
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>
           <term><option>--root</option></term>
           <listitem>
             <para>Print absolute paths in <command>name</command> or <command>symlink</command>
           </listitem>
         </varlistentry>
         <varlistentry>
           </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
           <term><option>--attribute-walk</option></term>
           <listitem>
             <para>Print all sysfs properties of the specified device that can be used
           </listitem>
         </varlistentry>
         <varlistentry>
           </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</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>
           <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>
           <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>--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>
           <term><option>--cleanup-db</option></term>
           <listitem>
             <para>Cleanup the udev database.</para>
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
       <para>Request device events from the kernel. Primarily used to replay events at system coldplug time.</para>
       <variablelist>
         <varlistentry>
       <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>--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>--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>.
           <listitem>
             <para>Trigger a specific type of devices. Valid types are:
             <command>devices</command>, <command>subsystems</command>.
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>
           <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>
           </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>
           <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>
           </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>
           <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>
           <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>
           </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>
           <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>
           </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>
           <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>
           </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>
           <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>
           </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>
           <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>
           </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>
           <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>
           </listitem>
         </varlistentry>
       </variablelist>
       <para>Watches the udev event queue, and exits if all current events are handled.</para>
       <variablelist>
         <varlistentry>
       <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>
           <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>
           </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>
           <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>
           </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>
           <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>
           <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>--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>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
       <para>Modify the internal state of the running udev daemon.</para>
       <variablelist>
         <varlistentry>
       <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>--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
           <term><option>--log-priority=<replaceable>value</replaceable></option></term>
           <listitem>
             <para>Set the internal log level of systemd-udevd. Valid values are the numerical
           </listitem>
         </varlistentry>
         <varlistentry>
           </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
           <term><option>--stop-exec-queue</option></term>
           <listitem>
             <para>Signal systemd-udevd to stop executing new events. Incoming events
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>--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
           <term><option>--reload</option></term>
           <listitem>
             <para>Signal systemd-udevd to reload the rules files and other databases like the kernel
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>--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
           <term><option>--children-max=</option><replaceable>value</replaceable></term>
           <listitem>
             <para>Set the maximum number of events, systemd-udevd will handle at the
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
       </para>
       <variablelist>
         <varlistentry>
       </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>--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>--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>--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>--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>--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>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
       <para>Maintain the hardware database index in <filename>/etc/udev/hwdb.bin</filename>.</para>
       <variablelist>
         <varlistentry>
       <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/,
           <term><option>--update</option></term>
           <listitem>
             <para>Compile the hardware database information located in /usr/lib/udev/hwdb.d/,
           </listitem>
         </varlistentry>
         <varlistentry>
           </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
           <term><option>--test=<replaceable>string</replaceable></option></term>
           <listitem>
             <para>Query the database with a modalias string, and print the
           </listitem>
         </varlistentry>
         <varlistentry>
           </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>
           <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>
 
       </variablelist>
     </refsect2>
 
       <para>Simulate a udev event run for the given device, and print debug output.</para>
       <variablelist>
         <varlistentry>
       <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>--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
           <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
           </listitem>
         </varlistentry>
         <varlistentry>
           </listitem>
         </varlistentry>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
       </variablelist>
     </refsect2>
 
       </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>
       <variablelist>
         <varlistentry>
+          <term><option>-h</option></term>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
           <term><option>--help</option></term>
           <listitem>
             <para>Print help text.</para>
index f005638..6a4cf0c 100644 (file)
@@ -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' },
         { "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' },
         {}
         { "export",             no_argument,       NULL, 'x' },
         { "help",               no_argument,       NULL, 'h' },
         {}
@@ -313,6 +313,22 @@ static int get_file_options(struct udev *udev,
         return retval;
 }
 
         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)
 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;
          * 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;
                 switch (option) {
                 case 'b':
                         all_good = false;
@@ -345,18 +361,7 @@ static int set_options(struct udev *udev,
                         break;
 
                 case 'h':
                         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':
                         exit(0);
 
                 case 'p':
index c5a1892..00a909f 100644 (file)
 static void print_help(void)
 {
         printf("Usage: udevadm control COMMAND\n"
 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;
 }
 
 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[] = {
 
         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;
 
         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;
                 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;
                 }
                         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)
         else if (optind == 1)
-                fprintf(stderr, "missing option\n");
+                fprintf(stderr, "Option missing\n");
 out:
         udev_ctrl_unref(uctrl);
         return rc;
 out:
         udev_ctrl_unref(uctrl);
         return rc;
index d0cce84..61a3b08 100644 (file)
@@ -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"
 
 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[] = {
 }
 
 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;
                 {}
         };
         const char *test = NULL;
         const char *root = "";
         bool update = false;
         struct trie *trie = NULL;
-        int err;
+        int err, c;
         int rc = EXIT_SUCCESS;
 
         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;
                 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 'h':
                         help();
                         return EXIT_SUCCESS;
+                case '?':
+                        return EXIT_FAILURE;
+                default:
+                        assert_not_reached("Unknown option");
                 }
                 }
-        }
 
         if (!update && !test) {
 
         if (!update && !test) {
-                help();
-                return EXIT_SUCCESS;
+                log_error("Either --update or --test must be used");
+                return EXIT_FAILURE;
         }
 
         if (update) {
         }
 
         if (update) {
index 2ee59fe..2d2cf43 100644 (file)
@@ -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;
         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[] = {
 
         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' },
                 { "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 =
                 {}
         };
 
         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"
                 "      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"
                 "                             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,
 
         enum action_type {
                 ACTION_QUERY,
@@ -354,14 +355,8 @@ static int uinfo(struct udev *udev, int argc, char *argv[])
                 QUERY_ALL,
         } query = QUERY_ALL;
 
                 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");
                 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;
                 }
                         rc = 1;
                         goto exit;
                 }
-        }
 
         switch (action) {
         case ACTION_QUERY:
 
         switch (action) {
         case ACTION_QUERY:
index 4d6af49..2c200b7 100644 (file)
@@ -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 = {};
 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 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[] = {
 
         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' },
                 { "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);
 
                 {}
         };
 
         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;
                 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':
                         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;
                 }
                         goto out;
                 default:
                         rc = 1;
                         goto out;
                 }
-        }
 
         if (!print_kernel && !print_udev) {
                 print_kernel = true;
 
         if (!print_kernel && !print_udev) {
                 print_kernel = true;
index 1468f03..362c3b2 100644 (file)
 #include "udev.h"
 #include "util.h"
 
 #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[] = {
 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' },
                 { "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);
                 {}
         };
         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;
         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;
                 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;
                                 exit(EXIT_FAILURE);
                         };
                         break;
-                };
-                case 'q':
-                        quiet = 1;
-                        break;
+                }
                 case 'E':
                         exists = optarg;
                         break;
                 case 'E':
                         exists = optarg;
                         break;
+                case 'q':
+                        quiet = 1;
+                        break;
                 case 'h':
                 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);
                         exit(EXIT_SUCCESS);
-                default:
+                case '?':
                         exit(EXIT_FAILURE);
                         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);
         }
 
         udev_queue = udev_queue_new(udev);
index f4aa21e..8041878 100644 (file)
@@ -37,7 +37,7 @@
 static void help(struct udev *udev)
 {
         fprintf(stderr, "\n");
 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");
 }
         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;
         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;
                 }
                 case 'h':
                         help(udev);
                         goto out;
                 }
-        }
 
         command = argv[optind++];
         if (command == NULL) {
 
         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) {
 
         syspath = argv[optind++];
         if (syspath == NULL) {
-                fprintf(stderr, "syspath missing\n\n");
+                fprintf(stderr, "syspath missing\n");
                 rc = 3;
                 goto out;
         }
                 rc = 3;
                 goto out;
         }
index df1409b..cd75fad 100644 (file)
@@ -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;
         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' },
 
         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);
 
 
         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;
                 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"
                         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);
                         exit(EXIT_SUCCESS);
-                default:
+                case '?':
                         exit(EXIT_FAILURE);
                         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;
         if (syspath == NULL) {
                 fprintf(stderr, "syspath parameter missing\n");
                 rc = 2;
index d10ca59..3608c35 100644 (file)
@@ -73,22 +73,41 @@ static const char *keyval(const char *str, const char **val, char *buf, size_t s
         return buf;
 }
 
         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[] = {
 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' },
                 { "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 {
                 {}
         };
         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;
         const char *action = "change";
         struct udev_enumerate *udev_enumerate;
         int rc = 0;
+        int c;
 
         udev_enumerate = udev_enumerate_new(udev);
         if (udev_enumerate == NULL) {
 
         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;
         }
 
                 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];
 
                 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;
                 case 'v':
                         verbose = 1;
                         break;
@@ -194,29 +203,21 @@ static int adm_trigger(struct udev *udev, int argc, char *argv[])
                         break;
                 }
                 case 'h':
                         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;
                         goto exit;
-                default:
+                case '?':
                         rc = 1;
                         goto exit;
                         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);
         switch (device_type) {
         case TYPE_SUBSYSTEMS:
                 udev_enumerate_scan_subsystems(udev_enumerate);