summaryrefslogtreecommitdiffstats
path: root/usr/klibc/utimes.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr/klibc/utimes.c')
-rw-r--r--usr/klibc/utimes.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/usr/klibc/utimes.c b/usr/klibc/utimes.c
new file mode 100644
index 0000000..74cb822
--- /dev/null
+++ b/usr/klibc/utimes.c
@@ -0,0 +1,18 @@
+#include <fcntl.h>
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <sys/syscall.h>
+
+int utimes(const char *file, const struct timeval tvp[2])
+{
+ struct timespec ts[2];
+
+ if (tvp) {
+ ts[0].tv_sec = tvp[0].tv_sec;
+ ts[0].tv_nsec = tvp[0].tv_usec * 1000;
+ ts[1].tv_sec = tvp[1].tv_sec;
+ ts[1].tv_nsec = tvp[1].tv_usec * 1000;
+ }
+
+ return utimensat(AT_FDCWD, file, &ts[0], 0);
+}