uid_t user_uid;
dev_t skip_file_dev;
ino_t skip_file_ino;
+ time_t start_time;
gid_t (*lookup_gid)(void *private, const char *gname, gid_t gid);
void (*cleanup_gid)(void *private);
fe->fixup |= TODO_TIMES;
fe->mtime = archive_entry_mtime(entry);
fe->mtime_nanos = archive_entry_mtime_nsec(entry);
- fe->atime = archive_entry_atime(entry);
- fe->atime_nanos = archive_entry_atime_nsec(entry);
+ if (archive_entry_atime_is_set(entry)) {
+ fe->atime = archive_entry_atime(entry);
+ fe->atime_nanos = archive_entry_atime_nsec(entry);
+ } else {
+ fe->atime = a->start_time;
+ fe->atime_nanos = 0;
+ }
}
if (a->deferred & TODO_FFLAGS) {
a->archive.vtable = archive_write_disk_vtable();
a->lookup_uid = trivial_lookup_uid;
a->lookup_gid = trivial_lookup_gid;
+ a->start_time = time(NULL);
#ifdef HAVE_GETEUID
a->user_uid = geteuid();
#endif /* HAVE_GETEUID */
times[1].tv_sec = archive_entry_mtime(a->entry);
times[1].tv_usec = archive_entry_mtime_nsec(a->entry) / 1000;
- times[0].tv_sec = archive_entry_atime(a->entry);
- times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000;
+ if (archive_entry_atime_is_set(a->entry)) {
+ times[0].tv_sec = archive_entry_atime(a->entry);
+ times[0].tv_usec = archive_entry_atime_nsec(a->entry) / 1000;
+ } else {
+ times[0].tv_sec = a->start_time;
+ times[0].tv_usec = 0;
+ }
#ifdef HAVE_FUTIMES
if (a->fd >= 0 && futimes(a->fd, times) == 0) {
struct utimbuf times;
times.modtime = archive_entry_mtime(a->entry);
- times.actime = archive_entry_atime(a->entry);
+ if (archive_entry_atime_is_set(a->entry))
+ times.actime = archive_entry_atime(a->entry);
+ else
+ times.actime = a->start_time;
if (!S_ISLNK(a->mode) && utime(a->name, ×) != 0) {
archive_set_error(&a->archive, errno,
"Can't update time for %s", a->name);
/* Write the entry to disk. */
assert((ad = archive_write_disk_new()) != NULL);
+ archive_write_disk_set_options(ad, ARCHIVE_EXTRACT_TIME);
failure("%s", msg);
/*
* A touchy API design issue: archive_write_data() does (as of
* the entry being a maximum size.
*/
archive_entry_set_size(ae, sizeof(data));
+ archive_entry_set_mtime(ae, 123456789, 0);
assertEqualIntA(ad, 0, archive_write_header(ad, ae));
assertEqualInt(sizeof(data), archive_write_data(ad, data, sizeof(data)));
assertEqualIntA(ad, 0, archive_write_finish_entry(ad));
-#if ARCHIVE_API_VERSION > 1
assertEqualInt(0, archive_write_finish(ad));
-#else
- archive_write_finish(ad);
-#endif
/* Test the entries on disk. */
assert(0 == stat(archive_entry_pathname(ae), &st));
failure("st.st_mode=%o archive_entry_mode(ae)=%o",
st.st_mode, archive_entry_mode(ae));
assertEqualInt(st.st_mode, (archive_entry_mode(ae) & ~UMASK));
+ failure("Old bug: if no atime specified, atime got set to Jan 1, 1970");
+ assert(st.st_atime != 0);
assertEqualInt(st.st_size, sizeof(data));
+ assertEqualInt(st.st_mtime, 123456789);
}
static void create_reg_file2(struct archive_entry *ae, const char *msg)