summaryrefslogtreecommitdiffstats
path: root/src/shared/blockdev-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/blockdev-util.c')
-rw-r--r--src/shared/blockdev-util.c7
1 files changed, 1 insertions, 6 deletions
diff --git a/src/shared/blockdev-util.c b/src/shared/blockdev-util.c
index 0d921cc045..6038591d83 100644
--- a/src/shared/blockdev-util.c
+++ b/src/shared/blockdev-util.c
@@ -221,7 +221,6 @@ int get_block_device_harder(const char *path, dev_t *ret) {
}
int lock_whole_block_device(dev_t devt, int operation) {
- _cleanup_free_ char *whole_node = NULL;
_cleanup_close_ int lock_fd = -1;
dev_t whole_devt;
int r;
@@ -232,14 +231,10 @@ int lock_whole_block_device(dev_t devt, int operation) {
if (r < 0)
return r;
- r = device_path_make_major_minor(S_IFBLK, whole_devt, &whole_node);
+ lock_fd = r = device_open_from_devnum(S_IFBLK, whole_devt, O_RDONLY|O_CLOEXEC|O_NONBLOCK, NULL);
if (r < 0)
return r;
- lock_fd = open(whole_node, O_RDONLY|O_CLOEXEC|O_NONBLOCK);
- if (lock_fd < 0)
- return -errno;
-
if (flock(lock_fd, operation) < 0)
return -errno;