]> Dogcows Code - chaz/tar/blobdiff - src/compare.c
Fix indentation.
[chaz/tar] / src / compare.c
index 91ced57031925ddce030a4df2dc7f1d8decd4452..7c514b96e3129ab4d205bbf512d12e4990bf686e 100644 (file)
@@ -80,7 +80,7 @@ process_noop (size_t size __attribute__ ((unused)),
 static int
 process_rawdata (size_t bytes, char *buffer)
 {
-  size_t status = safe_read (diff_handle, diff_buffer, bytes);
+  size_t status = blocking_read (diff_handle, diff_buffer, bytes);
 
   if (status != bytes)
     {
@@ -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)
@@ -358,31 +359,35 @@ dumpdir_cmp (const char *a, const char *b)
 }
 
 static void
-diff_dumpdir (void)
+diff_dumpdir (struct tar_stat_info *dir)
 {
   const char *dumpdir_buffer;
-  dev_t dev = 0;
-  struct stat stat_data;
 
-  if (deref_stat (current_stat_info.file_name, &stat_data) != 0)
+  if (dir->fd == 0)
     {
-      if (errno == ENOENT)
-       stat_warn (current_stat_info.file_name);
+      void (*diag) (char const *) = NULL;
+      int fd = subfile_open (dir->parent, dir->orig_file_name, open_read_flags);
+      if (fd < 0)
+       diag = open_diag;
+      else if (fstat (fd, &dir->stat))
+       diag = stat_diag;
       else
-       stat_error (current_stat_info.file_name);
+       dir->fd = fd;
+      if (diag)
+       {
+         file_removed_diag (dir->orig_file_name, false, diag);
+         return;
+       }
     }
-  else
-    dev = stat_data.st_dev;
-
-  dumpdir_buffer = directory_contents (scan_directory (&current_stat_info));
+  dumpdir_buffer = directory_contents (scan_directory (dir));
 
   if (dumpdir_buffer)
     {
-      if (dumpdir_cmp (current_stat_info.dumpdir, dumpdir_buffer))
-       report_difference (&current_stat_info, _("Contents differ"));
+      if (dumpdir_cmp (dir->dumpdir, dumpdir_buffer))
+       report_difference (dir, _("Contents differ"));
     }
   else
-    read_and_process (&current_stat_info, process_noop);
+    read_and_process (dir, process_noop);
 }
 
 static void
@@ -460,7 +465,7 @@ diff_archive (void)
   switch (current_header->header.typeflag)
     {
     default:
-      ERROR ((0, 0, _("%s: Unknown file type `%c', diffed as normal file"),
+      ERROR ((0, 0, _("%s: Unknown file type '%c', diffed as normal file"),
              quotearg_colon (current_stat_info.file_name),
              current_header->header.typeflag));
       /* Fall through.  */
@@ -497,7 +502,7 @@ diff_archive (void)
     case GNUTYPE_DUMPDIR:
     case DIRTYPE:
       if (is_dumpdir (&current_stat_info))
-       diff_dumpdir ();
+       diff_dumpdir (&current_stat_info);
       diff_dir ();
       break;
 
@@ -528,7 +533,9 @@ verify_volume (void)
   if (may_fail)
     WARN((0, 0,
          _("Verification may fail to locate original files.")));
-  
+
+  clear_directory_table ();
+
   if (!diff_buffer)
     diff_init ();
 
This page took 0.024956 seconds and 4 git commands to generate.