aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
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
parenta318262bc0081ab83e3f3c90e50462f99148605e (diff)
downloadglibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.zip
glibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.tar.gz
glibc-52a5fe70a2c77935afe807fb6e904e512ddd894e.tar.bz2
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')
-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
-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
13 files changed, 50 insertions, 53 deletions
diff --git a/sysdeps/posix/dl-fileid.h b/sysdeps/posix/dl-fileid.h
index 0bb6794..bf437f3 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 26ebb43..86f3285 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 b7e1aee..f7f19f1 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 f11644a..1368002 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 9eb17d1..89fcfad 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 54d6046..3e8ec5c 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 5f804b3..ff38f1e 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;
}
diff --git a/sysdeps/unix/sysv/linux/fdopendir.c b/sysdeps/unix/sysv/linux/fdopendir.c
index ede43f2..32ec10e 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 df25c2a..4dfcaee 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 4020a82..48f254d 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 f37e8aa..b599a66 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 0a0048c..5dcbfef 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 899a851..9ef9f42 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);