futimesat.c 824 B

1234567891011121314151617181920212223242526272829303132333435363738
  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/time.h>
  10. #ifdef __NR_futimesat
  11. _syscall3(int, futimesat, int, fd, const char *, file, const struct timeval *, tvp)
  12. #elif defined __NR_utimensat
  13. #include <errno.h>
  14. #define __need_NULL
  15. #include <stddef.h>
  16. int futimesat(int dirfd, const char *file, const struct timeval tvp[2])
  17. {
  18. struct timespec ts[2];
  19. if (tvp != NULL)
  20. {
  21. if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000
  22. || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000)
  23. {
  24. __set_errno(EINVAL);
  25. return -1;
  26. }
  27. TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]);
  28. TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]);
  29. }
  30. return utimensat(dirfd, file, tvp ? ts : NULL, 0);
  31. }
  32. #endif