Index: base/os_compat_android.cc |
diff --git a/base/os_compat_android.cc b/base/os_compat_android.cc |
index c4ea463d1781a4fba039e323e90bf39ee276b52d..581d518221aa9530cdeb2f99f43b2d84da06a3ee 100644 |
--- a/base/os_compat_android.cc |
+++ b/base/os_compat_android.cc |
@@ -4,22 +4,29 @@ |
#include "base/os_compat_android.h" |
+#include <asm/unistd.h> |
#include <errno.h> |
#include <math.h> |
#include <sys/stat.h> |
+#include <sys/syscall.h> |
#include <time64.h> |
#include "base/rand_util.h" |
#include "base/stringprintf.h" |
#include "base/strings/string_piece.h" |
+extern "C" { |
// There is no futimes() avaiable in Bionic, so we provide our own |
// implementation until it is there. |
-extern "C" { |
- |
int futimes(int fd, const struct timeval tv[2]) { |
- const std::string fd_path = base::StringPrintf("/proc/self/fd/%d", fd); |
- return utimes(fd_path.c_str(), tv); |
+ // Convert timeval to timespec. |
+ // timeval.usec is guaranteed to be less than one million. |
Mark Mentovai
2013/06/06 13:37:44
Guaranteed by whom? Any old user code might call t
nilesh
2013/06/06 19:03:14
Thanks. Done.
|
+ struct timespec ts[2]; |
+ ts[0].tv_sec = tv[0].tv_sec; |
Mark Mentovai
2013/06/06 13:37:44
tv is allowed to be NULL, in which case you would
nilesh
2013/06/06 19:03:14
Done.
|
+ ts[0].tv_nsec = tv[0].tv_usec * 1000; |
Mark Mentovai
2013/06/06 13:37:44
Normally you could use TIMEVAL_TO_TIMESPEC(&tv, &t
nilesh
2013/06/06 19:03:14
You are right. TIMEVAL_TO_TIMESPEC is not avialabl
|
+ ts[1].tv_sec = tv[1].tv_sec; |
+ ts[1].tv_nsec = tv[1].tv_usec * 1000; |
+ return syscall(__NR_utimensat, fd, NULL, ts, 0); |
} |
// Android has only timegm64() and no timegm(). |