diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-01-17 18:11:45 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-01-19 20:24:09 +0100 |
commit | 1c7dd82563ff2e71a067aea20d2acb2d0553644b (patch) | |
tree | f26693719aeea09d4ab0f94e503bf82de96fa241 /src/shared/btrfs-util.c | |
parent | import: when downloading raw files, show simple progress reports (diff) | |
download | systemd-1c7dd82563ff2e71a067aea20d2acb2d0553644b.tar.xz systemd-1c7dd82563ff2e71a067aea20d2acb2d0553644b.zip |
qcow2: when dissecting qcow2, use btrfs clone ioctls for reflinking blocks to target
Diffstat (limited to 'src/shared/btrfs-util.c')
-rw-r--r-- | src/shared/btrfs-util.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/shared/btrfs-util.c b/src/shared/btrfs-util.c index bd100eef0b..254483c31a 100644 --- a/src/shared/btrfs-util.c +++ b/src/shared/btrfs-util.c @@ -275,6 +275,26 @@ int btrfs_reflink(int infd, int outfd) { return 0; } +int btrfs_clone_range(int infd, uint64_t in_offset, int outfd, uint64_t out_offset, uint64_t sz) { + struct btrfs_ioctl_clone_range_args args = { + .src_fd = infd, + .src_offset = in_offset, + .src_length = sz, + .dest_offset = out_offset, + }; + int r; + + assert(infd >= 0); + assert(outfd >= 0); + assert(sz > 0); + + r = ioctl(outfd, BTRFS_IOC_CLONE_RANGE, &args); + if (r < 0) + return -errno; + + return 0; +} + int btrfs_get_block_device(const char *path, dev_t *dev) { struct btrfs_ioctl_fs_info_args fsi = {}; _cleanup_close_ int fd = -1; |