]> Dogcows Code - chaz/tar/blobdiff - src/create.c
(name_next): If file names are given both in the
[chaz/tar] / src / create.c
index b5cfd083219d0cc8aabe74ea397ee74671b21979..9c3f5ffe82098afec83b03191ee20654618ef9c5 100644 (file)
@@ -122,22 +122,22 @@ to_chars (int negative, uintmax_t value, size_t valsize,
 {
   int base256_allowed = (archive_format == GNU_FORMAT
                         || archive_format == OLDGNU_FORMAT);
-  uintmax_t v = negative ? -value : value;
 
   /* Generate the POSIX octal representation if the number fits.  */
-  if (! negative && v <= MAX_VAL_WITH_DIGITS (size - 1, LG_8))
+  if (! negative && value <= MAX_VAL_WITH_DIGITS (size - 1, LG_8))
     {
       where[size - 1] = '\0';
-      to_octal (v, where, size - 1);
+      to_octal (value, where, size - 1);
     }
 
   /* Otherwise, generate the base-256 representation if we are
      generating an old or new GNU format and if the number fits.  */
-  else if (v - negative <= MAX_VAL_WITH_DIGITS (size - 1, LG_256)
+  else if (((negative ? -1 - value : value)
+           <= MAX_VAL_WITH_DIGITS (size - 1, LG_256))
           && base256_allowed)
     {
       where[0] = negative ? -1 : 1 << (LG_256 - 1);
-      to_base256 (negative, v, where + 1, size - 1);
+      to_base256 (negative, value, where + 1, size - 1);
     }
 
   /* Otherwise, if the number is negative, and if it would not cause
@@ -152,7 +152,7 @@ to_chars (int negative, uintmax_t value, size_t valsize,
       if (! warned_once)
        {
          warned_once = 1;
-         WARN ((0, 0, _("Generating negative octal headers\n")));
+         WARN ((0, 0, _("Generating negative octal headers")));
        }
       where[size - 1] = '\0';
       to_octal (value & MAX_VAL_WITH_DIGITS (valsize * CHAR_BIT, 1),
@@ -169,10 +169,10 @@ to_chars (int negative, uintmax_t value, size_t valsize,
       char valbuf[UINTMAX_STRSIZE_BOUND + 1];
       char maxbuf[UINTMAX_STRSIZE_BOUND];
       char minbuf[UINTMAX_STRSIZE_BOUND + 1];
-      char subbuf[UINTMAX_STRSIZE_BOUND + 1];
-      char *value_string = STRINGIFY_BIGINT (v, valbuf + 1);
-      char *maxval_string = STRINGIFY_BIGINT (maxval, maxbuf);
       char const *minval_string;
+      char const *maxval_string = STRINGIFY_BIGINT (maxval, maxbuf);
+      char const *value_string;
+
       if (base256_allowed)
        {
          uintmax_t m = maxval + 1 ? maxval + 1 : maxval / 2 + 1;
@@ -182,13 +182,22 @@ to_chars (int negative, uintmax_t value, size_t valsize,
        }
       else
        minval_string = "0";
+
       if (negative)
-       *--value_string = '-';
+       {
+         char *p = STRINGIFY_BIGINT (- value, valbuf + 1);
+         *--p = '-';
+         value_string = p;
+       }
+      else
+       value_string = STRINGIFY_BIGINT (value, valbuf);
+
       if (substitute)
        {
          int negsub;
          uintmax_t sub = substitute (&negsub) & maxval;
-         uintmax_t s = (negsub &= archive_format == GNU_FORMAT) ? -sub : sub;
+         uintmax_t s = (negsub &= archive_format == GNU_FORMAT) ? - sub : sub;
+         char subbuf[UINTMAX_STRSIZE_BOUND + 1];
          char *sub_string = STRINGIFY_BIGINT (s, subbuf + 1);
          if (negsub)
            *--sub_string = '-';
@@ -558,8 +567,6 @@ finish_header (union block *header)
 
   uintmax_to_chars ((uintmax_t) sum, header->header.chksum, 7);
 
-  set_next_block_after (header);
-
   if (verbose_option
       && header->header.typeflag != GNUTYPE_LONGLINK
       && header->header.typeflag != GNUTYPE_LONGNAME)
@@ -571,6 +578,8 @@ finish_header (union block *header)
       current_format = archive_format;
       print_header ();
     }
+
+  set_next_block_after (header);
 }
 \f
 /* Sparse file processing.  */
@@ -915,7 +924,7 @@ create_archive (void)
 /* Dump a single file, recursing on directories.  P is the file name
    to dump.  TOP_LEVEL tells whether this is a top-level call; zero
    means no, positive means yes, and negative means an incremental
-   dump where it's irrelevant.  PARENT_DEVICE is the device of P's
+   dump.  PARENT_DEVICE is the device of P's
    parent directory; it is examined only if TOP_LEVEL is zero.
 
    Set global CURRENT_STAT to stat output for this file.  */
@@ -1131,7 +1140,7 @@ dump_file (char *p, int top_level, dev_t parent_device)
 
       /* Now output all the files in the directory.  */
 
-      errno = 0;               /* FIXME: errno should be read-only */
+      errno = 0;
 
       directory = opendir (p);
       if (!directory)
@@ -1156,7 +1165,7 @@ dump_file (char *p, int top_level, dev_t parent_device)
            }
          strcpy (namebuf + len, entry->d_name);
          if (!excluded_name (namebuf))
-           dump_file (namebuf, our_device, 0);
+           dump_file (namebuf, 0, our_device);
        }
 
       closedir (directory);
@@ -1354,9 +1363,16 @@ dump_file (char *p, int top_level, dev_t parent_device)
              f = open (p, O_RDONLY | O_BINARY);
              if (f < 0)
                {
-                 WARN ((0, errno, _("Cannot add file %s"), p));
-                 if (!ignore_failed_read_option)
-                   exit_status = TAREXIT_FAILURE;
+                 /* Do not diagnose a file that the parent directory
+                    said should be there, but is absent.  It was
+                    probably removed between then and now.  */
+                 if (top_level || errno != ENOENT)
+                   {
+                     WARN ((0, errno, _("Cannot add file %s"), p));
+                     if (! ignore_failed_read_option)
+                       exit_status = TAREXIT_FAILURE;
+                   }
+
                  return;
                }
            }
@@ -1471,7 +1487,7 @@ dump_file (char *p, int top_level, dev_t parent_device)
                ERROR ((0, errno, "%s: fstat", p));
              else if (final_stat.st_mtime != restore_times.modtime
                       || final_stat.st_size != restore_size)
-               ERROR ((0, errno, _("%s: file changed as we read it"), p));
+               ERROR ((0, 0, _("%s: file changed as we read it"), p));
              if (close (f) != 0)
                ERROR ((0, errno, _("%s: close"), p));
              if (atime_preserve_option)
@@ -1546,6 +1562,13 @@ dump_file (char *p, int top_level, dev_t parent_device)
       else if (S_ISFIFO (current_stat.st_mode)
               || S_ISSOCK (current_stat.st_mode))
        type = FIFOTYPE;
+#ifdef S_ISDOOR
+      else if (S_ISDOOR (current_stat.st_mode))
+       {
+         WARN ((0, 0, _("%s: door ignored"), p));
+         return;
+       }
+#endif
       else
        goto unknown;
     }
This page took 0.024327 seconds and 4 git commands to generate.