/[tar]/tar/src/compare.c
ViewVC logotype

Diff of /tar/src/compare.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.17 by gray, Mon Nov 17 07:38:03 2003 UTC revision 1.18 by gray, Mon Nov 17 11:05:18 2003 UTC
# Line 62  diff_init (void) Line 62  diff_init (void)
62  /* Sigh about something that differs by writing a MESSAGE to stdlis,  /* Sigh about something that differs by writing a MESSAGE to stdlis,
63     given MESSAGE is nonzero.  Also set the exit status if not already.  */     given MESSAGE is nonzero.  Also set the exit status if not already.  */
64  void  void
65  report_difference (const char *fmt, ...)  report_difference (struct tar_stat_info *st, const char *fmt, ...)
66  {  {
67    if (fmt)    if (fmt)
68      {      {
# Line 98  process_rawdata (size_t bytes, char *buf Line 98  process_rawdata (size_t bytes, char *buf
98        if (status < 0)        if (status < 0)
99          {          {
100            read_error (current_stat_info.file_name);            read_error (current_stat_info.file_name);
101            report_difference (NULL);            report_difference (&current_stat_info, NULL);
102          }          }
103        else        else
104          {          {
105            report_difference (ngettext ("Could only read %lu of %lu byte",            report_difference (&current_stat_info,
106                                 ngettext ("Could only read %lu of %lu byte",
107                                         "Could only read %lu of %lu bytes",                                         "Could only read %lu of %lu bytes",
108                                         bytes),                                         bytes),
109                               (unsigned long) status, (unsigned long) bytes);                               (unsigned long) status, (unsigned long) bytes);
# Line 112  process_rawdata (size_t bytes, char *buf Line 113  process_rawdata (size_t bytes, char *buf
113    
114    if (memcmp (buffer, diff_buffer, bytes))    if (memcmp (buffer, diff_buffer, bytes))
115      {      {
116        report_difference (_("Contents differ"));        report_difference (&current_stat_info,
117                             _("Contents differ"));
118        return 0;        return 0;
119      }      }
120    
# Line 128  process_dumpdir (size_t bytes, char *buf Line 130  process_dumpdir (size_t bytes, char *buf
130  {  {
131    if (memcmp (buffer, dumpdir_cursor, bytes))    if (memcmp (buffer, dumpdir_cursor, bytes))
132      {      {
133        report_difference (_("Contents differ"));        report_difference (&current_stat_info, _("Contents differ"));
134        return 0;        return 0;
135      }      }
136    
# Line 171  read_and_process (off_t size, int (*proc Line 173  read_and_process (off_t size, int (*proc
173      }      }
174  }  }
175    
 static void  
 diff_sparse_files (void)  
 {  
   /*FIXME!!*/abort();  
 }  
   
176  /* Call either stat or lstat over STAT_DATA, depending on  /* Call either stat or lstat over STAT_DATA, depending on
177     --dereference (-h), for a file which should exist.  Diagnose any     --dereference (-h), for a file which should exist.  Diagnose any
178     problem.  Return nonzero for success, zero otherwise.  */     problem.  Return nonzero for success, zero otherwise.  */
# Line 191  get_stat_data (char const *file_name, st Line 187  get_stat_data (char const *file_name, st
187          stat_warn (file_name);          stat_warn (file_name);
188        else        else
189          stat_error (file_name);          stat_error (file_name);
190        report_difference (NULL);        report_difference (&current_stat_info, NULL);
191        return 0;        return 0;
192      }      }
193    
# Line 244  diff_archive (void) Line 240  diff_archive (void)
240    
241        if (!S_ISREG (stat_data.st_mode))        if (!S_ISREG (stat_data.st_mode))
242          {          {
243            report_difference (_("File type differs"));            report_difference (&current_stat_info, _("File type differs"));
244            skip_member ();            skip_member ();
245            goto quit;            goto quit;
246          }          }
247    
248        if ((current_stat_info.stat.st_mode & MODE_ALL) != (stat_data.st_mode & MODE_ALL))        if ((current_stat_info.stat.st_mode & MODE_ALL) !=
249          report_difference (_("Mode differs"));            (stat_data.st_mode & MODE_ALL))
250            report_difference (&current_stat_info, _("Mode differs"));
251        sys_compare_uid_gid (&stat_data, &current_stat_info.stat);  
252          if (!sys_compare_uid (&stat_data, &current_stat_info.stat))
253            report_difference (&current_stat_info, _("Uid differs"));
254          if (!sys_compare_gid (&stat_data, &current_stat_info.stat))
255            report_difference (&current_stat_info, _("Gid differs"));
256    
257        if (stat_data.st_mtime != current_stat_info.stat.st_mtime)        if (stat_data.st_mtime != current_stat_info.stat.st_mtime)
258          report_difference (_("Mod time differs"));          report_difference (&current_stat_info, _("Mod time differs"));
259        if (current_header->header.typeflag != GNUTYPE_SPARSE &&        if (current_header->header.typeflag != GNUTYPE_SPARSE &&
260            stat_data.st_size != current_stat_info.stat.st_size)            stat_data.st_size != current_stat_info.stat.st_size)
261          {          {
262            report_difference (_("Size differs"));            report_difference (&current_stat_info, _("Size differs"));
263            skip_member ();            skip_member ();
264            goto quit;            goto quit;
265          }          }
# Line 270  diff_archive (void) Line 270  diff_archive (void)
270          {          {
271            open_error (current_stat_info.file_name);            open_error (current_stat_info.file_name);
272            skip_member ();            skip_member ();
273            report_difference (NULL);            report_difference (&current_stat_info, NULL);
274            goto quit;            goto quit;
275          }          }
276    
# Line 280  diff_archive (void) Line 280  diff_archive (void)
280        /* Need to treat sparse files completely differently here.  */        /* Need to treat sparse files completely differently here.  */
281    
282        if (current_header->header.typeflag == GNUTYPE_SPARSE)        if (current_header->header.typeflag == GNUTYPE_SPARSE)
283          diff_sparse_files ();          sparse_diff_file (diff_handle, &current_stat_info);
284        else        else
285          {          {
286            if (multi_volume_option)            if (multi_volume_option)
# Line 314  diff_archive (void) Line 314  diff_archive (void)
314            break;            break;
315          if (!get_stat_data (current_stat_info.link_name, &link_data))          if (!get_stat_data (current_stat_info.link_name, &link_data))
316            break;            break;
317          sys_compare_links (&stat_data, &link_data);          if (!sys_compare_links (&stat_data, &link_data))
318              report_difference (&current_stat_info,
319                                 _("Not linked to %s"),
320                                 quote (current_stat_info.link_name));
321        }        }
322        break;        break;
323                
# Line 332  diff_archive (void) Line 335  diff_archive (void)
335                readlink_warn (current_stat_info.file_name);                readlink_warn (current_stat_info.file_name);
336              else              else
337                readlink_error (current_stat_info.file_name);                readlink_error (current_stat_info.file_name);
338              report_difference (NULL);              report_difference (&current_stat_info, NULL);
339            }            }
340          else if (status != len          else if (status != len
341                   || strncmp (current_stat_info.link_name, linkbuf, len) != 0)                   || strncmp (current_stat_info.link_name, linkbuf, len) != 0)
342            report_difference (_("Symlink differs"));            report_difference (&current_stat_info, _("Symlink differs"));
343    
344          break;          break;
345        }        }
# Line 358  diff_archive (void) Line 361  diff_archive (void)
361            : /* current_header->header.typeflag == FIFOTYPE */            : /* current_header->header.typeflag == FIFOTYPE */
362            !S_ISFIFO (stat_data.st_mode))            !S_ISFIFO (stat_data.st_mode))
363          {          {
364            report_difference (_("File type differs"));            report_difference (&current_stat_info, _("File type differs"));
365            break;            break;
366          }          }
367    
# Line 366  diff_archive (void) Line 369  diff_archive (void)
369             || current_header->header.typeflag == BLKTYPE)             || current_header->header.typeflag == BLKTYPE)
370            && current_stat_info.stat.st_rdev != stat_data.st_rdev)            && current_stat_info.stat.st_rdev != stat_data.st_rdev)
371          {          {
372            report_difference (_("Device number differs"));            report_difference (&current_stat_info, _("Device number differs"));
373            break;            break;
374          }          }
375    
376        if ((current_stat_info.stat.st_mode & MODE_ALL) != (stat_data.st_mode & MODE_ALL))        if ((current_stat_info.stat.st_mode & MODE_ALL) != (stat_data.st_mode & MODE_ALL))
377          {          {
378            report_difference (_("Mode differs"));            report_difference (&current_stat_info, _("Mode differs"));
379            break;            break;
380          }          }
381    
# Line 410  diff_archive (void) Line 413  diff_archive (void)
413    
414        if (!S_ISDIR (stat_data.st_mode))        if (!S_ISDIR (stat_data.st_mode))
415          {          {
416            report_difference (_("File type differs"));            report_difference (&current_stat_info, _("File type differs"));
417            break;            break;
418          }          }
419    
420        if ((current_stat_info.stat.st_mode & MODE_ALL) != (stat_data.st_mode & MODE_ALL))        if ((current_stat_info.stat.st_mode & MODE_ALL) != (stat_data.st_mode & MODE_ALL))
421          {          {
422            report_difference (_("Mode differs"));            report_difference (&current_stat_info, _("Mode differs"));
423            break;            break;
424          }          }
425    
# Line 437  diff_archive (void) Line 440  diff_archive (void)
440    
441          if (!S_ISREG (stat_data.st_mode))          if (!S_ISREG (stat_data.st_mode))
442            {            {
443              report_difference (_("File type differs"));              report_difference (&current_stat_info, _("File type differs"));
444              skip_member ();              skip_member ();
445              break;              break;
446            }            }
# Line 445  diff_archive (void) Line 448  diff_archive (void)
448          offset = OFF_FROM_HEADER (current_header->oldgnu_header.offset);          offset = OFF_FROM_HEADER (current_header->oldgnu_header.offset);
449          if (stat_data.st_size != current_stat_info.stat.st_size + offset)          if (stat_data.st_size != current_stat_info.stat.st_size + offset)
450            {            {
451              report_difference (_("Size differs"));              report_difference (&current_stat_info, _("Size differs"));
452              skip_member ();              skip_member ();
453              break;              break;
454            }            }
# Line 455  diff_archive (void) Line 458  diff_archive (void)
458          if (diff_handle < 0)          if (diff_handle < 0)
459            {            {
460              open_error (current_stat_info.file_name);              open_error (current_stat_info.file_name);
461              report_difference (NULL);              report_difference (&current_stat_info, NULL);
462              skip_member ();              skip_member ();
463              break;              break;
464            }            }
# Line 463  diff_archive (void) Line 466  diff_archive (void)
466          if (lseek (diff_handle, offset, SEEK_SET) < 0)          if (lseek (diff_handle, offset, SEEK_SET) < 0)
467            {            {
468              seek_error_details (current_stat_info.file_name, offset);              seek_error_details (current_stat_info.file_name, offset);
469              report_difference (NULL);              report_difference (&current_stat_info, NULL);
470              break;              break;
471            }            }
472    

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26