]> Dogcows Code - chaz/tar/commitdiff
(dump_dir0): Handle incremental backups in pax archives
authorSergey Poznyakoff <gray@gnu.org.ua>
Mon, 7 Nov 2005 02:48:23 +0000 (02:48 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Mon, 7 Nov 2005 02:48:23 +0000 (02:48 +0000)
src/create.c

index 6e7d158b63e07916b143668b687d25d66503067b..645bcb65428634659bd36f54490ce291f43dbd07 100644 (file)
@@ -1029,7 +1029,7 @@ dump_dir0 (char *directory,
       if (!blk)
        return;
 
-      if (incremental_option)
+      if (incremental_option && archive_format != POSIX_FORMAT)
        blk->header.typeflag = GNUTYPE_DUMPDIR;
       else /* if (standard_option) */
        blk->header.typeflag = DIRTYPE;
@@ -1040,51 +1040,54 @@ dump_dir0 (char *directory,
        finish_header (st, blk, block_ordinal);
       else if (gnu_list_name->dir_contents)
        {
-         off_t size_left;
-         off_t totsize;
-         size_t bufsize;
-         ssize_t count;
-         const char *buffer, *p_buffer;
-
-         block_ordinal = current_block_ordinal ();
-         buffer = gnu_list_name->dir_contents; /* FOO */
-         totsize = 0;
-         if (buffer)
-           for (p_buffer = buffer; *p_buffer; )
-             {
-               size_t size = strlen (p_buffer) + 1;
-               totsize += size;
-               p_buffer += size;
-             }
-         totsize++;
-         OFF_TO_CHARS (totsize, blk->header.size);
-         finish_header (st, blk, block_ordinal);
-         p_buffer = buffer;
-         size_left = totsize;
-         while (size_left > 0)
+         if (archive_format == POSIX_FORMAT)
            {
-             if (multi_volume_option)
-               {
-                 assign_string (&save_name, st->orig_file_name);
-                 save_sizeleft = size_left;
-                 save_totsize = totsize;
-               }
-             blk = find_next_block ();
-             bufsize = available_space_after (blk);
-             if (size_left < bufsize)
+             xheader_store ("GNU.dumpdir", st, gnu_list_name->dir_contents);
+             finish_header (st, blk, block_ordinal);
+           }
+         else
+           {
+             off_t size_left;
+             off_t totsize;
+             size_t bufsize;
+             ssize_t count;
+             const char *buffer, *p_buffer;
+             
+             block_ordinal = current_block_ordinal ();
+             buffer = gnu_list_name->dir_contents; /* FOO */
+             if (buffer)
+               totsize = dumpdir_size (buffer);
+             else
+               totsize = 0;
+             OFF_TO_CHARS (totsize, blk->header.size);
+             finish_header (st, blk, block_ordinal);
+             p_buffer = buffer;
+             size_left = totsize;
+             while (size_left > 0)
                {
-                 bufsize = size_left;
-                 count = bufsize % BLOCKSIZE;
-                 if (count)
-                   memset (blk->buffer + size_left, 0, BLOCKSIZE - count);
+                 if (multi_volume_option)
+                   {
+                     assign_string (&save_name, st->orig_file_name);
+                     save_sizeleft = size_left;
+                     save_totsize = totsize;
+                   }
+                 blk = find_next_block ();
+                 bufsize = available_space_after (blk);
+                 if (size_left < bufsize)
+                   {
+                     bufsize = size_left;
+                     count = bufsize % BLOCKSIZE;
+                     if (count)
+                       memset (blk->buffer + size_left, 0, BLOCKSIZE - count);
+                   }
+                 memcpy (blk->buffer, p_buffer, bufsize);
+                 size_left -= bufsize;
+                 p_buffer += bufsize;
+                 set_next_block_after (blk + (bufsize - 1) / BLOCKSIZE);
                }
-             memcpy (blk->buffer, p_buffer, bufsize);
-             size_left -= bufsize;
-             p_buffer += bufsize;
-             set_next_block_after (blk + (bufsize - 1) / BLOCKSIZE);
+             if (multi_volume_option)
+               assign_string (&save_name, 0);
            }
-         if (multi_volume_option)
-           assign_string (&save_name, 0);
          return;
        }
     }
This page took 0.027414 seconds and 4 git commands to generate.