posix_fallocate.c 752 B

12345678910111213141516171819202122232425262728
  1. /* vi: set sw=4 ts=4: */
  2. /*
  3. * posix_fallocate() for uClibc
  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. extern __typeof(fallocate) __libc_fallocate attribute_hidden;
  17. int posix_fallocate(int fd, __off_t offset, __off_t len)
  18. {
  19. if (__libc_fallocate(fd, 0, offset, len))
  20. return errno;
  21. return 0;
  22. }
  23. # if defined __UCLIBC_HAS_LFS__ && __WORDSIZE == 64
  24. strong_alias(posix_fallocate,posix_fallocate64)
  25. # endif
  26. #endif