1 /* 2 * lutimes() implementation for uClibc 3 * 4 * Copyright (C) 2010 Vladimir Zapolskiy <vzapolskiy@gmail.com> 5 * 6 * Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball. 7 */ 8 9 #include <sys/syscall.h> 10 #include <time.h> 11 12 #ifdef __NR_lutimes 13 _syscall2(int, lutimes, const char *, file, const struct timeval *, tvp) 14 #elif defined __NR_utimensat 15 #include <sys/time.h> 16 #include <fcntl.h> 17 18 int lutimes(const char *file, const struct timeval tvp[2]) 19 { 20 struct timespec ts[2]; 21 22 if (tvp != NULL) 23 { 24 if (tvp[0].tv_usec < 0 || tvp[0].tv_usec >= 1000000 25 || tvp[1].tv_usec < 0 || tvp[1].tv_usec >= 1000000) 26 { 27 __set_errno(EINVAL); 28 return -1; 29 } 30 31 TIMEVAL_TO_TIMESPEC(&tvp[0], &ts[0]); 32 TIMEVAL_TO_TIMESPEC(&tvp[1], &ts[1]); 33 } 34 35 return utimensat(AT_FDCWD, file, tvp ? ts : NULL, AT_SYMLINK_NOFOLLOW); 36 } 37 #endif 38