summaryrefslogtreecommitdiff
path: root/udev.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2004-01-13 01:01:19 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:15 -0700
commitee1db00d07ed1db55061ba5e2cb54800cc3e2495 (patch)
tree716356410740f3c13a498ae1d8350b5fef367919 /udev.c
parenta2505f4d1da4793991a4d2b2dc8f93b9b89d9672 (diff)
[PATCH] more advanced user query options
Here is the '-h' and a '-d' to dump the whole database: kay@pim:~/src/udev.kay$ ./udev -d P: /block/hdb/hdb1 N: hdb1 S: O: G: P: /class/video4linux/video0 N: video/webcam0 S: camera0 kamera0 O: 500 G: 500 P: /block/hdc N: hdc S: O: G:
Diffstat (limited to 'udev.c')
-rw-r--r--udev.c39
1 files changed, 32 insertions, 7 deletions
diff --git a/udev.c b/udev.c
index 7078f089e2..84950c82a3 100644
--- a/udev.c
+++ b/udev.c
@@ -82,6 +82,16 @@ static inline char *get_seqnum(void)
return seqnum;
}
+static void print_record(char *path, struct udevice *dev)
+{
+ printf("P: %s\n", path);
+ printf("N: %s\n", dev->name);
+ printf("S: %s\n", dev->symlink);
+ printf("O: %s\n", dev->owner);
+ printf("G: %s\n", dev->group);
+ printf("\n");
+}
+
enum query_type {
NONE,
NAME,
@@ -92,7 +102,7 @@ enum query_type {
static inline int udev_user(int argc, char **argv)
{
- static const char short_options[] = "p:q:rVh";
+ static const char short_options[] = "dp:q:rVh";
int option;
int retval = -EINVAL;
struct udevice dev;
@@ -144,6 +154,16 @@ static inline int udev_user(int argc, char **argv)
root = 1;
break;
+ case 'd':
+ retval = udevdb_open_ro();
+ if (retval != 0) {
+ printf("unable to open udev database\n");
+ return -EACCES;
+ }
+ retval = udevdb_dump(print_record);
+ udevdb_exit();
+ return retval;
+
case 'V':
printf("udev, version %s\n", UDEV_VERSION);
return 0;
@@ -206,12 +226,17 @@ static inline int udev_user(int argc, char **argv)
}
help:
- printf("Usage: [-qrVh]\n"
- " -q <name> query database for the specified value\n"
- " -p <path> device path used for query\n"
- " -r print udev root\n"
- " -V print udev version\n"
- " -h print this help text\n"
+ printf("Usage: [-pqrdVh]\n"
+ " -q TYPE query database for the specified value:\n"
+ " 'name' name of device node\n"
+ " 'symlink' pointing to node\n"
+ " 'owner' of node\n"
+ " 'group' of node\n"
+ " -p PATH sysfs device path used for query\n"
+ " -r print udev root\n"
+ " -d dump whole database\n"
+ " -V print udev version\n"
+ " -h print this help text\n"
"\n");
return retval;
}