futimesat.c 846 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * futimesat() for uClibc
  3. *
  4. * Copyright (C) 2009 Analog Devices Inc.
  5. *
  6. * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
  7. */
  8. #include <sys/syscall.h>
  9. #include <sys/stat.h>
  10. #include <sys/time.h>
  11. #ifdef __NR_futimesat
  12. _syscall3(int, futimesat, int, fd, const char *, file, const struct timeval *, tvp)
  13. #elif defined __NR_utimensat
  14. #include <errno.h>
  15. #define __need_NULL
  16. #include <stddef.h>
  17. int futimesat(int dirfd, const char *file, const struct timeval tvp[2])
  18. {
  19. struct timespec ts[2];
  20. if (tvp != NULL)
  21. {
  22. if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
  23. || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
  24. {
  25. __set_errno(EINVAL);
  26. return -1;
  27. }
  28. TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]);
  29. TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]);
  30. }
  31. return utimensat(dirfd, file, tvp ? ts : NULL, 0);
  32. }
  33. #endif