udev: switch over to rereadpt() rather than raw BLKRRPART

Fixes: #38672
This commit is contained in:
Lennart Poettering
2025-10-22 22:56:01 +02:00
parent 0ef4118c78
commit aa47d8ade1
3 changed files with 2 additions and 53 deletions
-21
View File
@@ -804,27 +804,6 @@ int block_device_remove_all_partitions(sd_device *dev, int fd) {
return k < 0 ? k : has_partitions;
}
int blockdev_reread_partition_table(sd_device *dev) {
_cleanup_close_ int fd = -EBADF;
assert(dev);
/* Try to re-read the partition table. This only succeeds if none of the devices is busy. */
fd = sd_device_open(dev, O_RDONLY|O_CLOEXEC|O_NONBLOCK|O_NOCTTY);
if (fd < 0)
return fd;
if (flock(fd, LOCK_EX|LOCK_NB) < 0)
return -errno;
if (ioctl(fd, BLKRRPART, 0) < 0)
return -errno;
return 0;
}
int blockdev_get_sector_size(int fd, uint32_t *ret) {
int ssz = 0;
-1
View File
@@ -51,7 +51,6 @@ int block_device_remove_partition(int fd, const char *name, int nr);
int block_device_resize_partition(int fd, int nr, uint64_t start, uint64_t size);
int partition_enumerator_new(sd_device *dev, sd_device_enumerator **ret);
int block_device_remove_all_partitions(sd_device *dev, int fd);
int blockdev_reread_partition_table(sd_device *dev);
int blockdev_get_sector_size(int fd, uint32_t *ret);
int blockdev_get_device_size(int fd, uint64_t *ret);