chiark / gitweb /
udevinfo: use long options
authorKay Sievers <kay.sievers@suse.de>
Sun, 3 Sep 2006 02:05:20 +0000 (04:05 +0200)
committerKay Sievers <kay.sievers@suse.de>
Sun, 3 Sep 2006 02:05:20 +0000 (04:05 +0200)
udevinfo.8
udevinfo.c
udevinfo.xml

index 4430f5d9d30cd3f31a9f24ca7d26f8e00588a01b..01c90900313c0504bac1a299f938a428a50a9aec 100644 (file)
 udevinfo \- query device information from the udev database
 .SH "SYNOPSIS"
 .HP 9
-\fBudevinfo\fR [\fB\-q\ \fR\fB\fIquery\-type\fR\fR] [\fB\-a\ \fR] [\fB\-p\ \fR\fB\fIdevpath\fR\fR] [\fB\-n\ \fR\fB\fInode\fR\fR] [\fB\-r\fR] [\fB\-e\fR] [\fB\-V\fR] [\fB\-h\fR]
+\fBudevinfo\fR [\fB\-\-query=\fR\fB\fIquery\-type\fR\fR] [\fB\-\-attribute\-walk\fR] [\fB\-\-path=\fR\fB\fIdevpath\fR\fR] [\fB\-\-name=\fR\fB\fInode\fR\fR] [\fB\-\-root\fR] [\fB\-\-export\-db\fR] [\fB\-\-version\fR] [\fB\-\-help\fR]
 .SH "DESCRIPTION"
 .PP
 udevinfo 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.
 .SH "OPTIONS"
 .TP 3n
-\fB\-q\fR
+\fB\-\-query=\fR\fB\fItype\fR\fR
 Query the database for specified type of device data. It needs the
-\fB\-p\fR
+\fB\-\-path\fR
 or
-\fB\-n\fR
+\fB\-\-name\fR
 to identify the specified device. Valid queries are:
 \fBname\fR,
 \fBsymlink\fR,
@@ -32,27 +32,27 @@ to identify the specified device. Valid queries are:
 \fBenv\fR,
 \fBall\fR.
 .TP 3n
-\fB\-a\fR
-Print all sysfs properties of the specified device that can be used in udev rules to match the specified device. It prints all devices along the chain, up to the root of sysfs that can be used in udev rules.
-.TP 3n
-\fB\-p \fR\fB\fIdevpath\fR\fR
+\fB\-\-path=\fR\fB\fIdevpath\fR\fR
 The devpath of the device to query.
 .TP 3n
-\fB\-\fR\fB\fInode\fR\fR
+\fB\-\-name=\fR\fB\fInode\fR\fR
 The name of the device node or a symlink to query
 .TP 3n
-\fB\-r\fR
+\fB\-\-root\fR
 The udev root directory:
 \fI/dev\fR. If used in conjunction with a
 \fBname\fR
 or
 \fBsymlink\fR
-query, the query returns the absolute path.
+query, the query returns the absolute path including the root directory.
+.TP 3n
+\fB\-\-attribute\-walk\fR
+Print all sysfs properties of the specified device that can be used in udev rules to match the specified device. It prints all devices along the chain, up to the root of sysfs that can be used in udev rules.
 .TP 3n
-\fB\-e\fR
+\fB\-\-export\fR
 Export the content of the udev database.
 .TP 3n
-\fB\-h\fR
+\fB\-\-help\fR
 Print help text.
 .SH "AUTHOR"
 .PP
index 3146a96119e73826550b528f8061b12aacec4770..d1d77152c3ffed3ad82bc4eb305a8508d84c8a06 100644 (file)
@@ -25,6 +25,7 @@
 #include <unistd.h>
 #include <dirent.h>
 #include <errno.h>
+#include <getopt.h>
 
 #include "udev.h"
 
@@ -167,6 +168,18 @@ int main(int argc, char *argv[], char *envp[])
        struct udevice *udev;
        int root = 0;
 
+       struct option options[] = {
+               { "name", 1, NULL, 'n' },
+               { "path", 1, NULL, 'p' },
+               { "query", 1, NULL, 'q' },
+               { "attribute-walk", 0, NULL, 'a' },
+               { "export-db", 0, NULL, 'e' },
+               { "root", 0, NULL, 'r' },
+               { "version", 0, NULL, 'V' },
+               { "help", 0, NULL, 'h' },
+               {}
+       };
+
        enum action_type {
                ACTION_NONE,
                ACTION_QUERY,
@@ -199,9 +212,8 @@ int main(int argc, char *argv[], char *envp[])
        }
 
        /* get command line options */
