posix_fallocate64.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* Copyright (C) 2007-2019 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3. The GNU C Library is free software; you can redistribute it and/or
  4. modify it under the terms of the GNU Lesser General Public
  5. License as published by the Free Software Foundation; either
  6. version 2.1 of the License, or (at your option) any later version.
  7. The GNU C Library is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. Lesser General Public License for more details.
  11. You should have received a copy of the GNU Lesser General Public
  12. License along with the GNU C Library; if not, see
  13. <http://www.gnu.org/licenses/>. */
  14. #include <fcntl.h>
  15. #include <sysdep.h>
  16. extern int __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len);
  17. libc_hidden_proto (__posix_fallocate64_l64)
  18. #define __posix_fallocate64_l64 static internal_fallocate64
  19. #include <sysdeps/posix/posix_fallocate64.c>
  20. #undef __posix_fallocate64_l64
  21. /* Reserve storage for the data of the file associated with FD. */
  22. int
  23. __posix_fallocate64_l64 (int fd, __off64_t offset, __off64_t len)
  24. {
  25. INTERNAL_SYSCALL_DECL (err);
  26. #ifdef INTERNAL_SYSCALL_TYPES
  27. int res = INTERNAL_SYSCALL_TYPES (fallocate, err, 4, int, fd,
  28. int, 0, off_t, offset,
  29. off_t, len);
  30. #else
  31. int res = INTERNAL_SYSCALL_CALL (fallocate, err, fd, 0,
  32. SYSCALL_LL64 (offset), SYSCALL_LL64 (len));
  33. #endif
  34. if (! INTERNAL_SYSCALL_ERROR_P (res, err))
  35. return 0;
  36. if (INTERNAL_SYSCALL_ERRNO (res, err) != EOPNOTSUPP)
  37. return INTERNAL_SYSCALL_ERRNO (res, err);
  38. return internal_fallocate64 (fd, offset, len);
  39. }
  40. libc_hidden_def (__posix_fallocate64_l64)