diff --git a/lib/vfs/vfs.c b/lib/vfs/vfs.c
index 189ca7b..724bb72 100644
a
|
b
|
|
45 | 45 | #include <errno.h> |
46 | 46 | #include <stdlib.h> |
47 | 47 | |
| 48 | #ifdef __linux |
| 49 | # include <linux/fs.h> |
| 50 | # ifdef HAVE_SYS_IOCTL_H |
| 51 | # include <sys/ioctl.h> |
| 52 | # endif |
| 53 | #endif |
| 54 | |
48 | 55 | #include "lib/global.h" |
49 | 56 | #include "lib/strutil.h" |
50 | 57 | #include "lib/util.h" |
… |
… |
vfs_preallocate (int dest_vfs_fd, off_t src_fsize, off_t dest_fsize) |
656 | 663 | #endif /* HAVE_POSIX_FALLOCATE */ |
657 | 664 | } |
658 | 665 | |
| 666 | int |
| 667 | vfs_clone_file (int dest_vfs_fd, int src_vfs_fd) |
| 668 | { |
| 669 | #ifdef FICLONE |
| 670 | void *dest_fd = NULL; |
| 671 | void *src_fd = NULL; |
| 672 | struct vfs_class *dest_class; |
| 673 | struct vfs_class *src_class; |
| 674 | |
| 675 | dest_class = vfs_class_find_by_handle (dest_vfs_fd, &dest_fd); |
| 676 | if (dest_fd == NULL || (dest_class->flags & VFSF_LOCAL) == 0) |
| 677 | { |
| 678 | errno = EOPNOTSUPP; |
| 679 | return -1; |
| 680 | } |
| 681 | |
| 682 | src_class = vfs_class_find_by_handle (src_vfs_fd, &src_fd); |
| 683 | if (src_fd == NULL || (src_class->flags & VFSF_LOCAL) == 0) |
| 684 | { |
| 685 | errno = EOPNOTSUPP; |
| 686 | return -1; |
| 687 | } |
| 688 | |
| 689 | return ioctl (*(int *) dest_fd, FICLONE, *(int *) src_fd); |
| 690 | #else |
| 691 | (void) dest_vfs_fd; |
| 692 | (void) src_vfs_fd; |
| 693 | errno = EOPNOTSUPP; |
| 694 | return -1; |
| 695 | #endif |
| 696 | } |
| 697 | |
659 | 698 | /* --------------------------------------------------------------------------------------------- */ |
diff --git a/lib/vfs/vfs.h b/lib/vfs/vfs.h
index 2510195..58ba4b5 100644
a
|
b
|
char *_vfs_get_cwd (void); |
287 | 287 | |
288 | 288 | int vfs_preallocate (int dest_desc, off_t src_fsize, off_t dest_fsize); |
289 | 289 | |
| 290 | int vfs_clone_file (int dest_vfs_fd, int src_vfs_fd); |
| 291 | |
290 | 292 | /** |
291 | 293 | * Interface functions described in interface.c |
292 | 294 | */ |
diff --git a/src/filemanager/file.c b/src/filemanager/file.c
index 179d8c8..ad5a229 100644
a
|
b
|
copy_file_file (file_op_total_context_t * tctx, file_op_context_t * ctx, |
2366 | 2366 | appending = ctx->do_append; |
2367 | 2367 | ctx->do_append = FALSE; |
2368 | 2368 | |
| 2369 | /* Try clone the file first */ |
| 2370 | if (vfs_clone_file(dest_desc, src_desc) == 0) |
| 2371 | { |
| 2372 | dst_status = DEST_FULL; |
| 2373 | return_status = FILE_CONT; |
| 2374 | goto ret; |
| 2375 | } |
| 2376 | |
2369 | 2377 | /* Find out the optimal buffer size. */ |
2370 | 2378 | while (mc_fstat (dest_desc, &dst_stat) != 0) |
2371 | 2379 | { |