]> Dogcows Code - chaz/tar/blobdiff - src/incremen.c
Update copyright years.
[chaz/tar] / src / incremen.c
index 557df3090d502ce0074121f8501c4eb44af3a072..884d2fa2865831ad3a8ffec73aa617872324fa33 100644 (file)
@@ -1,6 +1,6 @@
 /* GNU dump extensions to tar.
 
-   Copyright 1988, 1992-1994, 1996-1997, 1999-2001, 2003-2009, 2013
+   Copyright 1988, 1992-1994, 1996-1997, 1999-2001, 2003-2009, 2013-2014
    Free Software Foundation, Inc.
 
    This file is part of GNU tar.
@@ -280,7 +280,7 @@ free_directory (struct directory *dir)
 static struct directory *
 attach_directory (const char *name)
 {
-  char *cname = normalize_filename (name);
+  char *cname = normalize_filename (chdir_current, name);
   struct directory *dir = make_directory (name, cname);
   if (dirtail)
     dirtail->next = dir;
@@ -370,7 +370,7 @@ find_directory (const char *name)
     return 0;
   else
     {
-      char *caname = normalize_filename (name);
+      char *caname = normalize_filename (chdir_current, name);
       struct directory *dir = make_directory (name, caname);
       struct directory *ret = hash_lookup (directory_table, dir);
       free_directory (dir);
@@ -759,7 +759,7 @@ scan_directory (struct tar_stat_info *st)
               entry = dumpdir_next (itr))
            {
              char *full_name = namebuf_name (nbuf, entry + 1);
-             
+
              if (*entry == 'I') /* Ignored entry */
                *entry = 'N';
              else if (excluded_name (full_name))
@@ -792,7 +792,7 @@ scan_directory (struct tar_stat_info *st)
                            diag = stat_diag;
                        }
                    }
-                 
+
                  if (diag)
                    {
                      file_removed_diag (full_name, false, diag);
@@ -806,7 +806,7 @@ scan_directory (struct tar_stat_info *st)
                      else if (directory->children == ALL_CHILDREN)
                        pd_flag |= PD_FORCE_CHILDREN | ALL_CHILDREN;
                      *entry = 'D';
-                     
+
                      stsub.parent = st;
                      procdir (full_name, &stsub, pd_flag, entry);
                      restore_parent_fd (&stsub);
@@ -823,7 +823,7 @@ scan_directory (struct tar_stat_info *st)
                    *entry = 'N';
                  else
                    *entry = 'Y';
-                 
+
                  tar_stat_destroy (&stsub);
                }
            }
@@ -832,7 +832,7 @@ scan_directory (struct tar_stat_info *st)
       else if (directory->tagfile)
        maketagdumpdir (directory);
     }
-  
+
   namebuf_free (nbuf);
 
   free (dirp);
@@ -1268,6 +1268,51 @@ read_incr_db_2 (void)
                _("Unexpected EOF in snapshot file")));
 }
 
+/* Display (to stdout) the range of allowed values for each field
+   in the snapshot file.  The array below should be kept in sync
+   with any changes made to the read_num() calls in the parsing
+   loop inside read_incr_db_2().
+
+   (This function is invoked via the --show-snapshot-field-ranges
+   command line option.) */
+
+struct field_range
+{
+  char const *fieldname;
+  intmax_t min_val;
+  uintmax_t max_val;
+};
+
+static struct field_range const field_ranges[] = {
+  { "nfs", 0, 1 },
+  { "timestamp_sec", TYPE_MINIMUM (time_t), TYPE_MAXIMUM (time_t) },
+  { "timestamp_nsec", 0, BILLION - 1 },
+  { "dev", TYPE_MINIMUM (dev_t), TYPE_MAXIMUM (dev_t) },
+  { "ino", TYPE_MINIMUM (ino_t), TYPE_MAXIMUM (ino_t) },
+  { NULL, 0, 0 }
+};
+
+void
+show_snapshot_field_ranges (void)
+{
+  struct field_range const *p;
+  char minbuf[SYSINT_BUFSIZE];
+  char maxbuf[SYSINT_BUFSIZE];
+
+  printf("This tar's snapshot file field ranges are\n");
+  printf ("   (%-15s => [ %s, %s ]):\n\n", "field name", "min", "max");
+
+  for (p=field_ranges; p->fieldname != NULL; p++)
+    {
+      printf ("    %-15s => [ %s, %s ],\n", p->fieldname,
+             sysinttostr (p->min_val, p->min_val, p->max_val, minbuf),
+             sysinttostr (p->max_val, p->min_val, p->max_val, maxbuf));
+
+    }
+
+  printf("\n");
+}
+
 /* Read incremental snapshot file (directory file).
    If the file has older incremental version, make sure that it is processed
    correctly and that tar will use the most conservative backup method among
@@ -1361,7 +1406,7 @@ write_directory_file_entry (void *entry, void *data)
 
   if (DIR_IS_FOUND (directory))
     {
-      char buf[max (SYSINT_BUFSIZE, INT_BUFSIZE_BOUND (intmax_t))];
+      char buf[SYSINT_BUFSIZE];
       char const *s;
 
       s = DIR_IS_NFS (directory) ? "1" : "0";
@@ -1582,7 +1627,7 @@ try_purge_directory (char const *directory_name)
   if (!is_dumpdir (&current_stat_info))
     return false;
 
-  current_dir = savedir (directory_name);
+  current_dir = tar_savedir (directory_name, 0);
 
   if (!current_dir)
     /* The directory doesn't exist now.  It'll be created.  In any
This page took 0.026963 seconds and 4 git commands to generate.