summary refs log tree commit diff
path: root/sysdeps/unix/sysv
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/unix/sysv
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/unix/sysv')
-rw-r--r--sysdeps/unix/sysv/linux/fdopendir.c4
-rw-r--r--sysdeps/unix/sysv/linux/fexecve.c4
-rw-r--r--sysdeps/unix/sysv/linux/opendir.c7
-rw-r--r--sysdeps/unix/sysv/linux/pathconf.c5
-rw-r--r--sysdeps/unix/sysv/linux/ttyname.h10
-rw-r--r--sysdeps/unix/sysv/linux/ttyname_r.c16
6 files changed, 21 insertions, 25 deletions
diff --git a/sysdeps/unix/sysv/linux/fdopendir.c b/sysdeps/unix/sysv/linux/fdopendir.c
index ede43f2485..32ec10e206 100644
--- a/sysdeps/unix/sysv/linux/fdopendir.c
+++ b/sysdeps/unix/sysv/linux/fdopendir.c
@@ -27,9 +27,9 @@
 DIR *
 __fdopendir (int fd)
 {
-  struct stat64 statbuf;
+  struct __stat64_t64 statbuf;
 
-  if (__builtin_expect (__fstat64 (fd, &statbuf), 0) < 0)
+  if (__glibc_unlikely (__fstat64_time64 (fd, &statbuf) < 0))
     return NULL;
   if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
     {
diff --git a/sysdeps/unix/sysv/linux/fexecve.c b/sysdeps/unix/sysv/linux/fexecve.c
index df25c2acb8..4dfcaeedc1 100644
--- a/sysdeps/unix/sysv/linux/fexecve.c
+++ b/sysdeps/unix/sysv/linux/fexecve.c
@@ -58,8 +58,8 @@ fexecve (int fd, char *const argv[], char *const envp[])
 
   /* We come here only if the 'execve' call fails.  Determine whether
      /proc is mounted.  If not we return ENOSYS.  */
-  struct stat64 st;
-  if (__stat64 ("/proc/self/fd", &st) != 0 && errno == ENOENT)
+  struct __stat64_t64 st;
+  if (__stat64_time64 ("/proc/self/fd", &st) != 0 && errno == ENOENT)
     save = ENOSYS;
 
   __set_errno (save);
diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c
index 4020a826f9..48f254d169 100644
--- a/sysdeps/unix/sysv/linux/opendir.c
+++ b/sysdeps/unix/sysv/linux/opendir.c
@@ -49,8 +49,8 @@ opendir_tail (int fd)
   /* Now make sure this really is a directory and nothing changed since the
      `stat' call.  The S_ISDIR check is superfluous if O_DIRECTORY works,
      but it's cheap and we need the stat call for st_blksize anyway.  */
-  struct stat64 statbuf;
-  if (__glibc_unlikely (__fstat64 (fd, &statbuf) < 0))
+  struct __stat64_t64 statbuf;
+  if (__glibc_unlikely (__fstat64_time64 (fd, &statbuf) < 0))
     goto lose;
   if (__glibc_unlikely (! S_ISDIR (statbuf.st_mode)))
     {
@@ -88,7 +88,8 @@ __opendir (const char *name)
 weak_alias (__opendir, opendir)
 
 DIR *
-__alloc_dir (int fd, bool close_fd, int flags, const struct stat64 *statp)
+__alloc_dir (int fd, bool close_fd, int flags,
+	     const struct __stat64_t64 *statp)
 {
   /* We have to set the close-on-exit flag if the user provided the
      file descriptor.  */
diff --git a/sysdeps/unix/sysv/linux/pathconf.c b/sysdeps/unix/sysv/linux/pathconf.c
index f37e8aaf68..b599a66c93 100644
--- a/sysdeps/unix/sysv/linux/pathconf.c
+++ b/sysdeps/unix/sysv/linux/pathconf.c
@@ -65,9 +65,10 @@ distinguish_extX (const struct statfs *fsbuf, const char *file, int fd)
 {
   char buf[64];
   char path[PATH_MAX];
-  struct stat64 st;
+  struct __stat64_t64 st;
 
-  if ((file == NULL ? __fstat64 (fd, &st) : __stat64 (file, &st)) != 0)
+  if ((file == NULL ? __fstat64_time64 (fd, &st)
+		    : __stat64_time64 (file, &st)) != 0)
     /* Strange.  The statfd call worked, but stat fails.  Default to
        the more pessimistic value.  */
     return EXT2_LINK_MAX;
diff --git a/sysdeps/unix/sysv/linux/ttyname.h b/sysdeps/unix/sysv/linux/ttyname.h
index 0a0048cc02..5dcbfef973 100644
--- a/sysdeps/unix/sysv/linux/ttyname.h
+++ b/sysdeps/unix/sysv/linux/ttyname.h
@@ -25,24 +25,18 @@
    linux/Documentation/devices.txt (on linux < 4.10) or
    linux/Documentation/admin-guide/devices.txt (on linux >= 4.10).  */
 static inline bool
-is_pty (struct stat64 *sb)
+is_pty (struct __stat64_t64 *sb)
 {
-#ifdef _STATBUF_ST_RDEV
   int m = __gnu_dev_major (sb->st_rdev);
   return (136 <= m && m <= 143);
-#else
-  return false;
-#endif
 }
 
 static inline bool
-is_mytty (const struct stat64 *mytty, const struct stat64 *maybe)
+is_mytty (const struct __stat64_t64 *mytty, const struct __stat64_t64 *maybe)
 {
   return (maybe->st_ino == mytty->st_ino
 	  && maybe->st_dev == mytty->st_dev
-#ifdef _STATBUF_ST_RDEV
 	  && S_ISCHR (maybe->st_mode)
 	  && maybe->st_rdev == mytty->st_rdev
-#endif
 	  );
 }
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index 899a851a83..9ef9f42883 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -31,15 +31,15 @@
 #include "ttyname.h"
 
 static int getttyname_r (char *buf, size_t buflen,
-			 const struct stat64 *mytty, int save,
+			 const struct __stat64_t64 *mytty, int save,
 			 int *dostat);
 
 static int
 attribute_compat_text_section
-getttyname_r (char *buf, size_t buflen, const struct stat64 *mytty,
+getttyname_r (char *buf, size_t buflen, const struct __stat64_t64 *mytty,
 	      int save, int *dostat)
 {
-  struct stat64 st;
+  struct __stat64_t64 st;
   DIR *dirstream;
   struct dirent64 *d;
   size_t devlen = strlen (buf);
@@ -71,7 +71,7 @@ getttyname_r (char *buf, size_t buflen, const struct stat64 *mytty,
 	cp = __stpncpy (buf + devlen, d->d_name, needed);
 	cp[0] = '\0';
 
-	if (__stat64 (buf, &st) == 0
+	if (__stat64_time64 (buf, &st) == 0
 	    && is_mytty (mytty, &st))
 	  {
 	    (void) __closedir (dirstream);
@@ -93,7 +93,7 @@ int
 __ttyname_r (int fd, char *buf, size_t buflen)
 {
   struct fd_to_filename filename;
-  struct stat64 st, st1;
+  struct __stat64_t64 st, st1;
   int dostat = 0;
   int doispty = 0;
   int save = errno;
@@ -118,7 +118,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
   if (__glibc_unlikely (__tcgetattr (fd, &term) < 0))
     return errno;
 
-  if (__fstat64 (fd, &st) < 0)
+  if (__fstat64_time64 (fd, &st) < 0)
     return errno;
 
   /* We try using the /proc filesystem.  */
@@ -144,7 +144,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
 
       /* Verify readlink result, fall back on iterating through devices.  */
       if (buf[0] == '/'
-	  && __stat64 (buf, &st1) == 0
+	  && __stat64_time64 (buf, &st1) == 0
 	  && is_mytty (&st, &st1))
 	return 0;
 
@@ -155,7 +155,7 @@ __ttyname_r (int fd, char *buf, size_t buflen)
   memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/"));
   buflen -= sizeof ("/dev/pts/") - 1;
 
-  if (__stat64 (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
+  if (__stat64_time64 (buf, &st1) == 0 && S_ISDIR (st1.st_mode))
     {
       ret = getttyname_r (buf, buflen, &st, save,
 			  &dostat);