From 4fdbf4a7de1efba8f253d8baba9f7ea30dee24eb Mon Sep 17 00:00:00 2001 From: Michael Biebl Date: Sat, 25 Sep 2021 21:08:26 +0200 Subject: [PATCH] Revert "udev: link_update() should fail if the entry in symlink dir couldn't have been created" 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 | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c index 2cc78c9e..bde18f75 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. */ -- 2.30.2