fallocate64.c 1.2 KB

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