summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay.sievers@suse.de>2006-09-03 04:05:20 +0200
committerKay Sievers <kay.sievers@suse.de>2006-09-03 04:05:20 +0200
commit11f1bb5ab42571fae5cc607d42b8d918c9e170ab (patch)
tree60f96e282dab0b1bc0a5a9ddf198266f9a2fb391
parenta44a30f6642ce49280012c551b532936a3a68729 (diff)
udevinfo: use long options
-rw-r--r--udevinfo.826
-rw-r--r--udevinfo.c53
-rw-r--r--udevinfo.xml53
3 files changed, 67 insertions, 65 deletions
diff --git a/udevinfo.8 b/udevinfo.8
index 4430f5d9d3..01c9090031 100644
--- a/udevinfo.8
+++ b/udevinfo.8
@@ -14,17 +14,17 @@
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\-n \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
diff --git a/udevinfo.c b/udevinfo.c
index 3146a96119..d1d77152c3 100644
--- a/udevinfo.c
+++ b/udevinfo.c
@@ -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;
}
diff --git a/udevinfo.xml b/udevinfo.xml
index 9bd0b8dc17..6c08eee58f 100644
--- a/udevinfo.xml
+++ b/udevinfo.xml
@@ -25,14 +25,14 @@
<refsynopsisdiv>
<cmdsynopsis>
<command>udevinfo</command>
- <arg><option>-q <replaceable>query-type</replaceable></option></arg>
- <arg><option>-a </option></arg>
- <arg><option>-p <replaceable>devpath</replaceable></option></arg>
- <arg><option>-n <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>
@@ -46,57 +46,52 @@
<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>-p <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>-n <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>