pwritev64v2.c 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* Linux implementation of pwritev2 (LFS version).
  2. Copyright (C) 2017-2019 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <http://www.gnu.org/licenses/>. */
  15. #include <sys/uio.h>
  16. #include <sysdep-cancel.h>
  17. #if !defined(__NR_pwritev64v2) && defined(__NR_pwritev2)
  18. # define __NR_pwritev64v2 __NR_pwritev2
  19. #endif
  20. ssize_t
  21. pwritev64v2 (int fd, const struct iovec *vector, int count, off64_t offset,
  22. int flags)
  23. {
  24. #ifdef __NR_pwritev64v2
  25. ssize_t result = SYSCALL_CANCEL (pwritev64v2, fd, vector, count,
  26. LO_HI_LONG (offset), flags);
  27. if (result >= 0 || errno != ENOSYS)
  28. return result;
  29. #endif
  30. /* Trying to emulate the pwritev2 syscall flags is troublesome:
  31. * We can not temporary change the file state of the O_DSYNC and O_SYNC
  32. flags to emulate RWF_{D}SYNC (attempts to change the state of using
  33. fcntl are silently ignored).
  34. * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
  35. semantic not provided by any other flag (O_NONBLOCK for instance). */
  36. if (flags != 0)
  37. {
  38. __set_errno (ENOTSUP);
  39. return -1;
  40. }
  41. if (offset == -1)
  42. return __writev (fd, vector, count);
  43. else
  44. return pwritev64 (fd, vector, count, offset);
  45. }
  46. #ifdef __OFF_T_MATCHES_OFF64_T
  47. strong_alias (pwritev64v2, pwritev2)
  48. #endif