loop-util: re-introduce loop_device_open() which takes sd_device object

Then, this makes loop_device_open_from_fd() or _from_path() be wrappers
of loop_device_open() with block_device_new_from_fd() or _from_path(),
respectively.
This commit is contained in:
Yu Watanabe
2022-09-28 17:42:37 +09:00
parent de3b7f168e
commit 4f0ad43e24
2 changed files with 70 additions and 56 deletions
+3 -7
View File
@@ -30,13 +30,9 @@ 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_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);
}
int loop_device_open(sd_device *dev, int open_flags, int lock_op, LoopDevice **ret);
int loop_device_open_from_fd(int fd, int open_flags, int lock_op, LoopDevice **ret);
int loop_device_open_from_path(const char *path, int open_flags, int lock_op, LoopDevice **ret);
LoopDevice* loop_device_ref(LoopDevice *d);
LoopDevice* loop_device_unref(LoopDevice *d);