summaryrefslogtreecommitdiff
path: root/udevdb.c
diff options
context:
space:
mode:
authorkay.sievers@vrfy.org <kay.sievers@vrfy.org>2003-12-30 22:31:37 -0800
committerGreg KH <gregkh@suse.de>2005-04-26 21:13:12 -0700
commitf4dc8d11c22ef72567a2e5c56ac9bae82867189b (patch)
tree9d7f00e254092ec7fe277c7db1dbc75abb5c9f9f /udevdb.c
parentc78cb204bc64bce32e705dead071bd4149b731ac (diff)
[PATCH] make udev user callable to query the database
Here is a slightly better version that prints the usage if a unknown option is given: kay@pim:~/src/udev.kay$ ./udev -x ./udev: invalid option -- x Usage: [-qrVh] -q arg query database -r print udev root -V print udev version -h print this help text > Here is a patch that makes it possible to call udev with options on the command line. > Valid options are for now: > > -V for the udev version: > kay@pim:~/src/udev.kay$ ./udev -V > udev, version 011_bk > > -r for the udev root: > kay@pim:~/src/udev.kay$ ./udev -r > /udev/ > > -q to query the database with the sysfs path for the name of the node: > kay@pim:~/src/udev.kay$ ./udev -q /class/video4linux/video0 > test/video/webcam0
Diffstat (limited to 'udevdb.c')
-rw-r--r--udevdb.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/udevdb.c b/udevdb.c
index bbbeddad47..0f9de661a4 100644
--- a/udevdb.c
+++ b/udevdb.c
@@ -128,3 +128,16 @@ int udevdb_init(int init_flag)
}
return 0;
}
+
+/**
+ * udevdb_init: open database for reading
+ */
+int udevdb_open_ro(void)
+{
+ udevdb = tdb_open(udev_db_filename, 0, 0, O_RDONLY, 0);
+ if (udevdb == NULL) {
+ dbg("unable to open database at '%s'", udev_db_filename);
+ return -EINVAL;
+ }
+ return 0;
+}