loop-util: rename loop_device_open() -> loop_device_open_from_path()

No functional changes, just preparation for later commits.
This commit is contained in:
Yu Watanabe
2022-09-28 17:42:37 +09:00
parent fd690a4b7f
commit de3b7f168e
5 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -874,7 +874,7 @@ static int action_umount(const char *path) {
return log_error_errno(r, "Failed to get devname of block device " DEVNUM_FORMAT_STR ": %m",
DEVNUM_FORMAT_VAL(devno));
r = loop_device_open(devname, 0, LOCK_EX, &d);
r = loop_device_open_from_path(devname, 0, LOCK_EX, &d);
if (r < 0)
return log_error_errno(r, "Failed to open loop device '%s': %m", devname);
+1 -1
View File
@@ -647,7 +647,7 @@ static int enumerate_partitions(dev_t devnum) {
/* Let's take a LOCK_SH lock on the block device, in case udevd is already running. If we don't take
* the lock, udevd might end up issuing BLKRRPART in the middle, and we don't want that, since that
* might remove all partitions while we are operating on them. */
r = loop_device_open(devname, O_RDONLY, LOCK_SH, &loop);
r = loop_device_open_from_path(devname, O_RDONLY, LOCK_SH, &loop);
if (r < 0)
return log_debug_errno(r, "Failed to open %s: %m", devname);
+1 -1
View File
@@ -1284,7 +1284,7 @@ int home_setup_luks(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to determine backing device for DM %s.", setup->dm_name);
if (!setup->loop) {
r = loop_device_open(n, O_RDWR, LOCK_UN, &setup->loop);
r = loop_device_open_from_path(n, O_RDWR, LOCK_UN, &setup->loop);
if (r < 0)
return log_error_errno(r, "Failed to open loopback device %s: %m", n);
}
+1 -1
View File
@@ -414,7 +414,7 @@ static int loop_device_make_internal(
/* If this is already a block device and we are supposed to cover the whole of it
* then store an fd to the original open device node — and do not actually create an
* unnecessary loopback device for it. */
return loop_device_open_full(NULL, fd, open_flags, lock_op, ret);
return loop_device_open_from_fd(fd, open_flags, lock_op, ret);
} else {
r = stat_verify_regular(&st);
if (r < 0)
+5 -2
View File
@@ -31,8 +31,11 @@ struct LoopDevice {
int loop_device_make(int fd, int open_flags, uint64_t offset, uint64_t size, uint32_t loop_flags, int lock_op, LoopDevice **ret);
int loop_device_make_by_path(const char *path, int open_flags, uint32_t loop_flags, int lock_op, LoopDevice **ret);
int loop_device_open_full(const char *loop_path, int loop_fd, int open_flags, int lock_op, LoopDevice **ret);
static inline int loop_device_open(const char *loop_path, int open_flags, int lock_op, LoopDevice **ret) {
return loop_device_open_full(loop_path, -1, open_flags, lock_op, ret);
static inline int loop_device_open_from_fd(int fd, int open_flags, int lock_op, LoopDevice **ret) {
return loop_device_open_full(NULL, fd, open_flags, lock_op, ret);
}
static inline int loop_device_open_from_path(const char *path, int open_flags, int lock_op, LoopDevice **ret) {
return loop_device_open_full(path, -1, open_flags, lock_op, ret);
}
LoopDevice* loop_device_ref(LoopDevice *d);