aboutsummaryrefslogtreecommitdiff
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
parenta318262bc0081ab83e3f3c90e50462f99148605e (diff)
downloadglibc-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>
-rw-r--r--csu/check_fds.c8
-rw-r--r--elf/dl-load.c8
-rw-r--r--elf/dl-misc.c4
-rw-r--r--elf/dl-profile.c4
-rw-r--r--iconv/gconv_cache.c4
-rw-r--r--include/dirent.h2
-rw-r--r--include/file_change_detection.h6
-rw-r--r--inet/rcmd.c6
-rw-r--r--intl/loadmsgcat.c4
-rw-r--r--io/Makefile4
-rw-r--r--io/file_change_detection.c10
-rw-r--r--io/getdirname.c6
-rw-r--r--libio/filedoalloc.c2
-rw-r--r--libio/fileops.c8
-rw-r--r--libio/oldfileops.c2
-rw-r--r--libio/wfileops.c2
-rw-r--r--locale/loadarchive.c8
-rw-r--r--locale/loadlocale.c6
-rw-r--r--nscd/nscd_helper.c4
-rw-r--r--nss/nss_database.c4
-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
-rw-r--r--sysvipc/ftok.c4
-rw-r--r--time/tzfile.c6
35 files changed, 106 insertions, 109 deletions
diff --git a/csu/check_fds.c b/csu/check_fds.c
index fbab28c284..6dc67334af 100644
--- a/csu/check_fds.c
+++ b/csu/check_fds.c
@@ -69,10 +69,10 @@ check_one_fd (int fd, int mode)
Note that the following code assumes that STDIN_FILENO,
STDOUT_FILENO, STDERR_FILENO are the three lowest file
decsriptor numbers, in this order. */
- struct stat64 st;
- if (__builtin_expect (nullfd != fd, 0)
- || __builtin_expect (__fstat64 (fd, &st), 0) != 0
- || __builtin_expect (S_ISCHR (st.st_mode), 1) == 0
+ struct __stat64_t64 st;
+ if (__glibc_unlikely (nullfd != fd)
+ || __glibc_likely (__fstat64_time64 (fd, &st) != 0)
+ || __glibc_unlikely (S_ISCHR (st.st_mode) == 0)
|| st.st_rdev != dev)
/* We cannot even give an error message here since it would
run into the same problems. */
diff --git a/elf/dl-load.c b/elf/dl-load.c
index 918ec7546c..a08df001af 100644
--- a/elf/dl-load.c
+++ b/elf/dl-load.c
@@ -1946,11 +1946,11 @@ open_path (const char *name, size_t namelen, int mode,
{
/* We failed to open machine dependent library. Let's
test whether there is any directory at all. */
- struct stat64 st;
+ struct __stat64_t64 st;
buf[buflen - namelen - 1] = '\0';
- if (__stat64 (buf, &st) != 0
+ if (__stat64_time64 (buf, &st) != 0
|| ! S_ISDIR (st.st_mode))
/* The directory does not exist or it is no directory. */
this_dir->status[cnt] = nonexisting;
@@ -1968,9 +1968,9 @@ open_path (const char *name, size_t namelen, int mode,
/* This is an extra security effort to make sure nobody can
preload broken shared objects which are in the trusted
directories and so exploit the bugs. */
- struct stat64 st;
+ struct __stat64_t64 st;
- if (__fstat64 (fd, &st) != 0
+ if (__fstat64_time64 (fd, &st) != 0
|| (st.st_mode & S_ISUID) == 0)
{
/* The shared object cannot be tested for being SUID
diff --git a/elf/dl-misc.c b/elf/dl-misc.c
index d4803bba4e..b256d792c6 100644
--- a/elf/dl-misc.c
+++ b/elf/dl-misc.c
@@ -43,11 +43,11 @@ void *
_dl_sysdep_read_whole_file (const char *file, size_t *sizep, int prot)
{
void *result = MAP_FAILED;
- struct stat64 st;
+ struct __stat64_t64 st;
int fd = __open64_nocancel (file, O_RDONLY | O_CLOEXEC);
if (fd >= 0)
{
- if (__fstat64 (fd, &st) >= 0)
+ if (__fstat64_time64 (fd, &st) >= 0)
{
*sizep = st.st_size;
diff --git a/elf/dl-profile.c b/elf/dl-profile.c
index 35b03959bc..088c023d95 100644
--- a/elf/dl-profile.c
+++ b/elf/dl-profile.c
@@ -185,7 +185,7 @@ _dl_start_profile (void)
{
char *filename;
int fd;
- struct stat64 st;
+ struct __stat64_t64 st;
const ElfW(Phdr) *ph;
ElfW(Addr) mapstart = ~((ElfW(Addr)) 0);
ElfW(Addr) mapend = 0;
@@ -342,7 +342,7 @@ _dl_start_profile (void)
return;
}
- if (__fstat64 (fd, &st) < 0 || !S_ISREG (st.st_mode))
+ if (__fstat64_time64 (fd, &st) < 0 || !S_ISREG (st.st_mode))
{
/* Not stat'able or not a regular file => don't use it. */
errstr = "%s: cannot stat file: %s\n";
diff --git a/iconv/gconv_cache.c b/iconv/gconv_cache.c
index 642cc731eb..68d6386d01 100644
--- a/iconv/gconv_cache.c
+++ b/iconv/gconv_cache.c
@@ -48,7 +48,7 @@ int
__gconv_load_cache (void)
{
int fd;
- struct stat64 st;
+ struct __stat64_t64 st;
struct gconvcache_header *header;
/* We cannot use the cache if the GCONV_PATH environment variable is
@@ -64,7 +64,7 @@ __gconv_load_cache (void)
return -1;
/* Get information about the file. */
- if (__builtin_expect (__fstat64 (fd, &st), 0) < 0
+ if (__glibc_unlikely (__fstat64_time64 (fd, &st) < 0)
/* We do not have to start looking at the file if it cannot contain
at least the cache header. */
|| (size_t) st.st_size < sizeof (struct gconvcache_header))
diff --git a/include/dirent.h b/include/dirent.h
index f1d7e8359c..d7567f5e86 100644
--- a/include/dirent.h
+++ b/include/dirent.h
@@ -49,7 +49,7 @@ extern int __versionsort64 (const struct dirent64 **a,
const struct dirent64 **b)
__attribute_pure__;
extern DIR *__alloc_dir (int fd, bool close_fd, int flags,
- const struct stat64 *statp)
+ const struct __stat64_t64 *statp)
__nonnull (4) attribute_hidden;
extern __typeof (rewinddir) __rewinddir;
extern __typeof (seekdir) __seekdir;
diff --git a/include/file_change_detection.h b/include/file_change_detection.h
index 9de2bd0b79..953de7c7fd 100644
--- a/include/file_change_detection.h
+++ b/include/file_change_detection.h
@@ -33,8 +33,8 @@ struct file_change_detection
off64_t size;
ino64_t ino;
- struct timespec mtime;
- struct timespec ctime;
+ struct __timespec64 mtime;
+ struct __timespec64 ctime;
};
/* Returns true if *LEFT and *RIGHT describe the same version of the
@@ -45,7 +45,7 @@ bool __file_is_unchanged (const struct file_change_detection *left,
/* Extract file change information to *FILE from the stat buffer
*ST. */
void __file_change_detection_for_stat (struct file_change_detection *file,
- const struct stat64 *st);
+ const struct __stat64_t64 *st);
/* Writes file change information for PATH to *FILE. Returns true on
success. For benign errors, *FILE is cleared, and true is
diff --git a/inet/rcmd.c b/inet/rcmd.c
index 0cfdaee15e..0d6b595572 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -468,14 +468,14 @@ ruserok (const char *rhost, int superuser, const char *ruser,
static FILE *
iruserfopen (const char *file, uid_t okuser)
{
- struct stat64 st;
+ struct __stat64_t64 st;
char *cp = NULL;
FILE *res = NULL;
/* If not a regular file, if owned by someone other than user or
root, if writeable by anyone but the owner, or if hardlinked
anywhere, quit. */
- if (__lstat64 (file, &st))
+ if (__lstat64_time64 (file, &st))
cp = _("lstat failed");
else if (!S_ISREG (st.st_mode))
cp = _("not regular file");
@@ -484,7 +484,7 @@ iruserfopen (const char *file, uid_t okuser)
res = fopen (file, "rce");
if (!res)
cp = _("cannot open");
- else if (__fstat64 (fileno (res), &st) < 0)
+ else if (__fstat64_time64 (fileno (res), &st) < 0)
cp = _("fstat failed");
else if (st.st_uid && st.st_uid != okuser)
cp = _("bad owner");
diff --git a/intl/loadmsgcat.c b/intl/loadmsgcat.c
index 4fda9b0219..9b10697dd9 100644
--- a/intl/loadmsgcat.c
+++ b/intl/loadmsgcat.c
@@ -756,7 +756,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
int fd = -1;
size_t size;
#ifdef _LIBC
- struct stat64 st;
+ struct __stat64_t64 st;
#else
struct stat st;
#endif
@@ -804,7 +804,7 @@ _nl_load_domain (struct loaded_l10nfile *domain_file,
/* We must know about the size of the file. */
if (
#ifdef _LIBC
- __builtin_expect (__fstat64 (fd, &st) != 0, 0)
+ __glibc_unlikely (__fstat64_time64 (fd, &st) != 0)
#else
__builtin_expect (fstat (fd, &st) != 0, 0)
#endif
diff --git a/io/Makefile b/io/Makefile
index ba8bd37355..1a16990205 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -69,7 +69,7 @@ tests := test-utime test-stat test-stat2 test-lfs tst-getcwd \
tst-posix_fallocate tst-posix_fallocate64 \
tst-fts tst-fts-lfs tst-open-tmpfile \
tst-copy_file_range tst-getcwd-abspath tst-lockf \
- tst-ftw-lnk tst-file_change_detection tst-lchmod \
+ tst-ftw-lnk tst-lchmod \
tst-ftw-bz26353 tst-stat tst-stat-lfs \
tst-utime \
tst-utimes \
@@ -90,7 +90,7 @@ tests-time64 := \
tst-utimes-time64 \
# Likewise for statx, but we do not need static linking here.
-tests-internal += tst-statx
+tests-internal += tst-statx tst-file_change_detection
tests-static += tst-statx
ifeq ($(run-built-tests),yes)
diff --git a/io/file_change_detection.c b/io/file_change_detection.c
index 9871bc9166..fad0907223 100644
--- a/io/file_change_detection.c
+++ b/io/file_change_detection.c
@@ -44,7 +44,7 @@ libc_hidden_def (__file_is_unchanged)
void
__file_change_detection_for_stat (struct file_change_detection *file,
- const struct stat64 *st)
+ const struct __stat64_t64 *st)
{
if (S_ISDIR (st->st_mode))
/* Treat as empty file. */
@@ -66,8 +66,8 @@ bool
__file_change_detection_for_path (struct file_change_detection *file,
const char *path)
{
- struct stat64 st;
- if (__stat64 (path, &st) != 0)
+ struct __stat64_t64 st;
+ if (__stat64_time64 (path, &st) != 0)
switch (errno)
{
case EACCES:
@@ -104,8 +104,8 @@ __file_change_detection_for_fp (struct file_change_detection *file,
}
else
{
- struct stat64 st;
- if (__fstat64 (__fileno (fp), &st) != 0)
+ struct __stat64_t64 st;
+ if (__fstat64_time64 (__fileno (fp), &st) != 0)
/* If we already have a file descriptor, all errors are fatal. */
return false;
else
diff --git a/io/getdirname.c b/io/getdirname.c
index 32b5ab4b6c..f29e910b37 100644
--- a/io/getdirname.c
+++ b/io/getdirname.c
@@ -28,12 +28,12 @@ char *
get_current_dir_name (void)
{
char *pwd;
- struct stat64 dotstat, pwdstat;
+ struct __stat64_t64 dotstat, pwdstat;
pwd = getenv ("PWD");
if (pwd != NULL
- && __stat64 (".", &dotstat) == 0
- && __stat64 (pwd, &pwdstat) == 0
+ && __stat64_time64 (".", &dotstat) == 0
+ && __stat64_time64 (pwd, &pwdstat) == 0
&& pwdstat.st_dev == dotstat.st_dev
&& pwdstat.st_ino == dotstat.st_ino)
/* The PWD value is correct. Use it. */
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index 7afa3cb683..c792eec88f 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -78,7 +78,7 @@ _IO_file_doallocate (FILE *fp)
{
size_t size;
char *p;
- struct stat64 st;
+ struct __stat64_t64 st;
size = BUFSIZ;
if (fp->_fileno >= 0 && __builtin_expect (_IO_SYSSTAT (fp, &st), 0) >= 0)
diff --git a/libio/fileops.c b/libio/fileops.c
index a71a567547..e8ee374821 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -545,7 +545,7 @@ libc_hidden_ver (_IO_new_file_underflow, _IO_file_underflow)
static int
mmap_remap_check (FILE *fp)
{
- struct stat64 st;
+ struct __stat64_t64 st;
if (_IO_SYSSTAT (fp, &st) == 0
&& S_ISREG (st.st_mode) && st.st_size != 0
@@ -663,7 +663,7 @@ decide_maybe_mmap (FILE *fp)
file descriptors are for mmap-able objects and on 32-bit
machines we don't want to map files which are too large since
this would require too much virtual memory. */
- struct stat64 st;
+ struct __stat64_t64 st;
if (_IO_SYSSTAT (fp, &st) == 0
&& S_ISREG (st.st_mode) && st.st_size != 0
@@ -962,7 +962,7 @@ _IO_new_file_seekoff (FILE *fp, off64_t offset, int dir, int mode)
break;
case _IO_seek_end:
{
- struct stat64 st;
+ struct __stat64_t64 st;
if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
{
offset += st.st_size;
@@ -1145,7 +1145,7 @@ libc_hidden_def (_IO_file_seek)
int
_IO_file_stat (FILE *fp, void *st)
{
- return __fstat64 (fp->_fileno, (struct stat64 *) st);
+ return __fstat64_time64 (fp->_fileno, (struct __stat64_t64 *) st);
}
libc_hidden_def (_IO_file_stat)
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index ed235360ad..ed3c98bd6d 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -487,7 +487,7 @@ _IO_old_file_seekoff (FILE *fp, off64_t offset, int dir, int mode)
break;
case _IO_seek_end:
{
- struct stat64 st;
+ struct __stat64_t64 st;
if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
{
offset += st.st_size;
diff --git a/libio/wfileops.c b/libio/wfileops.c
index 5d23566171..37f44780f8 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -840,7 +840,7 @@ _IO_wfile_seekoff (FILE *fp, off64_t offset, int dir, int mode)
break;
case _IO_seek_end:
{
- struct stat64 st;
+ struct __stat64_t64 st;
if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
{
offset += st.st_size;
diff --git a/locale/loadarchive.c b/locale/loadarchive.c
index 4177fc8972..512769eaec 100644
--- a/locale/loadarchive.c
+++ b/locale/loadarchive.c
@@ -78,7 +78,7 @@ static struct archmapped *archmapped;
ARCHMAPPED points to this; if mapping the archive header failed,
then headmap.ptr is null. */
static struct archmapped headmap;
-static struct stat64 archive_stat; /* stat of archive when header mapped. */
+static struct __stat64_t64 archive_stat; /* stat of archive when header mapped. */
/* Record of locales that we have already loaded from the archive. */
struct locale_in_archive
@@ -207,7 +207,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* Cannot open the archive, for whatever reason. */
return NULL;
- if (__fstat64 (fd, &archive_stat) == -1)
+ if (__fstat64_time64 (fd, &archive_stat) == -1)
{
/* stat failed, very strange. */
close_and_out:
@@ -396,7 +396,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* Open the file if it hasn't happened yet. */
if (fd == -1)
{
- struct stat64 st;
+ struct __stat64_t64 st;
fd = __open_nocancel (archfname,
O_RDONLY|O_LARGEFILE|O_CLOEXEC);
if (fd == -1)
@@ -405,7 +405,7 @@ _nl_load_locale_from_archive (int category, const char **namep)
/* Now verify we think this is really the same archive file
we opened before. If it has been changed we cannot trust
the header we read previously. */
- if (__fstat64 (fd, &st) < 0
+ if (__fstat64_time64 (fd, &st) < 0
|| st.st_size != archive_stat.st_size
|| st.st_mtime != archive_stat.st_mtime
|| st.st_dev != archive_stat.st_dev
diff --git a/locale/loadlocale.c b/locale/loadlocale.c
index 9c03490883..f4e6cc9fc2 100644
--- a/locale/loadlocale.c
+++ b/locale/loadlocale.c
@@ -167,7 +167,7 @@ _