aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2017-09-08 00:41:53 +0200
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>2018-10-24 12:53:27 +0200
commit17e59e4743d1f69a831a663321adb25ab7e555c5 (patch)
treea9ef3ceb26f75a9644479a7391a4b6bbfec37aaa
parent84909c7b83f5659780ad1d419dd17848ca35e221 (diff)
downloadglibc-17e59e4743d1f69a831a663321adb25ab7e555c5.tar
glibc-17e59e4743d1f69a831a663321adb25ab7e555c5.tar.gz
glibc-17e59e4743d1f69a831a663321adb25ab7e555c5.tar.bz2
glibc-17e59e4743d1f69a831a663321adb25ab7e555c5.zip
Y2038: add function __lstat64_time64 (and __lxstat64_time64)
These implementations just use the existing syscalls and convert from kernel 32-bit-time struct stat64 to GLIBC Y2038-ready struct __stat64_t64.
-rw-r--r--include/sys/stat.h2
-rw-r--r--io/Versions1
-rw-r--r--io/lstat64.c7
-rw-r--r--sysdeps/unix/sysv/linux/lxstat64.c41
4 files changed, 51 insertions, 0 deletions
diff --git a/include/sys/stat.h b/include/sys/stat.h
index 186df0c792..72aca27341 100644
--- a/include/sys/stat.h
+++ b/include/sys/stat.h
@@ -40,6 +40,8 @@ extern int __fxstat64_time64 (int __ver, int __fildes,
struct __stat64_t64 *__stat_buf);
extern int __xstat64_time64 (int __ver, const char *__filename,
struct __stat64_t64 *__stat_buf);
+extern int __lxstat64_time64 (int __ver, const char *__filename,
+ struct __stat64_t64 *__stat_buf);
#if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
hidden_proto (__fxstat)
diff --git a/io/Versions b/io/Versions
index 821e375bae..46f9d4cd6c 100644
--- a/io/Versions
+++ b/io/Versions
@@ -135,6 +135,7 @@ libc {
GLIBC_2.29 {
__fxstat64_time64;
__xstat64_time64;
+ __lxstat64_time64;
}
GLIBC_PRIVATE {
__libc_fcntl64;
diff --git a/io/lstat64.c b/io/lstat64.c
index c3eb7a76f5..96ce9998b2 100644
--- a/io/lstat64.c
+++ b/io/lstat64.c
@@ -50,3 +50,10 @@ lstat64 (const char *file, struct stat64 *buf)
{
return __lxstat64 (_STAT_VER, file, buf);
}
+
+int
+attribute_hidden
+__lstat64_time64 (const char *file, struct __stat64_t64 *buf)
+{
+ return __lxstat64_time64 (_STAT_VER, file, buf);
+}
diff --git a/sysdeps/unix/sysv/linux/lxstat64.c b/sysdeps/unix/sysv/linux/lxstat64.c
index d05fa14537..0c55407791 100644
--- a/sysdeps/unix/sysv/linux/lxstat64.c
+++ b/sysdeps/unix/sysv/linux/lxstat64.c
@@ -50,3 +50,44 @@ hidden_ver (___lxstat64, __lxstat64)
strong_alias (___lxstat64, __lxstat64);
hidden_def (__lxstat64)
#endif
+
+/* 64-bit time version */
+
+int
+__lxstat64_time64 (int vers, const char *name, struct __stat64_t64 *buf)
+{
+ int result;
+ struct stat64 st64;
+
+ result = INLINE_SYSCALL (lstat64, 2, name, &st64);
+#if defined _HAVE_STAT64___ST_INO && !__ASSUME_ST_INO_64_BIT
+ if (__builtin_expect (!result, 1) && st64.__st_ino != (__ino_t) st64.st_ino)
+ st64.st_ino = st64.__st_ino;
+#endif
+ if (!result)
+ {
+ buf->st_dev = st64.st_dev;
+
+#if defined _HAVE_STAT64___ST_INO
+ buf->__st_ino = st64.__st_ino;
+#endif
+ buf->st_mode = st64.st_mode;
+ buf->st_nlink = st64.st_nlink;
+ buf->st_uid = st64.st_uid;
+ buf->st_gid = st64.st_gid;
+ buf->st_rdev = st64.st_rdev;
+ buf->st_size = st64.st_size;
+ buf->st_blksize = st64.st_blksize;
+
+ buf->st_blocks = st64.st_blocks;
+ buf->st_atim.tv_sec = st64.st_atim.tv_sec;
+ buf->st_atim.tv_nsec = st64.st_atim.tv_nsec;
+ buf->st_mtim.tv_sec = st64.st_mtim.tv_sec;
+ buf->st_mtim.tv_nsec = st64.st_mtim.tv_nsec;
+ buf->st_ctim.tv_sec = st64.st_ctim.tv_sec;
+ buf->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;
+
+ buf->st_ino = st64.st_ino;
+ }
+ return result;
+}