diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-10 00:33:43 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-09-10 01:19:41 +0900 |
commit | 86f9b69a6a394bd752be01d997d47849de67006f (patch) | |
tree | 8fc5bfdcf9a3f436aa80d9ed1f9307de843bce99 /src/udev/udevd.c | |
parent | 9409174ee7280447a6f8c395740bda4fa8114b1d (diff) | |
download | systemd-86f9b69a6a394bd752be01d997d47849de67006f.tar.gz |
blockdev-util: split out blockdev_reread_partition_table()
No functional changes, just refactoring.
Diffstat (limited to 'src/udev/udevd.c')
-rw-r--r-- | src/udev/udevd.c | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/udev/udevd.c b/src/udev/udevd.c index c034e6a3cf..c2a4a8a7bd 100644 --- a/src/udev/udevd.c +++ b/src/udev/udevd.c @@ -1400,23 +1400,13 @@ static int synthesize_change(sd_device *dev) { streq_ptr(devtype, "disk") && !startswith(sysname, "dm-")) { _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; - bool part_table_read = false; + bool part_table_read; sd_device *d; - int fd; - - /* Try to re-read the partition table. This only succeeds if none of the devices is - * busy. The kernel returns 0 if no partition table is found, and we will not get an - * event for the disk. */ - fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK); - if (fd >= 0) { - r = flock(fd, LOCK_EX|LOCK_NB); - if (r >= 0) - r = ioctl(fd, BLKRRPART, 0); - - close(fd); - if (r >= 0) - part_table_read = true; - } + + r = blockdev_reread_partition_table(dev); + if (r < 0) + log_device_debug_errno(dev, r, "Failed to re-read partition table, ignoring: %m"); + part_table_read = r >= 0; /* search for partitions */ r = partition_enumerator_new(dev, &e); |