]> Dogcows Code - chaz/tar/commitdiff
--atime-preserve=replace: fix correctness and performance bugs
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Mar 2011 23:40:32 +0000 (15:40 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 7 Mar 2011 23:40:56 +0000 (15:40 -0800)
reported by Eric Blake in
<http://lists.gnu.org/archive/html/bug-tar/2011-03/msg00000.html>.
* src/compare.c (diff_file): Do not restore atime of size-zero files.
* src/create.c (dump_file0): Likewise.  Also, do not restore atime
when fd is zero, because that indicates a file we haven't opened.

src/compare.c
src/create.c

index 91ced57031925ddce030a4df2dc7f1d8decd4452..273269a140916af81a9e2c0515bace0658e254fb 100644 (file)
@@ -234,7 +234,8 @@ diff_file (void)
              else
                read_and_process (&current_stat_info, process_rawdata);
 
-             if (atime_preserve_option == replace_atime_preserve)
+             if (atime_preserve_option == replace_atime_preserve
+                 && stat_data.st_size != 0)
                {
                  struct timespec atime = get_stat_atime (&stat_data);
                  if (set_file_atime (diff_handle, chdir_fd, file_name, atime)
@@ -528,7 +529,7 @@ verify_volume (void)
   if (may_fail)
     WARN((0, 0,
          _("Verification may fail to locate original files.")));
-  
+
   if (!diff_buffer)
     diff_init ();
 
index e8de6b92463708620ed2abc937f24550d3b5020a..43b5a4c23ab1140f38180d02e2b140c9886bd031 100644 (file)
@@ -1797,6 +1797,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
+                  && fd && (is_dir || original_size != 0)
                   && set_file_atime (fd, parentfd, name, st->atime) != 0)
            utime_error (p);
        }
This page took 0.028536 seconds and 4 git commands to generate.