From: Michael Biebl Date: Sat, 25 Sep 2021 19:08:26 +0000 (+0200) Subject: Revert "udev: link_update() should fail if the entry in symlink dir couldn't have... X-Git-Tag: archive/raspbian/247.3-7+rpi1+deb11u4^2~2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=33772848b832a3f4da797fa231c34ce3350bf060;p=systemd.git 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 --- 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. */