diff mbox series

[RFC,39/52] Y2038: add function __utime_t64

Message ID 20170907224219.12483-40-albert.aribaud@3adev.fr
State New
Headers show
Series Make GLIBC Y2038-proof | expand

Commit Message

Albert ARIBAUD (3ADEV) Sept. 7, 2017, 10:42 p.m. UTC
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
 include/utime.h       |  7 +++++++
 io/Versions           |  1 +
 io/utime.c            | 16 ++++++++++++++++
 sysdeps/posix/utime.c | 22 ++++++++++++++++++++++
 4 files changed, 46 insertions(+)
diff mbox series

Patch

diff --git a/include/utime.h b/include/utime.h
index 5049251311..eb907f7472 100644
--- a/include/utime.h
+++ b/include/utime.h
@@ -6,4 +6,11 @@ 
 libc_hidden_proto (utime)
 #endif
 
+/* Structure describing file times, 64-bit time version.  */
+struct __utimbuf64
+  {
+    __time64_t actime;		/* Access time.  */
+    __time64_t modtime;		/* Modification time.  */
+  };
+
 #endif /* utime.h */
diff --git a/io/Versions b/io/Versions
index 33629a0d4e..622eb6fe12 100644
--- a/io/Versions
+++ b/io/Versions
@@ -134,5 +134,6 @@  libc {
     __xstat64_t64;
     __lxstat64_t64;
     __fxstatat64_t64;
+    __utime_t64;
   }
 }
diff --git a/io/utime.c b/io/utime.c
index 242ccd120a..776203896b 100644
--- a/io/utime.c
+++ b/io/utime.c
@@ -37,3 +37,19 @@  utime (const char *file, const struct utimbuf *times)
 libc_hidden_def (utime)
 
 stub_warning (utime)
+
+/* 64-bit time version */
+
+int
+__utime_t64 (const char *file, const struct utimbuf *times)
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+stub_warning (__utime_t64)
diff --git a/sysdeps/posix/utime.c b/sysdeps/posix/utime.c
index c8fe60ba91..d6662b7d4b 100644
--- a/sysdeps/posix/utime.c
+++ b/sysdeps/posix/utime.c
@@ -45,3 +45,25 @@  utime (const char *file, const struct utimbuf *times)
   return __utimes (file, tvp);
 }
 libc_hidden_def (utime)
+
+/* 64-bit time version */
+
+int
+__utime_t64 (const char *file, const struct __utimbuf64 *times)
+{
+  struct __timeval64 timevals[2];
+  struct __timeval64 *tvp;
+
+  if (times != NULL)
+    {
+      timevals[0].tv_sec = (time_t) times->actime;
+      timevals[0].tv_usec = 0L;
+      timevals[1].tv_sec = (time_t) times->modtime;
+      timevals[1].tv_usec = 0L;
+      tvp = timevals;
+    }
+  else
+    tvp = NULL;
+
+  return __utimes_t64 (file, tvp);
+}