[RFC PATCH 21/38] utime: prefer utimensat syscall
Jonas Bonn
jonas at southpole.se
Tue Sep 6 08:30:45 UTC 2011
Signed-off-by: Jonas Bonn <jonas at southpole.se>
---
libc/sysdeps/linux/common/utime.c | 19 ++++++++++++++++++-
1 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/libc/sysdeps/linux/common/utime.c b/libc/sysdeps/linux/common/utime.c
index c9fd1bf..5d8ca6b 100644
--- a/libc/sysdeps/linux/common/utime.c
+++ b/libc/sysdeps/linux/common/utime.c
@@ -10,8 +10,25 @@
#include <sys/syscall.h>
#include <utime.h>
+#ifdef __NR_utimensat
+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);
+}
-#ifdef __NR_utime
+#elif defined __NR_utime
_syscall2(int, utime, const char *, file, const struct utimbuf *, times)
#else
#include <stdlib.h>
--
1.7.5.4
More information about the uClibc
mailing list