This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[RFC PATCH 12/52] Y2038: add function __futimens64
Signed-off-by: Albert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
---
io/futimens.c | 9 +++++++++
sysdeps/unix/sysv/linux/arm/Versions | 1 +
sysdeps/unix/sysv/linux/futimens.c | 38 ++++++++++++++++++++++++++++++++++++
3 files changed, 48 insertions(+)
diff --git a/io/futimens.c b/io/futimens.c
index 27fc1ae6ef..516e64efde 100644
--- a/io/futimens.c
+++ b/io/futimens.c
@@ -21,6 +21,7 @@
#include <string.h>
#include <time.h>
#include <sysdep.h>
+#include <kernel_timespec.h>
/* Change the access time of the file associated with FD to TSP[0] and
@@ -32,3 +33,11 @@ futimens (int fd, const struct timespec tsp[2])
return -1;
}
stub_warning (futimens)
+
+int
+__futimens64 (int fd, const struct __timespec64 tsp[2])
+{
+ __set_errno (ENOSYS);
+ return -1;
+}
+stub_warning (__futimens64)
diff --git a/sysdeps/unix/sysv/linux/arm/Versions b/sysdeps/unix/sysv/linux/arm/Versions
index fd94c63672..08dfae2b61 100644
--- a/sysdeps/unix/sysv/linux/arm/Versions
+++ b/sysdeps/unix/sysv/linux/arm/Versions
@@ -33,5 +33,6 @@ libc {
__clock_settime64;
__clock_getres64;
__clock_nanosleep64;
+ __futimens64;
}
}
diff --git a/sysdeps/unix/sysv/linux/futimens.c b/sysdeps/unix/sysv/linux/futimens.c
index b4985e034c..64f1a35663 100644
--- a/sysdeps/unix/sysv/linux/futimens.c
+++ b/sysdeps/unix/sysv/linux/futimens.c
@@ -36,3 +36,41 @@ futimens (int fd, const struct timespec tsp[2])
/* Avoid implicit array coercion in syscall macros. */
return INLINE_SYSCALL (utimensat, 4, fd, NULL, &tsp[0], 0);
}
+
+/* 64-bit time version */
+
+extern int __y2038_linux_support;
+
+int
+__futimens64 (int fd, const struct __timespec64 tsp[2])
+{
+ struct __timespec64 ts64[2];
+ struct timespec ts32[2];
+
+ if (fd < 0)
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (EBADF);
+
+ if (__y2038_linux_support)
+ {
+ if (fd < 0)
+ return INLINE_SYSCALL_ERROR_RETURN_VALUE (EBADF);
+ ts64[0].tv_sec = tsp[0].tv_sec;
+ ts64[0].tv_nsec = tsp[0].tv_nsec;
+ ts64[0].tv_pad = 0;
+ ts64[1].tv_sec = tsp[1].tv_sec;
+ ts64[1].tv_nsec = tsp[1].tv_nsec;
+ ts64[1].tv_pad = 0;
+ return INLINE_SYSCALL (utimensat64, 4, fd, NULL, &ts64[0], 0);
+ }
+
+ if (tsp[0].tv_sec > INT_MAX || tsp[1].tv_sec > INT_MAX)
+ {
+ return EOVERFLOW;
+ }
+
+ ts32[0].tv_sec = tsp[0].tv_sec;
+ ts32[0].tv_nsec = tsp[0].tv_nsec;
+ ts32[1].tv_sec = tsp[1].tv_sec;
+ ts32[1].tv_nsec = tsp[1].tv_nsec;
+ return INLINE_SYSCALL (utimensat, 4, fd, NULL, &ts32[0], 0);
+}
--
2.11.0