]> Dogcows Code - chaz/tar/blobdiff - src/incremen.c
Update invocations of name_scan.
[chaz/tar] / src / incremen.c
index b5eec8f0eaaad687c7d379990be5a829addcfddf..d4ef30a1add3af2cb526d79f52026f45528a4320 100644 (file)
@@ -150,6 +150,7 @@ procdir (char *name_buffer, struct stat *stat_data,
 { 
   struct directory *directory;
   bool nfs = NFS_FILE_STAT (*stat_data);
+  struct name *np;
   
   if ((directory = find_directory (name_buffer)) != NULL)
     {
@@ -202,8 +203,12 @@ procdir (char *name_buffer, struct stat *stat_data,
        ? ALL_CHILDREN
        : CHANGED_CHILDREN;
     }
-  
-  if (one_file_system_option && device != stat_data->st_dev)
+
+  /* If the directory is on another device and --one-file-system was given,
+     omit it... */
+  if (one_file_system_option && device != stat_data->st_dev
+      /* ... except if it was explicitely given in the command line */
+      && !((np = name_scan (name_buffer, true)) && np->explicit))
     directory->children = NO_CHILDREN;
   else if (children == ALL_CHILDREN)
     directory->children = ALL_CHILDREN;
@@ -361,6 +366,20 @@ get_directory_contents (char *dir_name, dev_t device)
   return buffer;
 }
 
+size_t
+dumpdir_size (const char *p)
+{
+  size_t totsize = 0;
+
+  while (*p)
+    {
+      size_t size = strlen (p) + 1;
+      totsize += size;
+      p += size;
+    }
+  return totsize + 1;  
+}
+
 \f
 
 static FILE *listed_incremental_stream;
@@ -440,7 +459,7 @@ read_directory_file (void)
        incremental_version = 0;
 
       if (incremental_version > TAR_INCREMENTAL_VERSION)
-       ERROR((1, 0, _("Unsupported incremental format version: %s"),
+       ERROR((1, 0, _("Unsupported incremental format version: %d"),
               incremental_version));
       
       t = u = (errno = 0, strtoumax (buf, &ebuf, 10));
@@ -617,43 +636,31 @@ write_directory_file (void)
 \f
 /* Restoration of incremental dumps.  */
 
-/* Examine the directories under directory_name and delete any
-   files that were not there at the time of the back-up. */
 void
-purge_directory (char const *directory_name)
+get_gnu_dumpdir ()
 {
-  char *archive_dir;
-  char *current_dir;
-  char *cur, *arc;
   size_t size;
   size_t copied;
   union block *data_block;
   char *to;
-
-  current_dir = savedir (directory_name);
-
-  if (!current_dir)
-    {
-      /* The directory doesn't exist now.  It'll be created.  In any
-        case, we don't have to delete any files out of it.  */
-
-      skip_member ();
-      return;
-    }
-
+  char *archive_dir;
+  
   size = current_stat_info.stat.st_size;
   if (size != current_stat_info.stat.st_size)
     xalloc_die ();
+
   archive_dir = xmalloc (size);
   to = archive_dir;
+
+  set_next_block_after (current_header);
+  mv_begin (&current_stat_info);
+
   for (; size > 0; size -= copied)
     {
+      mv_size_left (size);
       data_block = find_next_block ();
       if (!data_block)
-       {
-         ERROR ((0, 0, _("Unexpected EOF in archive")));
-         break;                /* FIXME: What happens then?  */
-       }
+       ERROR ((1, 0, _("Unexpected EOF in archive")));
       copied = available_space_after (data_block);
       if (copied > size)
        copied = size;
@@ -663,9 +670,42 @@ purge_directory (char const *directory_name)
                            (data_block->buffer + copied - 1));
     }
 
+  mv_end ();
+  
+  current_stat_info.stat.st_size = 0; /* For skip_member() and friends
+                                        to work correctly */
+  current_stat_info.dumpdir = archive_dir;
+}
+
+
+/* Examine the directories under directory_name and delete any
+   files that were not there at the time of the back-up. */
+void
+purge_directory (char const *directory_name)
+{
+  char *current_dir;
+  char *cur, *arc;
+
+  if (!current_stat_info.dumpdir)
+    {
+      skip_member ();
+      return;
+    }
+  
+  current_dir = savedir (directory_name);
+
+  if (!current_dir)
+    {
+      /* The directory doesn't exist now.  It'll be created.  In any
+        case, we don't have to delete any files out of it.  */
+
+      skip_member ();
+      return;
+    }
+
   for (cur = current_dir; *cur; cur += strlen (cur) + 1)
     {
-      for (arc = archive_dir; *arc; arc += strlen (arc) + 1)
+      for (arc = current_stat_info.dumpdir; *arc; arc += strlen (arc) + 1)
        {
          arc++;
          if (!strcmp (arc, cur))
@@ -707,7 +747,6 @@ purge_directory (char const *directory_name)
 
     }
   free (current_dir);
-  free (archive_dir);
 }
 
 void
This page took 0.024717 seconds and 4 git commands to generate.