-       opterr = 0;
        while (1) {
-               option = getopt(argc, argv, ":aden:p:q:rVh");
+               option = getopt_long(argc, argv, "aden:p:q:rVh", options, NULL);
                if (option == -1)
                        break;
 
@@ -267,30 +279,25 @@ int main(int argc, char *argv[], char *envp[])
                        printf("udevinfo, version %s\n", UDEV_VERSION);
                        goto exit;
                case 'h':
-                       printf("Usage: udevinfo [-anpqrVh]\n"
-                              "  -q TYPE  query database for the specified value:\n"
-                              "             'name'    name of device node\n"
-                              "             'symlink' pointing to node\n"
-                              "             'path'    sysfs device path\n"
-                              "             'env'     the device related imported environment\n"
-                              "             'all'     all values\n"
+                       printf("Usage: udevinfo OPTIONS\n"
+                              "  --query=<type>    query database for the specified value:\n"
+                              "    name            name of device node\n"
+                              "    symlink         pointing to node\n"
+                              "    path            sysfs device path\n"
+                              "    env             the device related imported environment\n"
+                              "    all             all values\n"
                               "\n"
-                              "  -p PATH  sysfs device path used for query or chain\n"
-                              "  -n NAME  node/symlink name used for query\n"
+                              "  --path=<devpath>  sysfs device path used for query or chain\n"
+                              "  --name=<name>     node or symlink name used for query\n"
                               "\n"
-                              "  -r       prepend to query result or print udev_root\n"
-                              "  -a       print all SYSFS_attributes along the device chain\n"
-                              "  -e       export the content of the udev database\n"
-                              "  -V       print udev version\n"
-                              "  -h       print this help text\n"
+                              "  --root            prepend to query result or print udev_root\n"
+                              "  --attribute-walk  print all SYSFS_attributes along the device chain\n"
+                              "  --export-db       export the content of the udev database\n"
+                              "  --verision        print udev version\n"
+                              "  --help            print this text\n"
                               "\n");
                        goto exit;
-               case ':':
-                       fprintf(stderr, "missing argument for '%c'\n", optopt);
-                       goto exit;
-               case '?':
                default:
-                       fprintf(stderr, "unrecognized option '%c'\n", optopt);
                        goto exit;
                }
        }
@@ -315,7 +322,7 @@ int main(int argc, char *argv[], char *envp[])
                        }
                        udev_db_get_device(udev, devpath);
                } else {
-                       fprintf(stderr, "query needs device path(-p) or node name(-n) specified\n");
+                       fprintf(stderr, "query needs --path or node --name specified\n");
                        rc = 4;
                        goto exit;
                }
@@ -366,7 +373,7 @@ int main(int argc, char *argv[], char *envp[])
                        }
                        print_device_chain(devpath);
                } else {
-                       fprintf(stderr, "attribute walk needs device path(-p) or node name(-n) specified\n");
+                       fprintf(stderr, "attribute walk needs --path or node --name specified\n");
                        rc = 5;
                        goto exit;
                }
index 9bd0b8dc17086d12ccc2ecc963684893a4353342..6c08eee58f4ca3f8ae8769a0d8568acb54621357 100644 (file)
       <refsynopsisdiv>
         <cmdsynopsis>
           <command>udevinfo</command>
-          <arg><option>-<replaceable>query-type</replaceable></option></arg>
-          <arg><option>-</option></arg>
-          <arg><option>-<replaceable>devpath</replaceable></option></arg>
-          <arg><option>-<replaceable>node</replaceable></option></arg>
-          <arg><option>-r</option></arg>
-          <arg><option>-e</option></arg>
-          <arg><option>-V</option></arg>
-          <arg><option>-h</option></arg>
+          <arg><option>--query=<replaceable>query-type</replaceable></option></arg>
+          <arg><option>--attribute-walk</option></arg>
+          <arg><option>--path=<replaceable>devpath</replaceable></option></arg>
+          <arg><option>--name=<replaceable>node</replaceable></option></arg>
+          <arg><option>--root</option></arg>
+          <arg><option>--export-db</option></arg>
+          <arg><option>--version</option></arg>
+          <arg><option>--help</option></arg>
         </cmdsynopsis>
       </refsynopsisdiv>
 
       <refsect1><title>OPTIONS</title>
         <variablelist>
           <varlistentry>
-            <term><option>-q</option></term>
+            <term><option>--query=<replaceable>type</replaceable></option></term>
             <listitem>
               <para>Query the database for specified type of device data. It needs the
-              <option>-p</option> or <option>-n</option> to identify the specified
+              <option>--path</option> or <option>--name</option> to identify the specified
               device. Valid queries are:
               <command>name</command>, <command>symlink</command>, <command>path</command>,
               <command>env</command>, <command>all</command>.</para>
             </listitem>
           </varlistentry>
-
-          <varlistentry>
-            <term><option>-a</option></term>
-            <listitem>
-              <para>Print all sysfs properties of the specified device that can be used
-              in udev rules to match the specified device. It prints all devices
-              along the chain, up to the root of sysfs that can be used in udev rules.</para>
-            </listitem>
-          </varlistentry>
-
           <varlistentry>
-            <term><option>-<replaceable>devpath</replaceable></option></term>
+            <term><option>--path=<replaceable>devpath</replaceable></option></term>
             <listitem>
               <para>The devpath of the device to query.</para>
             </listitem>
           </varlistentry>
-
           <varlistentry>
-            <term><option>-<replaceable>node</replaceable></option></term>
+            <term><option>--name=<replaceable>node</replaceable></option></term>
             <listitem>
               <para>The name of the device node or a symlink to query</para>
             </listitem>
           </varlistentry>
-
           <varlistentry>
-            <term><option>-r</option></term>
+            <term><option>--root</option></term>
             <listitem>
               <para>The udev root directory: <filename>/dev</filename>. If used in conjunction
               with a <command>name</command> or <command>symlink</command> query, the
-              query returns the absolute path.</para>
+              query returns the absolute path including the root directory.</para>
+            </listitem>
+          </varlistentry>
+          <varlistentry>
+            <term><option>--attribute-walk</option></term>
+            <listitem>
+              <para>Print all sysfs properties of the specified device that can be used
+              in udev rules to match the specified device. It prints all devices
+              along the chain, up to the root of sysfs that can be used in udev rules.</para>
             </listitem>
           </varlistentry>
-
           <varlistentry>
-            <term><option>-e</option></term>
+            <term><option>--export</option></term>
             <listitem>
               <para>Export the content of the udev database.</para>
             </listitem>
           </varlistentry>
 
           <varlistentry>
-            <term><option>-h</option></term>
+            <term><option>--help</option></term>
             <listitem>
               <para>Print help text.</para>
             </listitem>