Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(864)

Unified Diff: fusl/src/stat/utimensat.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/stat/umask.c ('k') | fusl/src/stdio/__fclose_ca.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/stat/utimensat.c
diff --git a/fusl/src/stat/utimensat.c b/fusl/src/stat/utimensat.c
new file mode 100644
index 0000000000000000000000000000000000000000..159c8be3b3c71109f2b72c36cc2c4027683a8cf6
--- /dev/null
+++ b/fusl/src/stat/utimensat.c
@@ -0,0 +1,37 @@
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <fcntl.h>
+#include <errno.h>
+#include "syscall.h"
+
+int utimensat(int fd, const char *path, const struct timespec times[2], int flags)
+{
+ int r = __syscall(SYS_utimensat, fd, path, times, flags);
+#ifdef SYS_futimesat
+ if (r != -ENOSYS || flags) return __syscall_ret(r);
+ struct timeval *tv = 0, tmp[2];
+ if (times) {
+ int i;
+ tv = tmp;
+ for (i=0; i<2; i++) {
+ if (times[i].tv_nsec >= 1000000000ULL) {
+ if (times[i].tv_nsec == UTIME_NOW &&
+ times[1-i].tv_nsec == UTIME_NOW) {
+ tv = 0;
+ break;
+ }
+ if (times[i].tv_nsec == UTIME_OMIT)
+ return __syscall_ret(-ENOSYS);
+ return __syscall_ret(-EINVAL);
+ }
+ tmp[i].tv_sec = times[i].tv_sec;
+ tmp[i].tv_usec = times[i].tv_nsec / 1000;
+ }
+ }
+
+ r = __syscall(SYS_futimesat, fd, path, tv);
+ if (r != -ENOSYS || fd != AT_FDCWD) return __syscall_ret(r);
+ r = __syscall(SYS_utimes, path, tv);
+#endif
+ return __syscall_ret(r);
+}
« no previous file with comments | « fusl/src/stat/umask.c ('k') | fusl/src/stdio/__fclose_ca.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698