summaryrefslogtreecommitdiffstats
path: root/debian/patches/debian/Revert-udev-link_update-should-fail-if-the-entry-in-symli.patch
blob: e3f1c64205a51b2f613a968442b6a91b2d5aa80c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
From: Michael Biebl <biebl@debian.org>
Date: Sat, 25 Sep 2021 21:08:26 +0200
Subject: Revert "udev: link_update() should fail if the entry in symlink dir
 couldn't have been created"

This reverts commit c07dc6cedc6e6fbc28a0da3e8c8b12900423b409.
---
 src/udev/udev-node.c | 21 +++++++++------------
 1 file changed, 9 insertions(+), 12 deletions(-)

diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 2cc78c9..bde18f7 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -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. */