Revert "udev: link_update() should fail if the entry in symlink dir couldn't have...
authorMichael Biebl <biebl@debian.org>
Sat, 25 Sep 2021 19:08:26 +0000 (21:08 +0200)
committerLuca Boccassi <bluca@debian.org>
Sun, 18 Jun 2023 14:55:54 +0000 (15:55 +0100)
This reverts commit c07dc6cedc6e6fbc28a0da3e8c8b12900423b409.

Gbp-Pq: Topic debian
Gbp-Pq: Name Revert-udev-link_update-should-fail-if-the-entry-in-symli.patch

src/udev/udev-node.c

index 2cc78c9e2f4294d0d1b91c1364671d55182f182c..bde18f756e446695f882a56eee9fad186a53d533 100644 (file)
@@ -214,23 +214,20 @@ static int link_update(sd_device *dev, const char *slink, bool add) {
         if (!filename)
                 return log_oom();
 
-        if (!add) {
-                if (unlink(filename) == 0)
-                        (void) rmdir(dirname);
-        } else
-                for (;;) {
+        if (!add && unlink(filename) == 0)
+                (void) rmdir(dirname);
+
+        if (add)
+                do {
                         _cleanup_close_ int fd = -1;
 
                         r = mkdir_parents(filename, 0755);
                         if (!IN_SET(r, 0, -ENOENT))
-                                return r;
-
-                        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
-                        if (fd >= 0)
                                 break;
-                        if (errno != ENOENT)
-                                return -errno;
-                }
+                        fd = open(filename, O_WRONLY|O_CREAT|O_CLOEXEC|O_TRUNC|O_NOFOLLOW, 0444);
+                        if (fd < 0)
+                                r = -errno;
+                } while (r == -ENOENT);
 
         /* If the database entry is not written yet we will just do one iteration and possibly wrong symlink
          * will be fixed in the second invocation. */