diff options
author | Ron Yorston <rmy@pobox.com> | 2018-07-25 10:41:42 +0100 |
---|---|---|
committer | Ron Yorston <rmy@pobox.com> | 2018-07-25 10:41:42 +0100 |
commit | 59873514f17cefd6ba3997dad5779f75433fd4e6 (patch) | |
tree | 1c9d0a3450ed95f0b820285b9f9fc217c902e652 /libbb/copy_file.c | |
parent | 779fd5745ac11bf752f5f4b977a274a39c192f90 (diff) | |
parent | 81de30de05beebabfa72f2a01ec4f33e9a1923e3 (diff) | |
download | busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.gz busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.tar.bz2 busybox-w32-59873514f17cefd6ba3997dad5779f75433fd4e6.zip |
Merge branch 'busybox'
Diffstat (limited to 'libbb/copy_file.c')
-rw-r--r-- | libbb/copy_file.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/libbb/copy_file.c b/libbb/copy_file.c index c60765d95..7cd9cd978 100644 --- a/libbb/copy_file.c +++ b/libbb/copy_file.c | |||
@@ -343,8 +343,27 @@ int FAST_FUNC copy_file(const char *source, const char *dest, int flags) | |||
343 | } | 343 | } |
344 | } | 344 | } |
345 | #endif | 345 | #endif |
346 | #if ENABLE_FEATURE_CP_REFLINK | ||
347 | # undef BTRFS_IOCTL_MAGIC | ||
348 | # define BTRFS_IOCTL_MAGIC 0x94 | ||
349 | # undef BTRFS_IOC_CLONE | ||
350 | # define BTRFS_IOC_CLONE _IOW (BTRFS_IOCTL_MAGIC, 9, int) | ||
351 | if (flags & FILEUTILS_REFLINK) { | ||
352 | retval = ioctl(dst_fd, BTRFS_IOC_CLONE, src_fd); | ||
353 | if (retval == 0) | ||
354 | goto do_close; | ||
355 | /* reflink did not work */ | ||
356 | if (flags & FILEUTILS_REFLINK_ALWAYS) { | ||
357 | bb_perror_msg("failed to clone '%s' from '%s'", dest, source); | ||
358 | goto do_close; | ||
359 | } | ||
360 | /* fall through to standard copy */ | ||
361 | retval = 0; | ||
362 | } | ||
363 | #endif | ||
346 | if (bb_copyfd_eof(src_fd, dst_fd) == -1) | 364 | if (bb_copyfd_eof(src_fd, dst_fd) == -1) |
347 | retval = -1; | 365 | retval = -1; |
366 | IF_FEATURE_CP_REFLINK(do_close:) | ||
348 | /* Careful with writing... */ | 367 | /* Careful with writing... */ |
349 | if (close(dst_fd) < 0) { | 368 | if (close(dst_fd) < 0) { |
350 | bb_perror_msg("error writing to '%s'", dest); | 369 | bb_perror_msg("error writing to '%s'", dest); |