Skip to content

Commit

Permalink
Fix setting dates on system not supporting POSIX 2008
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed May 24, 2016
1 parent 4b39747 commit f76d3e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions configure.ac
Expand Up @@ -165,6 +165,8 @@ AC_CHECK_FUNCS_ONCE([funopen])
AC_CHECK_FUNCS_ONCE([fopencookie])
AC_CHECK_FUNCS_ONCE([sysctlbyname])
AC_CHECK_FUNCS_ONCE([__res_setservers])
AC_CHECK_MEMBERS([struct stat.st_mtim])

AC_CHECK_DECLS(
[[fstatat], [openat], [unlinkat], [readlinkat], [faccessat]],
[], [], [
Expand Down
12 changes: 6 additions & 6 deletions libpkg/pkg_add.c
Expand Up @@ -270,7 +270,12 @@ set_attrs(int fd, char *path, mode_t perm, uid_t uid, gid_t gid,
static void
fill_timespec_buf(const struct stat *aest, struct timespec tspec[2])
{
#ifdef __APPLE__
#ifdef HAVE_STRUCT_STAT_ST_MTIM
tspec[0].tv_sec = aest->st_atim.tv_sec;
tspec[0].tv_nsec = aest->st_atim.tv_nsec;
tspec[1].tv_sec = aest->st_mtim.tv_sec;
tspec[1].tv_nsec = aest->st_mtim.tv_nsec;
#else
# ifdef _DARWIN_C_SOURCE
tspec[0].tv_sec = aest->st_atimespec.tv_sec;
tspec[0].tv_nsec = aest->st_atimespec.tv_nsec;
Expand All @@ -283,11 +288,6 @@ fill_timespec_buf(const struct stat *aest, struct timespec tspec[2])
tspec[1].tv_sec = aest->st_mtime;
tspec[1].tv_nsec = 0;
# endif
#else
tspec[0].tv_sec = aest->st_atim.tv_sec;
tspec[0].tv_nsec = aest->st_atim.tv_nsec;
tspec[1].tv_sec = aest->st_mtim.tv_sec;
tspec[1].tv_nsec = aest->st_mtim.tv_nsec;
#endif
}

Expand Down

0 comments on commit f76d3e6

Please sign in to comment.