]> granicus.if.org Git - strace/blob - tests/copy_file_range.c
72a750f7521e1993fc1580adfca6e1053ecfed8a
[strace] / tests / copy_file_range.c
1 /*
2  * This file is part of copy_file_range strace test.
3  *
4  * Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
5  * Copyright (c) 2016-2017 The strace developers.
6  * All rights reserved.
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10
11 #include "tests.h"
12 #include <asm/unistd.h>
13 #include "scno.h"
14
15 #if defined __NR_copy_file_range
16
17 # include <stdio.h>
18 # include <unistd.h>
19
20 int
21 main(void)
22 {
23         const long int fd_in = (long int) 0xdeadbeefffffffff;
24         const long int fd_out = (long int) 0xdeadbeeffffffffe;
25         TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_in);
26         TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_out);
27         *off_in = 0xdeadbef1facefed1;
28         *off_out = 0xdeadbef2facefed2;
29         const size_t len = (size_t) 0xdeadbef3facefed3ULL;
30         const unsigned int flags = 0;
31
32         long rc = syscall(__NR_copy_file_range,
33                           fd_in, off_in, fd_out, off_out, len, flags);
34         printf("copy_file_range(%d, [%lld], %d, [%lld], %zu, %u)"
35                " = %ld %s (%m)\n",
36                (int) fd_in, *off_in, (int) fd_out, *off_out, len, flags,
37                rc, errno2name());
38
39         puts("+++ exited with 0 +++");
40         return 0;
41 }
42
43 #else
44
45 SKIP_MAIN_UNDEFINED("__NR_copy_file_range")
46
47 #endif