Skip to content

Commit

Permalink
y2038: xstat64: Use statx Linux syscall to read file timestamp beyond…
Browse files Browse the repository at this point in the history
… y2038

Signed-off-by: Lukasz Majewski <lukma@denx.de>
  • Loading branch information
Lukasz Majewski committed Jul 29, 2019
1 parent 1d0ad29 commit c74c19a
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions sysdeps/unix/sysv/linux/xstat64.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,23 @@ __xstat64_time64 (int vers, const char *name, struct __stat64_t64 *buf)
buf->st_ctim.tv_pad = 0;

buf->st_ino = st64.st_ino;

/* For Y2038 being safe we provide explicitly 64 bit time data types
via statx - as stat{64} syscall can only handle 32bits. */
#ifdef __NR_statx
struct statx stx;
result = INLINE_SYSCALL_CALL (statx, 0, name, 0,
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 result;
}

0 comments on commit c74c19a

Please sign in to comment.