fallocate64.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * fallocate() for uClibc - based off posix_fallocate() by Erik Andersen
  3. * http://www.opengroup.org/onlinepubs/9699919799/functions/posix_fallocate.html
  4. *
  5. * Copyright (C) 2000-2006 Erik Andersen <andersen@uclibc.org>
  6. *
  7. * Licensed under the LGPL v2.1 or later, see the file COPYING.LIB in this tarball.
  8. */
  9. #include <sys/syscall.h>
  10. #include <fcntl.h>
  11. #include <bits/kernel-features.h>
  12. #include <stdint.h>
  13. #include <errno.h>
  14. #if defined __NR_fallocate
  15. # if __WORDSIZE == 64
  16. /* Can use normal fallocate() */
  17. # elif __WORDSIZE == 32
  18. extern __typeof(fallocate64) __libc_fallocate64 attribute_hidden;
  19. int attribute_hidden __libc_fallocate64(int fd, int mode, __off64_t offset,
  20. __off64_t len)
  21. {
  22. int ret;
  23. INTERNAL_SYSCALL_DECL(err);
  24. ret = (int) (INTERNAL_SYSCALL(fallocate, err, 6, fd, mode,
  25. OFF64_HI_LO (offset), OFF64_HI_LO (len)));
  26. if (unlikely(INTERNAL_SYSCALL_ERROR_P (ret, err))) {
  27. __set_errno(INTERNAL_SYSCALL_ERRNO (ret, err));
  28. ret = -1;
  29. }
  30. return ret;
  31. }
  32. # if defined __UCLIBC_LINUX_SPECIFIC__ && defined __USE_GNU
  33. strong_alias(__libc_fallocate64,fallocate64)
  34. # endif
  35. # else
  36. # error your machine is neither 32 bit or 64 bit ... it must be magical
  37. # endif
  38. #endif