Skip to content

Commit

Permalink
Y2038: fxstat64: Use statx to read {amc}time attributes for file
Browse files Browse the repository at this point in the history
The fxstat64 differs from lxstat64 in a way it access the file for which
it reads the attribute.

In the former the file descriptor (fd) is used.

Signed-off-by: Lukasz Majewski <lukma@denx.de>
  • Loading branch information
Lukasz Majewski committed Aug 28, 2019
1 parent d79192c commit 57841b6
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion sysdeps/unix/sysv/linux/fxstatat64.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <sys/syscall.h>

#include <statx_cp.h>
#include <fcntl.h>

/* Get information about the file NAME in BUF. */

Expand Down Expand Up @@ -94,7 +95,23 @@ __fxstatat64_time64 (int vers, int fd, const char *file, struct __stat64_t64 *bu
buf->st_ctim.tv_nsec = st64.st_ctim.tv_nsec;

buf->st_ino = st64.st_ino;


/* For Y2038 being safe we provide explicitly 64 bit time data types
via statx - as fstat{64} syscall can only handle 32bits. */
# ifdef __NR_statx
struct statx stx;
result = INLINE_SYSCALL_CALL (statx, fd, NULL, AT_EMPTY_PATH,
STATX_ATIME | STATX_MTIME | STATX_CTIME,
&stx);
if (!result) {
buf->st_atim.tv_sec = stx.stx_atime.tv_sec;
buf->st_atim.tv_nsec = stx.stx_atime.tv_nsec;
buf->st_mtim.tv_sec = stx.stx_mtime.tv_sec;
buf->st_mtim.tv_nsec = stx.stx_mtime.tv_nsec;
buf->st_ctim.tv_sec = stx.stx_ctime.tv_sec;
buf->st_ctim.tv_nsec = stx.stx_ctime.tv_nsec;
}
# endif
return 0;
}
else
Expand Down

0 comments on commit 57841b6

Please sign in to comment.