summaryrefslogtreecommitdiffstats
path: root/man2/copy_file_range.2
diff options
context:
space:
mode:
Diffstat (limited to 'man2/copy_file_range.2')
-rw-r--r--man2/copy_file_range.218
1 files changed, 9 insertions, 9 deletions
diff --git a/man2/copy_file_range.2 b/man2/copy_file_range.2
index 1bade7bf7..6f3aa4971 100644
--- a/man2/copy_file_range.2
+++ b/man2/copy_file_range.2
@@ -239,48 +239,48 @@ the call failed to copy, while still reporting success.
#include <stdlib.h>
#include <sys/stat.h>
#include <unistd.h>
-
+\&
int
main(int argc, char *argv[])
{
int fd_in, fd_out;
off64_t len, ret;
struct stat stat;
-
+\&
if (argc != 3) {
fprintf(stderr, "Usage: %s <source> <destination>\en", argv[0]);
exit(EXIT_FAILURE);
}
-
+\&
fd_in = open(argv[1], O_RDONLY);
if (fd_in == \-1) {
perror("open (argv[1])");
exit(EXIT_FAILURE);
}
-
+\&
if (fstat(fd_in, &stat) == \-1) {
perror("fstat");
exit(EXIT_FAILURE);
}
-
+\&
len = stat.st_size;
-
+\&
fd_out = open(argv[2], O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd_out == \-1) {
perror("open (argv[2])");
exit(EXIT_FAILURE);
}
-
+\&
do {
ret = copy_file_range(fd_in, NULL, fd_out, NULL, len, 0);
if (ret == \-1) {
perror("copy_file_range");
exit(EXIT_FAILURE);
}
-
+\&
len \-= ret;
} while (len > 0 && ret > 0);
-
+\&
close(fd_in);
close(fd_out);
exit(EXIT_SUCCESS);