| OLD | NEW |
| 1 #include <sys/stat.h> | 1 #include <sys/stat.h> |
| 2 #include <sys/time.h> | 2 #include <sys/time.h> |
| 3 #include <fcntl.h> | 3 #include <fcntl.h> |
| 4 #include <errno.h> | 4 #include <errno.h> |
| 5 #include "syscall.h" | 5 #include "syscall.h" |
| 6 | 6 |
| 7 int utimensat(int fd, const char *path, const struct timespec times[2], int flag
s) | 7 int utimensat(int fd, |
| 8 { | 8 const char* path, |
| 9 » int r = __syscall(SYS_utimensat, fd, path, times, flags); | 9 const struct timespec times[2], |
| 10 int flags) { |
| 11 int r = __syscall(SYS_utimensat, fd, path, times, flags); |
| 10 #ifdef SYS_futimesat | 12 #ifdef SYS_futimesat |
| 11 » if (r != -ENOSYS || flags) return __syscall_ret(r); | 13 if (r != -ENOSYS || flags) |
| 12 » struct timeval *tv = 0, tmp[2]; | 14 return __syscall_ret(r); |
| 13 » if (times) { | 15 struct timeval *tv = 0, tmp[2]; |
| 14 » » int i; | 16 if (times) { |
| 15 » » tv = tmp; | 17 int i; |
| 16 » » for (i=0; i<2; i++) { | 18 tv = tmp; |
| 17 » » » if (times[i].tv_nsec >= 1000000000ULL) { | 19 for (i = 0; i < 2; i++) { |
| 18 » » » » if (times[i].tv_nsec == UTIME_NOW && | 20 if (times[i].tv_nsec >= 1000000000ULL) { |
| 19 » » » » times[1-i].tv_nsec == UTIME_NOW) { | 21 if (times[i].tv_nsec == UTIME_NOW && |
| 20 » » » » » tv = 0; | 22 times[1 - i].tv_nsec == UTIME_NOW) { |
| 21 » » » » » break; | 23 tv = 0; |
| 22 » » » » } | 24 break; |
| 23 » » » » if (times[i].tv_nsec == UTIME_OMIT) | 25 } |
| 24 » » » » » return __syscall_ret(-ENOSYS); | 26 if (times[i].tv_nsec == UTIME_OMIT) |
| 25 » » » » return __syscall_ret(-EINVAL); | 27 return __syscall_ret(-ENOSYS); |
| 26 » » » } | 28 return __syscall_ret(-EINVAL); |
| 27 » » » tmp[i].tv_sec = times[i].tv_sec; | 29 } |
| 28 » » » tmp[i].tv_usec = times[i].tv_nsec / 1000; | 30 tmp[i].tv_sec = times[i].tv_sec; |
| 29 » » } | 31 tmp[i].tv_usec = times[i].tv_nsec / 1000; |
| 30 » } | 32 } |
| 33 } |
| 31 | 34 |
| 32 » r = __syscall(SYS_futimesat, fd, path, tv); | 35 r = __syscall(SYS_futimesat, fd, path, tv); |
| 33 » if (r != -ENOSYS || fd != AT_FDCWD) return __syscall_ret(r); | 36 if (r != -ENOSYS || fd != AT_FDCWD) |
| 34 » r = __syscall(SYS_utimes, path, tv); | 37 return __syscall_ret(r); |
| 38 r = __syscall(SYS_utimes, path, tv); |
| 35 #endif | 39 #endif |
| 36 » return __syscall_ret(r); | 40 return __syscall_ret(r); |
| 37 } | 41 } |
| OLD | NEW |