]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: try to create device symlink directly only when the link does not exist yet
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 2 Jun 2021 16:16:44 +0000 (01:16 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Jun 2021 06:51:39 +0000 (15:51 +0900)
src/udev/udev-node.c

index b9471397148f5ae043101303e82eb1ea4a32f7e4..6276a543d28fb41d97f35777090da74e65717851 100644 (file)
@@ -96,7 +96,7 @@ static int node_symlink(sd_device *dev, const char *node, const char *slink) {
 
                         return 0;
                 }
-        } else {
+        } else if (errno == ENOENT) {
                 log_device_debug(dev, "Creating symlink '%s' to '%s'", slink, target);
 
                 r = create_symlink(target, slink);
@@ -104,7 +104,8 @@ static int node_symlink(sd_device *dev, const char *node, const char *slink) {
                         return 0;
 
                 log_device_debug_errno(dev, r, "Failed to create symlink '%s' to '%s', trying to replace '%s': %m", slink, target, slink);
-        }
+        } else
+                return log_device_debug_errno(dev, errno, "Failed to lstat() '%s': %m", slink);
 
         log_device_debug(dev, "Atomically replace '%s'", slink);