about summary refs log tree commit diff
path: root/sysdeps/posix
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-03-02 17:06:02 -0300
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-06-22 12:09:52 -0300
commit52a5fe70a2c77935afe807fb6e904e512ddd894e (patch)
treee17476a3ebc60b2e00aea93f24227199caaee8d4 /sysdeps/posix
parenta318262bc0081ab83e3f3c90e50462f99148605e (diff)
downloadglibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.tar.gz
glibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.tar.xz
glibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.zip
Use 64 bit time_t stat internally
For the legacy ABI with supports 32-bit time_t it calls the 64-bit
time directly, since the LFS symbols calls the 64-bit time_t ones
internally.

Checked on i686-linux-gnu and x86_64-linux-gnu.

Reviewed-by: Lukasz Majewski <lukma@denx.de>
Diffstat (limited to 'sysdeps/posix')
-rw-r--r--sysdeps/posix/dl-fileid.h4
-rw-r--r--sysdeps/posix/euidaccess.c4
-rw-r--r--sysdeps/posix/getaddrinfo.c18
-rw-r--r--sysdeps/posix/getcwd.c15
-rw-r--r--sysdeps/posix/pathconf.c4
-rw-r--r--sysdeps/posix/sysconf.c4
-rw-r--r--sysdeps/posix/tempname.c8
7 files changed, 29 insertions, 28 deletions
diff --git a/sysdeps/posix/dl-fileid.h b/sysdeps/posix/dl-fileid.h
index 0bb6794dbe..bf437f3d71 100644
--- a/sysdeps/posix/dl-fileid.h
+++ b/sysdeps/posix/dl-fileid.h
@@ -32,9 +32,9 @@ struct r_file_id
 static inline bool
 _dl_get_file_id (int fd, struct r_file_id *id)
 {
-  struct stat64 st;
+  struct __stat64_t64 st;
 
-  if (__glibc_unlikely (__fstat64 (fd, &st) < 0))
+  if (__glibc_unlikely (__fstat64_time64 (fd, &st) < 0))
     return false;
 
   id->dev = st.st_dev;
diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c
index 26ebb432a2..86f3285471 100644
--- a/sysdeps/posix/euidaccess.c
+++ b/sysdeps/posix/euidaccess.c
@@ -119,7 +119,7 @@ int group_member ();
 int
 euidaccess (const char *path, int mode)
 {
-  struct stat64 stats;
+  struct __stat64_t64 stats;
   int granted;
 
 #ifdef	_LIBC
@@ -140,7 +140,7 @@ euidaccess (const char *path, int mode)
     return access (path, mode);
 #endif
 
-  if (__stat64 (path, &stats))
+  if (__stat64_time64 (path, &stats))
     return -1;
 
   mode &= (X_OK | W_OK | R_OK);	/* Clear any bogus bits. */
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index b7e1aee80f..f7f19f1d7c 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -1636,16 +1636,16 @@ static int gaiconf_reload_flag_ever_set;
 /* Last modification time.  */
 #ifdef _STATBUF_ST_NSEC
 
-static struct timespec gaiconf_mtime;
+static struct __timespec64 gaiconf_mtime;
 
 static inline void
-save_gaiconf_mtime (const struct stat64 *st)
+save_gaiconf_mtime (const struct __stat64_t64 *st)
 {
   gaiconf_mtime = st->st_mtim;
 }
 
 static inline bool
-check_gaiconf_mtime (const struct stat64 *st)
+check_gaiconf_mtime (const struct __stat64_t64 *st)
 {
   return (st->st_mtim.tv_sec == gaiconf_mtime.tv_sec
           && st->st_mtim.tv_nsec == gaiconf_mtime.tv_nsec);
@@ -1656,13 +1656,13 @@ check_gaiconf_mtime (const struct stat64 *st)
 static time_t gaiconf_mtime;
 
 static inline void
-save_gaiconf_mtime (const struct stat64 *st)
+save_gaiconf_mtime (const struct __stat64_t64 *st)
 {
   gaiconf_mtime = st->st_mtime;
 }
 
 static inline bool
-check_gaiconf_mtime (const struct stat64 *st)
+check_gaiconf_mtime (const struct __stat64_t64 *st)
 {
   return st->st_mtime == gaiconf_mtime;
 }
@@ -1777,8 +1777,8 @@ gaiconf_init (void)
   FILE *fp = fopen (GAICONF_FNAME, "rce");
   if (fp != NULL)
     {
-      struct stat64 st;
-      if (__fstat64 (fileno (fp), &st) != 0)
+      struct __stat64_t64 st;
+      if (__fstat64_time64 (fileno (fp), &st) != 0)
 	{
 	  fclose (fp);
 	  goto no_file;
@@ -2130,8 +2130,8 @@ gaiconf_init (void)
 static void
 gaiconf_reload (void)
 {
-  struct stat64 st;
-  if (__stat64 (GAICONF_FNAME, &st) != 0
+  struct __stat64_t64 st;
+  if (__stat64_time64 (GAICONF_FNAME, &st) != 0
       || !check_gaiconf_mtime (&st))
     gaiconf_init ();
 }
diff --git a/sysdeps/posix/getcwd.c b/sysdeps/posix/getcwd.c
index f11644aae7..13680026ff 100644
--- a/sysdeps/posix/getcwd.c
+++ b/sysdeps/posix/getcwd.c
@@ -183,7 +183,7 @@ __getcwd_generic (char *buf, size_t size)
   ino_t rootino, thisino;
   char *dir;
   register char *dirp;
-  struct stat64 st;
+  struct __stat64_t64 st;
   size_t allocated = size;
   size_t used;
 
@@ -249,12 +249,12 @@ __getcwd_generic (char *buf, size_t size)
   dirp = dir + allocated;
   *--dirp = '\0';
 
-  if (__lstat64 (".", &st) < 0)
+  if (__lstat64_time64 (".", &st) < 0)
     goto lose;
   thisdev = st.st_dev;
   thisino = st.st_ino;
 
-  if (__lstat64 ("/", &st) < 0)
+  if (__lstat64_time64 ("/", &st) < 0)
     goto lose;
   rootdev = st.st_dev;
   rootino = st.st_ino;
@@ -276,12 +276,12 @@ __getcwd_generic (char *buf, size_t size)
       if (fd < 0)
         goto lose;
       fd_needs_closing = true;
-      parent_status = __fstat64 (fd, &st);
+      parent_status = __fstat64_time64 (fd, &st);
 #else
       dotlist[dotlen++] = '.';
       dotlist[dotlen++] = '.';
       dotlist[dotlen] = '\0';
-      parent_status = __lstat64 (dotlist, &st);
+      parent_status = __lstat64_time64 (dotlist, &st);
 #endif
       if (parent_status != 0)
         goto lose;
@@ -353,7 +353,8 @@ __getcwd_generic (char *buf, size_t size)
           {
             int entry_status;
 #if HAVE_OPENAT_SUPPORT
-            entry_status = __fstatat64 (fd, d->d_name, &st, AT_SYMLINK_NOFOLLOW);
+            entry_status = __fstatat64_time64 (fd, d->d_name, &st,
+					       AT_SYMLINK_NOFOLLOW);
 #else
             /* Compute size needed for this file name, or for the file
                name ".." in the same directory, whichever is larger.
@@ -390,7 +391,7 @@ __getcwd_generic (char *buf, size_t size)
               }
 
             memcpy (dotlist + dotlen, d->d_name, _D_ALLOC_NAMLEN (d));
-            entry_status = __lstat64 (dotlist, &st);
+            entry_status = __lstat64_time64 (dotlist, &st);
 #endif
             /* We don't fail here if we cannot stat() a directory entry.
                This can happen when (network) file systems fail.  If this
diff --git a/sysdeps/posix/pathconf.c b/sysdeps/posix/pathconf.c
index 9eb17d1536..89fcfad49d 100644
--- a/sysdeps/posix/pathconf.c
+++ b/sysdeps/posix/pathconf.c
@@ -129,9 +129,9 @@ __pathconf (const char *path, int name)
 #ifdef	_POSIX_ASYNC_IO
       {
 	/* AIO is only allowed on regular files and block devices.  */
-	struct stat64 st;
+	struct __stat64_t64 st;
 
-	if (__stat64 (path, &st) < 0
+	if (__stat64_time64 (path, &st) < 0
 	    || (! S_ISREG (st.st_mode) && ! S_ISBLK (st.st_mode)))
 	  return -1;
 	else
diff --git a/sysdeps/posix/sysconf.c b/sysdeps/posix/sysconf.c
index 54d6046d00..3e8ec5cd51 100644
--- a/sysdeps/posix/sysconf.c
+++ b/sysdeps/posix/sysconf.c
@@ -1215,8 +1215,8 @@ __sysconf_check_spec (const char *spec)
 		   "/POSIX_V6_", sizeof ("/POSIX_V6_") - 1),
 	  spec, speclen + 1);
 
-  struct stat64 st;
-  long int ret = __stat64 (name, &st) >= 0 ? 1 : -1;
+  struct __stat64_t64 st;
+  long int ret = __stat64_time64 (name, &st) >= 0 ? 1 : -1;
 
   __set_errno (save_errno);
   return ret;
diff --git a/sysdeps/posix/tempname.c b/sysdeps/posix/tempname.c
index 5f804b38d7..ff38f1e31f 100644
--- a/sysdeps/posix/tempname.c
+++ b/sysdeps/posix/tempname.c
@@ -55,14 +55,14 @@
 #include <time.h>
 
 #if _LIBC
-# define struct_stat64 struct stat64
+# define struct_stat64 struct __stat64_t64
 # define __secure_getenv __libc_secure_getenv
 #else
 # define struct_stat64 struct stat
 # define __gen_tempname gen_tempname
 # define __mkdir mkdir
 # define __open open
-# define __lstat64(file, buf) lstat (file, buf)
+# define __lstat64_time64(file, buf) lstat (file, buf)
 # define __stat64(file, buf) stat (file, buf)
 # define __getrandom getrandom
 # define __clock_gettime64 clock_gettime
@@ -99,7 +99,7 @@ static int
 direxists (const char *dir)
 {
   struct_stat64 buf;
-  return __stat64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
+  return __stat64_time64 (dir, &buf) == 0 && S_ISDIR (buf.st_mode);
 }
 
 /* Path search algorithm, for tmpnam, tmpfile, etc.  If DIR is
@@ -191,7 +191,7 @@ try_nocreate (char *tmpl, void *flags _GL_UNUSED)
 {
   struct_stat64 st;
 
-  if (__lstat64 (tmpl, &st) == 0 || errno == EOVERFLOW)
+  if (__lstat64_time64 (tmpl, &st) == 0 || errno == EOVERFLOW)
     __set_errno (EEXIST);
   return errno == ENOENT ? 0 : -1;
 }