chiark / gitweb /
prepare for new HAL udevdb dump
[elogind.git] / udevinfo.c
index db562eee49d6c581c8bb1e775f56da76484684f5..814bd1e90af94a83fca8be047dc863ecd7764fbb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * udevinfo - fetches attributes for a device
+ * udevinfo.c - fetches attributes for a device
  *
  * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
  *
@@ -165,9 +165,22 @@ exit:
        return retval;
 }
 
-static int print_dump(const char *devpath, const char *name) {
-       printf("%s=%s/%s\n", devpath, udev_root, name);
-       return 0;
+static void dump_names(void) {
+       LIST_HEAD(name_list);
+       struct name_entry *name_loop;
+       struct name_entry *tmp_loop;
+
+       udev_db_get_all_entries(&name_list);
+       list_for_each_entry_safe(name_loop, tmp_loop, &name_list, node) {
+               struct udevice udev_db;
+
+               udev_init_device(&udev_db, NULL, NULL, NULL);
+               if (udev_db_get_device(&udev_db, name_loop->name) == 0) {
+                       printf("%s=%s/%s\n", udev_db.devpath, udev_root, udev_db.name);
+                       free(name_loop);
+               }
+               udev_cleanup_device(&udev_db);
+       }
 }
 
 int main(int argc, char *argv[], char *envp[])
@@ -256,7 +269,7 @@ int main(int argc, char *argv[], char *envp[])
                        break;
 
                case 'd':
-                       udev_db_dump_names(print_dump);
+                       dump_names();
                        goto exit;
 
                case 'V':
@@ -289,7 +302,7 @@ int main(int argc, char *argv[], char *envp[])
                        }
                        retval = udev_db_get_device(&udev, pos);
                        if (retval != 0) {
-                               fprintf(stderr, "device not found in database\n");
+                               fprintf(stderr, "no record for '%s' in database\n", pos);
                                goto exit;
                        }
                        goto print;
@@ -329,7 +342,7 @@ print:
                        goto exit;
                case QUERY_SYMLINK:
                        if (list_empty(&udev.symlink_list))
-                               break;
+                               goto exit;
                        if (root)
                                list_for_each_entry(name_loop, &udev.symlink_list, node)
                                        printf("%s/%s ", udev_root, name_loop->name);