logo

utils-std

Collection of commonly available Unix tools git clone https://anongit.hacktivis.me/git/utils-std.git/

copy_file_range.c (539B)


  1. // utils-std: Collection of commonly available Unix tools
  2. // SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
  3. // SPDX-License-Identifier: MPL-2.0
  4. // For copy_file_range
  5. #define _GNU_SOURCE // musl, glibc
  6. #define _DEFAULT_SOURCE // FreeBSD
  7. #include <stdint.h> // SIZE_MAX
  8. #include <sys/types.h>
  9. #include <unistd.h>
  10. int
  11. main(void)
  12. {
  13. int fd_in = 0;
  14. int fd_out = 1;
  15. off_t in_pos = 0, out_pos = 0;
  16. ssize_t ret = copy_file_range(fd_in, &in_pos, fd_out, &out_pos, SIZE_MAX, 0);
  17. return ret > 0;
  18. }