chiark / gitweb /
rules: do not set GROUP="disk" for scanners
[elogind.git] / udev_node.c
index 556a442a333709a08593a4f4c2ded038942a8e5c..6ca0601ea48e815b86437e75819611008e715211 100644 (file)
@@ -164,7 +164,7 @@ static int node_symlink(const char *node, const char *slink)
        strlcpy(slink_tmp, slink, sizeof(slink_tmp));
        strlcat(slink_tmp, TMP_FILE_EXT, sizeof(slink_tmp));
        unlink(slink_tmp);
-       selinux_setfscreatecon(slink_tmp, NULL, S_IFLNK);
+       selinux_setfscreatecon(slink, NULL, S_IFLNK);
        retval = symlink(target, slink_tmp);
        selinux_resetfscreatecon();
        if (retval != 0) {
@@ -218,14 +218,16 @@ 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;
@@ -406,8 +408,8 @@ int udev_node_remove(struct udevice *udev)
        strlcat(filename, "/", sizeof(filename));
        strlcat(filename, udev->name, sizeof(filename));
        if (stat(filename, &stats) != 0) {
-               dbg("device node '%s' not found", filename);
-               return -1;
+               info("device node '%s' not found", filename);
+               return 0;
        }
        if (udev->devt && stats.st_rdev != udev->devt) {
                info("device node '%s' points to a different device, skip removal", filename);