From: Markos Chandras <[email protected]>

Signed-off-by: Markos Chandras <[email protected]>
---
 libc/sysdeps/linux/common/utime.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/libc/sysdeps/linux/common/utime.c 
b/libc/sysdeps/linux/common/utime.c
index ab63a24..7977107 100644
--- a/libc/sysdeps/linux/common/utime.c
+++ b/libc/sysdeps/linux/common/utime.c
@@ -8,9 +8,29 @@
  */
 
 #include <sys/syscall.h>
+#include <fcntl.h>
+#include <stddef.h>
 #include <utime.h>
 
-#ifdef __NR_utime
+#if defined(__NR_utimensat) && !defined(__NR_utime)
+int utime(const char *file, const struct utimbuf *times)
+{
+       struct timespec tspecs[2], *ts;
+
+       if (times) {
+               ts = tspecs;
+               ts[0].tv_sec = times->actime;
+               ts[0].tv_nsec = 0;
+               ts[1].tv_sec = times->modtime;
+               ts[1].tv_nsec = 0;
+       } else {
+               ts = NULL;
+       }
+
+       return utimensat(AT_FDCWD, file, ts, 0);
+}
+
+#elif defined(__NR_utime)
 _syscall2(int, utime, const char *, file, const struct utimbuf *, times)
 #elif defined __NR_utimes /* alpha || ia64 */
 # define __need_NULL
@@ -30,7 +50,8 @@ int utime(const char *file, const struct utimbuf *times)
        return utimes(file, times ? timevals : NULL);
 }
 #endif
-#if defined __NR_utime || defined __NR_utimes
+#if (defined(__NR_utimensat) && !defined(__NR_utime)) || \
+       defined __NR_utime || defined __NR_utimes
 link_warning(utime, "the use of OBSOLESCENT `utime' is discouraged, use 
`utimes'")
 libc_hidden_def(utime)
 #endif
-- 
1.8.1.1


_______________________________________________
uClibc mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/uclibc

Reply via email to