diff mbox series

[RFC,30/52] Y2038: add function __utimes_t64

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

Commit Message

Albert ARIBAUD (3ADEV) Sept. 7, 2017, 10:41 p.m. UTC
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
 include/sys/time.h                   |  6 ++++++
 misc/utimes.c                        | 15 +++++++++++++++
 sysdeps/unix/sysv/linux/arm/Versions |  1 +
 sysdeps/unix/sysv/linux/utimes.c     | 31 +++++++++++++++++++++++++++++++
 4 files changed, 53 insertions(+)
diff mbox series

Patch

diff --git a/include/sys/time.h b/include/sys/time.h
index 95c431f7b3..b46873f6f4 100644
--- a/include/sys/time.h
+++ b/include/sys/time.h
@@ -20,6 +20,9 @@ 
 # include <time/sys/time.h>
 
 # ifndef _ISOMAC
+
+#  include <include/time.h>
+
 extern int __gettimeofday (struct timeval *__tv,
 			   struct timezone *__tz);
 libc_hidden_proto (__gettimeofday)
@@ -39,5 +42,8 @@  extern int __utimes (const char *__file, const struct timeval __tvp[2])
 	attribute_hidden;
 extern int __futimes (int fd, const struct timeval tvp[2]) attribute_hidden;
 
+extern int __utimes_t64 (const char *file, const struct __timeval64 tvp[2])
+	attribute_hidden;
+
 # endif
 #endif
diff --git a/misc/utimes.c b/misc/utimes.c
index 73d91ace1c..5bb1a6f963 100644
--- a/misc/utimes.c
+++ b/misc/utimes.c
@@ -37,3 +37,18 @@  __utimes (const char *file, const struct timeval tvp[2])
 weak_alias (__utimes, utimes)
 
 stub_warning (utimes)
+
+int
+__utimes_t64 (const char *file, const struct __timeval64 tvp[2])
+{
+  if (file == NULL)
+    {
+      __set_errno (EINVAL);
+      return -1;
+    }
+
+  __set_errno (ENOSYS);
+  return -1;
+}
+
+stub_warning (__utimes_t64)
diff --git a/sysdeps/unix/sysv/linux/arm/Versions b/sysdeps/unix/sysv/linux/arm/Versions
index edac9cf007..68a4cb7384 100644
--- a/sysdeps/unix/sysv/linux/arm/Versions
+++ b/sysdeps/unix/sysv/linux/arm/Versions
@@ -38,5 +38,6 @@  libc {
     __sigtimedwait64;
     __futimes64;
     __lutimes64;
+    __utimes_t64;
   }
 }
diff --git a/sysdeps/unix/sysv/linux/utimes.c b/sysdeps/unix/sysv/linux/utimes.c
index 038ff20ba0..91d1ac2b53 100644
--- a/sysdeps/unix/sysv/linux/utimes.c
+++ b/sysdeps/unix/sysv/linux/utimes.c
@@ -34,3 +34,34 @@  __utimes (const char *file, const struct timeval tvp[2])
 }
 
 weak_alias (__utimes, utimes)
+
+/* 64-bit time version */
+
+extern int __y2038_linux_support;
+
+int
+__utimes_t64 (const char *file, const struct __timeval64 tvp[2])
+{
+  struct timeval tv32[2], *tvp32 = NULL;
+
+  if (__y2038_linux_support)
+    {
+      /* TODO: implement using 64-bit time syscall */
+    }
+
+  if (tvp != NULL)
+    {
+      if (tvp[0].tv_sec > INT_MAX || tvp[1].tv_sec > INT_MAX)
+        {
+          __set_errno(EOVERFLOW);
+          return -1;
+        }
+      tv32[0].tv_sec = tvp[0].tv_sec;
+      tv32[0].tv_usec = tvp[0].tv_usec;
+      tv32[1].tv_sec = tvp[1].tv_sec;
+      tv32[1].tv_usec = tvp[1].tv_usec;
+      tvp32 = tv32;
+    }
+
+  return INLINE_SYSCALL (utimes, 2, file, tvp32);
+}