]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Y2038: add function __stat64_time64 (and __xstat64_time64)
authorAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Thu, 7 Sep 2017 22:41:52 +0000 (00:41 +0200)
committerAlbert ARIBAUD (3ADEV) <albert.aribaud@3adev.fr>
Wed, 24 Oct 2018 10:53:27 +0000 (12:53 +0200)
These implementations just use the existing syscalls and convert from
kernel 32-bit-time struct stat64 to GLIBC Y2038-ready struct __stat64_t64.

include/sys/stat.h
io/Versions
io/stat64.c
sysdeps/unix/sysv/linux/xstat64.c

index c00f7b46d75ff8574586af3cc4ebb992c8cbea2a..186df0c79278997b706de308b5ebb31aebb2c060 100644 (file)
@@ -38,6 +38,8 @@ extern int __mknod (const char *__path,
                    __mode_t __mode, __dev_t __dev);
 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);
 
 #if IS_IN (libc) || (IS_IN (rtld) && !defined NO_RTLD_HIDDEN)
 hidden_proto (__fxstat)
index 0d8f63c4515e1e835825ecc1d8ff7b329261e443..821e375bae4a26ad4c85a997b648b43332301773 100644 (file)
@@ -134,6 +134,7 @@ libc {
   }
   GLIBC_2.29 {
     __fxstat64_time64;
+    __xstat64_time64;
   }
   GLIBC_PRIVATE {
     __libc_fcntl64;
index 5020551c0f97440f3b269dea1b40fa3f4676e431..4ed632f42a169bfd2531cdad3e155f1c07a63128 100644 (file)
@@ -50,3 +50,10 @@ stat64 (const char *file, struct stat64 *buf)
 {
   return __xstat64 (_STAT_VER, file, buf);
 }
+
+int
+attribute_hidden
+__stat64_time64 (const char *file, struct __stat64_t64 *buf)
+{
+  return __xstat64_time64 (_STAT_VER, file, buf);
+}
index afc9ba2cb74aa2ee69c1a328c14624a4ebca863b..e0341c1bd39d4e7db86284405990dfe43d40447f 100644 (file)
@@ -52,3 +52,44 @@ hidden_ver (___xstat64, __xstat64)
 strong_alias (___xstat64, __xstat64)
 hidden_def (__xstat64)
 #endif
+
+/* 64-bit time version */
+
+int
+__xstat64_time64 (int vers, const char *name, struct __stat64_t64 *buf)
+{
+  int result;
+  struct stat64 st64;
+
+  result = INLINE_SYSCALL (stat64, 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;
+}