diff mbox series

[1/2] xfsprogs: copy_range don't truncate dstfile

Message ID 20190905053152.15701-1-yin-jianhong@163.com (mailing list archive)
State New, archived
Headers show
Series [1/2] xfsprogs: copy_range don't truncate dstfile | expand

Commit Message

Jianhong.Yin Sept. 5, 2019, 5:31 a.m. UTC
now if we do copy_range from srcfile to dstfile without any option
will truncate the dstfile, and not any document indicate this default
action. that's unexpected and confuse people.

'''
$ ./xfs_io -f -c 'copy_range copy_file_range.c'  testfile
$ ll testfile
-rw-rw-r--. 1 yjh yjh 3534 Sep  5 07:15 testfile
$ ./xfs_io -c 'copy_range testfile'  testfile
$ ll testfile
-rw-rw-r--. 1 yjh yjh 3534 Sep  5 07:16 testfile
$ ./xfs_io -c 'copy_range testfile -l 3534 -d 3534' testfile
$ ll testfile
-rw-rw-r--. 1 yjh yjh 7068 Sep  5 07:17 testfile
$ ./xfs_io -c 'copy_range copy_file_range.c'  testfile
$ ll testfile
-rw-rw-r--. 1 yjh yjh 7068 Sep  5 07:18 testfile
$ cmp -n 3534 copy_file_range.c testfile
$ cmp -i 0:3534 copy_file_range.c testfile
'''

Signed-off-by: Jianhong Yin <yin-jianhong@163.com>
---
 io/copy_file_range.c | 15 ---------------
 1 file changed, 15 deletions(-)
diff mbox series

Patch

diff --git a/io/copy_file_range.c b/io/copy_file_range.c
index b7b9fd88..283f5094 100644
--- a/io/copy_file_range.c
+++ b/io/copy_file_range.c
@@ -66,15 +66,6 @@  copy_src_filesize(int fd)
 	return st.st_size;
 }
 
-static int
-copy_dst_truncate(void)
-{
-	int ret = ftruncate(file->fd, 0);
-	if (ret < 0)
-		perror("ftruncate");
-	return ret;
-}
-
 static int
 copy_range_f(int argc, char **argv)
 {
@@ -146,12 +137,6 @@  copy_range_f(int argc, char **argv)
 			goto out;
 		}
 		len = sz;
-
-		ret = copy_dst_truncate();
-		if (ret < 0) {
-			ret = 1;
-			goto out;
-		}
 	}
 
 	ret = copy_file_range_cmd(fd, &src, &dst, len);