futimesat.c 512 B

12345678910111213141516171819202122
  1. #define _GNU_SOURCE
  2. #include <sys/time.h>
  3. #include <sys/stat.h>
  4. #include <errno.h>
  5. #include "syscall.h"
  6. int __futimesat(int dirfd, const char *pathname, const struct timeval times[2])
  7. {
  8. struct timespec ts[2];
  9. if (times) {
  10. int i;
  11. for (i=0; i<2; i++) {
  12. if (times[i].tv_usec >= 1000000ULL)
  13. return __syscall_ret(-EINVAL);
  14. ts[i].tv_sec = times[i].tv_sec;
  15. ts[i].tv_nsec = times[i].tv_usec * 1000;
  16. }
  17. }
  18. return utimensat(dirfd, pathname, times ? ts : 0, 0);
  19. }
  20. weak_alias(__futimesat, futimesat);