chiark / gitweb /
udevinfo: exclude "uevent" file from --attribute-walk
[elogind.git] / udev_node.c
index fcd52d0e45d5d9b861a353267bfbf5c56d64f64c..c620e4aa0b13f95b676cb95401e9216235aff291 100644 (file)
@@ -133,7 +133,7 @@ static int node_symlink(const char *node, const char *slink)
                                    stats.st_rdev == stats2.st_rdev) {
                                        info("replace device node '%s' with symlink to our node '%s'", slink, node);
                                } else {
-                                       err("device node '%s' already exists, link '%s' will not overwrite it", node, slink);
+                                       err("device node '%s' already exists, link to '%s' will not overwrite it", slink, node);
                                        goto exit;
                                }
                        }
@@ -218,23 +218,29 @@ static int update_link(struct udevice *udev, const char *name)
                if (strcmp(udev->dev->devpath, device->name) == 0) {
                        info("compare (our own) priority of '%s' %i >= %i",
                             udev->dev->devpath, udev->link_priority, priority);
-                       if (target[0] == '\0' || udev->link_priority >= priority) {
+                       if (strcmp(udev->name, name) == 0) {
+                               info("'%s' is our device node, database inconsistent, skip link update", udev->name);
+                       } else if (target[0] == '\0' || udev->link_priority >= priority) {
                                priority = udev->link_priority;
                                strlcpy(target, udev->name, sizeof(target));
                        }
                        continue;
                }
 
-               /* or something else, then read priority from database */
+               /* another device, read priority from database */
                udev_db = udev_device_init(NULL);
                if (udev_db == NULL)
                        continue;
                if (udev_db_get_device(udev_db, device->name) == 0) {
-                       info("compare priority of '%s' %i > %i",
-                            udev_db->dev->devpath, udev_db->link_priority, priority);
-                       if (target[0] == '\0' || udev_db->link_priority > priority) {
-                               priority = udev_db->link_priority;
-                               strlcpy(target, udev_db->name, sizeof(target));
+                       if (strcmp(udev_db->name, name) == 0) {
+                               info("'%s' is a device node of '%s', skip link update", udev_db->name, device->name);
+                       } else {
+                               info("compare priority of '%s' %i > %i",
+                                    udev_db->dev->devpath, udev_db->link_priority, priority);
+                               if (target[0] == '\0' || udev_db->link_priority > priority) {
+                                       priority = udev_db->link_priority;
+                                       strlcpy(target, udev_db->name, sizeof(target));
+                               }
                        }
                }
                udev_device_cleanup(udev_db);
@@ -242,8 +248,8 @@ static int update_link(struct udevice *udev, const char *name)
        name_list_cleanup(&name_list);
 
        if (target[0] == '\0') {
-               err("missing target for '%s'", name);
-               rc = -1;
+               info("no current target for '%s' found", name);
+               rc = 1;
                goto out;
        }