Skip to content

Commit

Permalink
Merge pull request #1028 from FedorLap2006/stat-time-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennisbonke authored Apr 2, 2024
2 parents fd6373e + cd2e1b1 commit bbb349b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
5 changes: 5 additions & 0 deletions abis/linux/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,11 @@ struct stat {
long tv_nsec;
} __st_atim32, __st_mtim32, __st_ctim32;
ino_t st_ino;

// These fields are not in the ABI. Their values are
// copied from __st_atim32, __st_mtim32, __st_ctim32
// accordingly.

struct timespec st_atim;
struct timespec st_mtim;
struct timespec st_ctim;
Expand Down
13 changes: 12 additions & 1 deletion sysdeps/linux/generic/sysdeps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,19 @@ int sys_stat(fsfd_target fsfdt, int fd, const char *path, int flags, struct stat
#else
auto ret = do_cp_syscall(SYS_fstatat64, fd, path, statbuf, flags);
#endif
if (int e = sc_error(ret); e)
if (int e = sc_error(ret); e) {
return e;
}

#if defined(__i386__)
statbuf->st_atim.tv_sec = statbuf->__st_atim32.tv_sec;
statbuf->st_atim.tv_nsec = statbuf->__st_atim32.tv_nsec;
statbuf->st_mtim.tv_sec = statbuf->__st_mtim32.tv_sec;
statbuf->st_mtim.tv_nsec = statbuf->__st_mtim32.tv_nsec;
statbuf->st_ctim.tv_sec = statbuf->__st_ctim32.tv_sec;
statbuf->st_ctim.tv_nsec = statbuf->__st_ctim32.tv_nsec;
#endif

return 0;
}

Expand Down

0 comments on commit bbb349b

Please sign in to comment.