X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fcreate.c;h=6eedb2efc6e1dafb668311d8ffe01cbd45287e40;hb=ecbcb7b6d74c2d69386c8d7e435486a4690c9993;hp=5e2171b561917a74c2bde424a9eb7e0648c970a0;hpb=8da503cad6e883b30c05749149084d24319063b4;p=chaz%2Ftar diff --git a/src/create.c b/src/create.c index 5e2171b..6eedb2e 100644 --- a/src/create.c +++ b/src/create.c @@ -1263,49 +1263,10 @@ open_failure_recover (struct tar_stat_info const *dir) char * get_directory_entries (struct tar_stat_info *st) { - DIR *dirstream; - while (! (dirstream = fdopendir (st->fd)) && open_failure_recover (st)) - continue; - - if (! dirstream) - return 0; - else - { - char *entries = streamsavedir (dirstream); - int streamsavedir_errno = errno; - - int fd = dirfd (dirstream); - if (fd < 0) - { - /* The dirent.h implementation doesn't use file descriptors - for directory streams, so open the directory again. */ - char const *name = st->orig_file_name; - if (closedir (dirstream) != 0) - close_diag (name); - dirstream = 0; - fd = subfile_open (st->parent, - st->parent ? last_component (name) : name, - open_searchdir_flags); - if (fd < 0) - fd = - errno; - else - { - struct stat dirst; - if (! (fstat (fd, &dirst) == 0 - && st->stat.st_ino == dirst.st_ino - && st->stat.st_dev == dirst.st_dev)) - { - close (fd); - fd = - IMPOSTOR_ERRNO; - } - } - } - - st->fd = fd; - st->dirstream = dirstream; - errno = streamsavedir_errno; - return entries; - } + while (! (st->dirstream = fdopendir (st->fd))) + if (! open_failure_recover (st)) + return 0; + return streamsavedir (st->dirstream); } /* Dump the directory ST. Return true if successful, false (emitting @@ -1649,7 +1610,6 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) char type; off_t original_size; struct timespec original_ctime; - struct timespec restore_times[2]; off_t block_ordinal = -1; int fd = 0; bool is_dir; @@ -1693,8 +1653,8 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) } st->archive_file_size = original_size = st->stat.st_size; - st->atime = restore_times[0] = get_stat_atime (&st->stat); - st->mtime = restore_times[1] = get_stat_mtime (&st->stat); + st->atime = get_stat_atime (&st->stat); + st->mtime = get_stat_mtime (&st->stat); st->ctime = original_ctime = get_stat_ctime (&st->stat); #ifdef S_ISHIDDEN @@ -1833,7 +1793,7 @@ dump_file0 (struct tar_stat_info *st, char const *name, char const *p) set_exit_status (TAREXIT_DIFFERS); } else if (atime_preserve_option == replace_atime_preserve - && set_file_atime (fd, p, restore_times) != 0) + && set_file_atime (fd, p, st->atime, fstatat_flags) != 0) utime_error (p); }