]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udev: only ignore ENOENT or friends which suggest the block device is not exist
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 12 Mar 2022 11:40:58 +0000 (20:40 +0900)
committerLennart Poettering <lennart@poettering.net>
Thu, 24 Mar 2022 15:20:08 +0000 (16:20 +0100)
The ENOENT, ENXIO, and ENODEV error can happen easily when a block
device appears and soon removed. So, it is reasonable to ignore the
error. But other errors should not occur here, and hence let's handle
them as critical.

src/udev/udevd.c

index 8389c39f652f806ea88185a82e06a7dfc1b86393..f1f864a4610cf750a4ebbc451b6336e97aadbefa 100644 (file)
@@ -399,8 +399,10 @@ static int worker_lock_block_device(sd_device *dev, int *ret_fd) {
 
         fd = open(val, O_RDONLY|O_CLOEXEC|O_NOFOLLOW|O_NONBLOCK);
         if (fd < 0) {
-                log_device_debug_errno(dev, errno, "Failed to open '%s', ignoring: %m", val);
-                return 0;
+                bool ignore = ERRNO_IS_DEVICE_ABSENT(errno);
+
+                log_device_debug_errno(dev, errno, "Failed to open '%s'%s: %m", val, ignore ? ", ignoring" : "");
+                return ignore ? 0 : -errno;
         }
 
         if (flock(fd, LOCK_SH|LOCK_NB) < 0)