chiark / gitweb /
[PATCH] add udev logging to info log
[elogind.git] / udev.c
diff --git a/udev.c b/udev.c
index 7078f089e2db0a4d46069eda299e7d2e006b7098..b872f42494e68070e34452e6221dca619fb5e650 100644 (file)
--- a/udev.c
+++ b/udev.c
@@ -34,6 +34,7 @@
 #include "udev.h"
 #include "udev_version.h"
 #include "udev_dbus.h"
+#include "logging.h"
 #include "namedev.h"
 #include "udevdb.h"
 #include "libsysfs/libsysfs.h"
@@ -82,6 +83,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 +103,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 +155,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 +227,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;
 }
@@ -220,6 +246,8 @@ static char *subsystem_blacklist[] = {
        "net",
        "scsi_host",
        "scsi_device",
+       "usb_host",
+       "pci_bus",
        "",
 };