summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-07-26 13:10:25 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-07-31 21:23:21 +0200
commit0d29df06b9ed4c21ea4598f45f57a3e9690786ce (patch)
treef93b3b749c3c43cf1b38370160516fccc45047ae
parent6f87a2f3c05b38d202ba42c5e4e59da8c8d21e9b (diff)
downloadglibc-0d29df06b9ed4c21ea4598f45f57a3e9690786ce.tar.gz
Y2038: implement Y2038-ready utime
-rw-r--r--include/utime.h7
-rw-r--r--io/Versions1
-rw-r--r--io/utime.c16
-rw-r--r--io/utime.h15
-rw-r--r--sysdeps/posix/utime.c25
5 files changed, 61 insertions, 3 deletions
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 03d621bace..6fe7b02f45 100644
--- a/io/Versions
+++ b/io/Versions
@@ -134,5 +134,6 @@ libc {
__fxstat64_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/io/utime.h b/io/utime.h
index 44a4e9cddd..3222b12e91 100644
--- a/io/utime.h
+++ b/io/utime.h
@@ -32,15 +32,24 @@ __BEGIN_DECLS
# include <bits/types/time_t.h>
#endif
-/* Structure describing file times. */
+/* Structure describing file times, 32- or 64-bit time. */
struct utimbuf
{
- __time_t actime; /* Access time. */
- __time_t modtime; /* Modification time. */
+ time_t actime; /* Access time. */
+ time_t modtime; /* Modification time. */
};
/* Set the access and modification times of FILE to those given in
*FILE_TIMES. If FILE_TIMES is NULL, set them to the current time. */
+#ifdef __USE_TIME_BITS64
+# if defined(__REDIRECT)
+extern int __REDIRECT (utime, (const char *__file,
+ const struct utimbuf *__file_times),
+ __utime_t64) __THROW __nonnull ((1));
+# else
+# define utime __utime_t64
+# endif
+#endif
extern int utime (const char *__file,
const struct utimbuf *__file_times)
__THROW __nonnull ((1));
diff --git a/sysdeps/posix/utime.c b/sysdeps/posix/utime.c
index c8fe60ba91..d9f4aaef1e 100644
--- a/sysdeps/posix/utime.c
+++ b/sysdeps/posix/utime.c
@@ -45,3 +45,28 @@ utime (const char *file, const struct utimbuf *times)
return __utimes (file, tvp);
}
libc_hidden_def (utime)
+
+/* 64-bit time version */
+
+extern int __utimes64 (const char *file,
+ const struct __timeval64 tvp[2]);
+
+int
+__utime_t64 (const char *file, const struct __utimbuf64 *times)
+{
+ struct timeval timevals[2];
+ struct timeval *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 (file, tvp);
+}