]> Dogcows Code - chaz/tar/blobdiff - src/extract.c
(max): New macro.
[chaz/tar] / src / extract.c
index 74da1a1bba269df42302300d521371431651c397..e859c169dfdfc0e51d98acbdd2c67dcd297225a7 100644 (file)
@@ -1,5 +1,5 @@
 /* Extract files from a tar archive.
-   Copyright (C) 1988, 92, 93, 94, 96, 97 Free Software Foundation, Inc.
+   Copyright 1988, 92,93,94,96,97,98, 1999 Free Software Foundation, Inc.
    Written by John Gilmore, on 1985-11-19.
 
    This program is free software; you can redistribute it and/or modify it
 
    You should have received a copy of the GNU General Public License along
    with this program; if not, write to the Free Software Foundation, Inc.,
-   59 Place - Suite 330, Boston, MA 02111-1307, USA.  */
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #include "system.h"
 
 #include <time.h>
+#ifndef time
 time_t time ();
+#endif
 
 #if HAVE_UTIME_H
 # include <utime.h>
@@ -35,8 +37,8 @@ struct utimbuf
 
 static time_t now;             /* current time */
 static int we_are_root;                /* true if our effective uid == 0 */
-static int newdir_umask;       /* umask when creating new directories */
-static int current_umask;      /* current umask (which is set to 0 if -p) */
+static mode_t newdir_umask;    /* umask when creating new directories */
+static mode_t current_umask;   /* current umask (which is set to 0 if -p) */
 
 #if 0
 /* "Scratch" space to store the information about a sparse file before
@@ -63,7 +65,7 @@ static struct delayed_set_stat *delayed_set_stat_head;
 void
 extr_init (void)
 {
-  now = time ((time_t *) 0);
+  now = time (0);
   we_are_root = geteuid () == 0;
 
   /* Option -p clears the kernel umask, so it does not affect proper
@@ -81,7 +83,7 @@ extr_init (void)
 
   /* FIXME: Just make sure we can add files in directories we create.  Maybe
      should we later remove permissions we are adding, here?  */
-  newdir_umask &= ~0300;
+  newdir_umask &= ~ MODE_WXUSR;
 }
 
 /*------------------------------------------------------------------.
@@ -91,21 +93,25 @@ extr_init (void)
 static void
 set_mode (char *file_name, struct stat *stat_info)
 {
-  /* We ought to force permission when -k is not selected, because if the
+  /* Do nothing unless we are restoring the original permissions.
+
+     We must force permission when -k and -U are not selected, because if the
      file already existed, open or creat would save the permission bits from
      the previously created file, ignoring the ones we specified.
 
-     But with -k selected, we know *we* created this file, so the mode
+     But with -k or -U selected, we know *we* created this file, so the mode
      bits were set by our open.  If the file has abnormal mode bits, we must
      chmod since writing or chown has probably reset them.  If the file is
      normal, we merely skip the chmod.  This works because we did umask (0)
      when -p, so umask will have left the specified mode alone.  */
 
-  if (!keep_old_files_option
-      || (stat_info->st_mode & (S_ISUID | S_ISGID | S_ISVTX)))
-    if (chmod (file_name, ~current_umask & (int) stat_info->st_mode) < 0)
-      ERROR ((0, errno, _("%s: Cannot change mode to %0.4o"),
-             file_name, ~current_umask & (int) stat_info->st_mode));
+  if ((we_are_root || same_permissions_option)
+      && ((!keep_old_files_option && !unlink_first_option)
+         || (stat_info->st_mode & (S_ISUID | S_ISGID | S_ISVTX))))
+    if (chmod (file_name, ~current_umask & stat_info->st_mode) < 0)
+      ERROR ((0, errno, _("%s: Cannot change mode to %04lo"),
+             file_name,
+             (unsigned long) (~current_umask & stat_info->st_mode)));
 }
 
 /*----------------------------------------------------------------------.
@@ -173,14 +179,18 @@ set_stat (char *file_name, struct stat *stat_info, int symlink_flag)
       if (symlink_flag)
        {
          if (lchown (file_name, stat_info->st_uid, stat_info->st_gid) < 0)
-           ERROR ((0, errno, _("%s: Cannot lchown to uid %d gid %d"),
-                   file_name, stat_info->st_uid, stat_info->st_gid));
+           ERROR ((0, errno, _("%s: Cannot lchown to uid %lu gid %lu"),
+                   file_name,
+                   (unsigned long) stat_info->st_uid,
+                   (unsigned long) stat_info->st_gid));
        }
       else
        {
          if (chown (file_name, stat_info->st_uid, stat_info->st_gid) < 0)
-           ERROR ((0, errno, _("%s: Cannot chown to uid %d gid %d"),
-                   file_name, stat_info->st_uid, stat_info->st_gid));
+           ERROR ((0, errno, _("%s: Cannot chown to uid %lu gid %lu"),
+                   file_name,
+                   (unsigned long) stat_info->st_uid,
+                   (unsigned long) stat_info->st_gid));
        }
 
 #else /* not HAVE_LCHOWN */
@@ -188,8 +198,10 @@ set_stat (char *file_name, struct stat *stat_info, int symlink_flag)
       if (!symlink_flag)
 
        if (chown (file_name, stat_info->st_uid, stat_info->st_gid) < 0)
-         ERROR ((0, errno, _("%s: Cannot chown to uid %d gid %d"),
-                 file_name, stat_info->st_uid, stat_info->st_gid));
+         ERROR ((0, errno, _("%s: Cannot chown to uid %lu gid %lu"),
+                 file_name,
+                 (unsigned long) stat_info->st_uid,
+                 (unsigned long) stat_info->st_gid));
 
 #endif/* not HAVE_LCHOWN */
 
@@ -197,9 +209,9 @@ set_stat (char *file_name, struct stat *stat_info, int symlink_flag)
 
        /* On a few systems, and in particular, those allowing to give files
           away, changing the owner or group destroys the suid or sgid bits.
-          So, when root, let's attempt setting these bits once more.  */
+          So let's attempt setting these bits once more.  */
 
-       if (we_are_root && (stat_info->st_mode & (S_ISUID | S_ISGID | S_ISVTX)))
+       if (stat_info->st_mode & (S_ISUID | S_ISGID | S_ISVTX))
          set_mode (file_name, stat_info);
     }
 }
@@ -233,20 +245,12 @@ make_directories (char *file_name)
        continue;
 
       *cursor = '\0';          /* truncate the path there */
-      status = mkdir (file_name, ~newdir_umask & 0777);
+      status = mkdir (file_name, ~newdir_umask & MODE_RWX);
 
       if (status == 0)
        {
-         /* Fix ownership.  */
-
-         if (we_are_root)
-           if (chown (file_name, current_stat.st_uid, current_stat.st_gid) < 0)
-             ERROR ((0, errno,
-                     _("%s: Cannot change owner to uid %d, gid %d"),
-                     file_name, current_stat.st_uid, current_stat.st_gid));
-
          print_for_mkdir (file_name, cursor - file_name,
-                          ~newdir_umask & 0777);
+                          ~newdir_umask & MODE_RWX);
          did_something = 1;
 
          *cursor = '/';
@@ -272,6 +276,25 @@ make_directories (char *file_name)
   return did_something;                /* tell them to retry if we made one */
 }
 
+/*--------------------------------------------------------------------.
+| Unlink the destination, if we are supposed to do so.               |
+| Return zero if extraction should not proceed.                              |
+`--------------------------------------------------------------------*/
+
+static int
+unlink_destination (char const *file_name)
+{
+  if (unlink_first_option
+      && !remove_any_file (file_name, recursive_unlink_option)
+      && errno != ENOENT)
+    {
+      ERROR ((0, errno, _("Cannot remove %s"), file_name));
+      return 0;
+    }
+
+  return 1;
+}
+
 /*--------------------------------------------------------------------.
 | Attempt repairing what went wrong with the extraction.  Delete an   |
 | already existing file or create missing intermediate directories.   |
@@ -285,10 +308,10 @@ maybe_recoverable (char *file_name)
   switch (errno)
     {
     case EEXIST:
-      /* Attempt deleting an existing file.  However, with -k, just stay
+      /* Attempt deleting an existing file.  However, with -k or -U, just stay
         quiet.  */
 
-      if (keep_old_files_option)
+      if (keep_old_files_option || unlink_first_option)
        return 0;
 
       return remove_any_file (file_name, 0);
@@ -310,55 +333,68 @@ maybe_recoverable (char *file_name)
 `---*/
 
 static void
-extract_sparse_file (int fd, long *sizeleft, long totalsize, char *name)
+extract_sparse_file (int fd, off_t *sizeleft, off_t totalsize, char *name)
 {
-  union block *data_block;
   int sparse_ind = 0;
-  int written, count;
-
-  /* FIXME: `data_block' might be used uninitialized in this function.
-     Reported by Bruno Haible.  */
+  size_t written;
+  ssize_t count;
 
   /* assuming sizeleft is initially totalsize */
 
   while (*sizeleft > 0)
     {
-      data_block = find_next_block ();
+      union block *data_block = find_next_block ();
       if (data_block == NULL)
        {
          ERROR ((0, 0, _("Unexpected EOF on archive file")));
          return;
        }
-      lseek (fd, sparsearray[sparse_ind].offset, 0);
+      if (lseek (fd, sparsearray[sparse_ind].offset, SEEK_SET) < 0)
+       {
+         char buf[UINTMAX_STRSIZE_BOUND];
+         ERROR ((0, errno, _("%s: lseek error at byte %s"),
+                 STRINGIFY_BIGINT (sparsearray[sparse_ind].offset, buf),
+                 name));
+         return;
+       }
       written = sparsearray[sparse_ind++].numbytes;
       while (written > BLOCKSIZE)
        {
-         count = write (fd, data_block->buffer, BLOCKSIZE);
+         count = full_write (fd, data_block->buffer, BLOCKSIZE);
          if (count < 0)
            ERROR ((0, errno, _("%s: Could not write to file"), name));
          written -= count;
          *sizeleft -= count;
          set_next_block_after (data_block);
          data_block = find_next_block ();
+         if (! data_block)
+           {
+             ERROR ((0, 0, _("Unexpected EOF on archive file")));
+             return;
+           }
        }
 
-      count = write (fd, data_block->buffer, (size_t) written);
+      count = full_write (fd, data_block->buffer, written);
 
       if (count < 0)
        ERROR ((0, errno, _("%s: Could not write to file"), name));
       else if (count != written)
        {
-         ERROR ((0, 0, _("%s: Could only write %d of %d bytes"),
-                    name, count, totalsize));
-         skip_file ((long) (*sizeleft));
+         char buf1[UINTMAX_STRSIZE_BOUND];
+         char buf2[UINTMAX_STRSIZE_BOUND];
+         ERROR ((0, 0, _("%s: Could only write %s of %s bytes"),
+                 name,
+                 STRINGIFY_BIGINT (totalsize - *sizeleft, buf1),
+                 STRINGIFY_BIGINT (totalsize, buf2)));
+         skip_file (*sizeleft);
        }
 
       written -= count;
       *sizeleft -= count;
       set_next_block_after (data_block);
     }
+
   free (sparsearray);
-  set_next_block_after (data_block);
 }
 
 /*----------------------------------.
@@ -371,12 +407,14 @@ extract_archive (void)
   union block *data_block;
   int fd;
   int status;
-  int name_length;
-  int written;
+  ssize_t sstatus;
+  size_t name_length;
+  size_t written;
   int openflag;
-  long size;
+  off_t size;
   int skipcrud;
   int counter;
+  char typeflag;
 #if 0
   int sparse_ind = 0;
 #endif
@@ -392,7 +430,7 @@ extract_archive (void)
     {
       if (current_header->oldgnu_header.isextended)
        skip_extended_headers ();
-      skip_file ((long) current_stat.st_size);
+      skip_file (current_stat.st_size);
       return;
     }
 
@@ -406,15 +444,14 @@ extract_archive (void)
   skipcrud = 0;
   while (!absolute_names_option && CURRENT_FILE_NAME[0] == '/')
     {
-      static int warned_once = 0;
+      static int warned_once;
 
-      skipcrud++;              /* force relative path */
       if (!warned_once)
        {
          warned_once = 1;
-         WARN ((0, 0, _("\
-Removing leading `/' from absolute path names in the archive")));
+         WARN ((0, 0, _("Removing leading `/' from archive names")));
        }
+      skipcrud++;              /* force relative path */
     }
 
   /* Take a safety backup of a previously existing file.  */
@@ -426,13 +463,14 @@ Removing leading `/' from absolute path names in the archive")));
                CURRENT_FILE_NAME));
        if (current_header->oldgnu_header.isextended)
          skip_extended_headers ();
-       skip_file ((long) current_stat.st_size);
+       skip_file (current_stat.st_size);
        return;
       }
 
   /* Extract the archive entry according to its type.  */
 
-  switch (current_header->header.typeflag)
+  typeflag = current_header->header.typeflag;
+  switch (typeflag)
     {
       /* JK - What we want to do if the file is sparse is loop through
         the array of sparse structures in the header and read in and
@@ -456,25 +494,29 @@ Removing leading `/' from absolute path names in the archive")));
       for (counter = 0; counter < SPARSES_IN_OLDGNU_HEADER; counter++)
        {
          sparsearray[counter].offset =
-           from_oct (1 + 12,
-                     current_header->oldgnu_header.sp[counter].offset);
+           OFF_FROM_CHARS (current_header->oldgnu_header.sp[counter].offset);
          sparsearray[counter].numbytes =
-           from_oct (1 + 12,
-                     current_header->oldgnu_header.sp[counter].numbytes);
+           SIZE_FROM_CHARS (current_header->oldgnu_header.sp[counter].numbytes);
          if (!sparsearray[counter].numbytes)
            break;
        }
 
       if (current_header->oldgnu_header.isextended)
        {
-         /* Read in the list of extended headers and translate them into
-            the sparsearray as before.  */
+         /* Read in the list of extended headers and translate them
+            into the sparsearray as before.  Note that this
+            invalidates current_header.  */
 
          /* static */ int ind = SPARSES_IN_OLDGNU_HEADER;
 
          while (1)
            {
              exhdr = find_next_block ();
+             if (! exhdr)
+               {
+                 ERROR ((0, 0, _("Unexpected EOF on archive file")));
+                 return;
+               }
              for (counter = 0; counter < SPARSES_IN_SPARSE_HEADER; counter++)
                {
                  if (counter + ind > sp_array_size - 1)
@@ -487,16 +529,12 @@ Removing leading `/' from absolute path names in the archive")));
                        xrealloc (sparsearray,
                                  sp_array_size * (sizeof (struct sp_array)));
                    }
-                 /* Compare to 0, or use !(int)..., for Pyramid's dumb
-                    compiler.  */
-                 if (exhdr->sparse_header.sp[counter].numbytes == 0)
+                 if (exhdr->sparse_header.sp[counter].numbytes[0] == 0)
                    break;
                  sparsearray[counter + ind].offset =
-                   from_oct (1 + 12,
-                             exhdr->sparse_header.sp[counter].offset);
+                   OFF_FROM_CHARS (exhdr->sparse_header.sp[counter].offset);
                  sparsearray[counter + ind].numbytes =
-                   from_oct (1 + 12,
-                             exhdr->sparse_header.sp[counter].numbytes);
+                   SIZE_FROM_CHARS (exhdr->sparse_header.sp[counter].numbytes);
                }
              if (!exhdr->sparse_header.isextended)
                break;
@@ -524,10 +562,10 @@ Removing leading `/' from absolute path names in the archive")));
       /* FIXME: deal with protection issues.  */
 
     again_file:
-      openflag = (keep_old_files_option ?
-                 O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_EXCL :
-                 O_BINARY | O_NDELAY | O_WRONLY | O_CREAT | O_TRUNC)
-       | ((current_header->header.typeflag == GNUTYPE_SPARSE) ? 0 : O_APPEND);
+      openflag = (keep_old_files_option || unlink_first_option ?
+                 O_WRONLY | O_BINARY | O_NONBLOCK | O_CREAT | O_EXCL :
+                 O_WRONLY | O_BINARY | O_NONBLOCK | O_CREAT | O_TRUNC)
+       | ((typeflag == GNUTYPE_SPARSE) ? 0 : O_APPEND);
 
       /* JK - The last | is a kludge to solve the problem the O_APPEND
         flag causes with files we are trying to make sparse: when a file
@@ -544,21 +582,28 @@ Removing leading `/' from absolute path names in the archive")));
          goto extract_file;
        }
 
-      if (unlink_first_option)
-       remove_any_file (CURRENT_FILE_NAME, recursive_unlink_option);
+      if (!unlink_destination (CURRENT_FILE_NAME))
+       {
+         if (current_header->oldgnu_header.isextended)
+           skip_extended_headers ();
+         skip_file (current_stat.st_size);
+         if (backup_option)
+           undo_last_backup ();
+         break;
+       }
 
 #if O_CTG
       /* Contiguous files (on the Masscomp) have to specify the size in
         the open call that creates them.  */
 
-      if (current_header->header.typeflag == CONTTYPE)
+      if (typeflag == CONTTYPE)
        fd = open (CURRENT_FILE_NAME, openflag | O_CTG,
                   current_stat.st_mode, current_stat.st_size);
       else
        fd = open (CURRENT_FILE_NAME, openflag, current_stat.st_mode);
 
 #else /* not O_CTG */
-      if (current_header->header.typeflag == CONTTYPE)
+      if (typeflag == CONTTYPE)
        {
          static int conttype_diagnosed = 0;
 
@@ -581,17 +626,17 @@ Removing leading `/' from absolute path names in the archive")));
                  CURRENT_FILE_NAME));
          if (current_header->oldgnu_header.isextended)
            skip_extended_headers ();
-         skip_file ((long) current_stat.st_size);
+         skip_file (current_stat.st_size);
          if (backup_option)
            undo_last_backup ();
          break;
        }
 
     extract_file:
-      if (current_header->header.typeflag == GNUTYPE_SPARSE)
+      if (typeflag == GNUTYPE_SPARSE)
        {
          char *name;
-         int name_length_bis;
+         size_t name_length_bis;
 
          /* Kludge alert.  NAME is assigned to header.name because
             during the extraction, the space that contains the header
@@ -600,8 +645,8 @@ Removing leading `/' from absolute path names in the archive")));
             REAL interesting unless we do this.  */
 
          name_length_bis = strlen (CURRENT_FILE_NAME) + 1;
-         name = (char *) xmalloc ((sizeof (char)) * name_length_bis);
-         memcpy (name, CURRENT_FILE_NAME, (size_t) name_length_bis);
+         name = (char *) xmalloc (name_length_bis);
+         memcpy (name, CURRENT_FILE_NAME, name_length_bis);
          size = current_stat.st_size;
          extract_sparse_file (fd, &size, current_stat.st_size, name);
        }
@@ -610,9 +655,6 @@ Removing leading `/' from absolute path names in the archive")));
             size > 0;
             size -= written)
          {
-#if 0
-           long offset, numbytes;
-#endif
            if (multi_volume_option)
              {
                assign_string (&save_name, current_file_name);
@@ -631,43 +673,30 @@ Removing leading `/' from absolute path names in the archive")));
                break;          /* FIXME: What happens, then?  */
              }
 
-           /* If the file is sparse, use the sparsearray that we created
-              before to lseek into the new file the proper amount, and to
-              see how many bytes we want to write at that position.  */
-
-#if 0
-           if (current_header->header.typeflag == GNUTYPE_SPARSE)
-             {
-               off_t pos;
-
-               pos = lseek (fd, (off_t) sparsearray[sparse_ind].offset, 0);
-               fprintf (msg_file, _("%d at %d\n"), (int) pos, sparse_ind);
-               written = sparsearray[sparse_ind++].numbytes;
-             }
-           else
-#endif
-             written = available_space_after (data_block);
+           written = available_space_after (data_block);
 
            if (written > size)
              written = size;
            errno = 0;          /* FIXME: errno should be read-only */
-           status = write (fd, data_block->buffer, (size_t) written);
+           sstatus = full_write (fd, data_block->buffer, written);
 
            set_next_block_after ((union block *)
                                  (data_block->buffer + written - 1));
-           if (status == written)
+           if (sstatus == written)
              continue;
 
            /* Error in writing to file.  Print it, skip to next file in
               archive.  */
 
-           if (status < 0)
+           if (sstatus < 0)
              ERROR ((0, errno, _("%s: Could not write to file"),
                      CURRENT_FILE_NAME));
            else
-             ERROR ((0, 0, _("%s: Could only write %d of %d bytes"),
-                     CURRENT_FILE_NAME, status, written));
-           skip_file ((long) (size - written));
+             ERROR ((0, 0, _("%s: Could only write %lu of %lu bytes"),
+                     CURRENT_FILE_NAME,
+                     (unsigned long) sstatus,
+                     (unsigned long) written));
+           skip_file (size - written);
            break;              /* still do the close, mod time, chmod, etc */
          }
 
@@ -680,27 +709,6 @@ Removing leading `/' from absolute path names in the archive")));
       if (to_stdout_option)
        break;
 
-#if 0
-      if (current_header->header.isextended)
-       {
-         union block *exhdr;
-         int counter;
-
-         for (counter = 0; counter < 21; counter++)
-           {
-             off_t offset;
-
-             if (!exhdr->sparse_header.sp[counter].numbytes)
-               break;
-             offset = from_oct (1 + 12, exhdr->sparse_header.sp[counter].offset);
-             written = from_oct (1 + 12, exhdr->sparse_header.sp[counter].numbytes);
-             lseek (fd, offset, 0);
-             status = write (fd, data_block->buffer, written);
-             if (status == written)
-               continue;
-           }
-       }
-#endif
       status = close (fd);
       if (status < 0)
        {
@@ -716,9 +724,9 @@ Removing leading `/' from absolute path names in the archive")));
       if (to_stdout_option)
        break;
 
-#ifdef S_ISLNK
-      if (unlink_first_option)
-       remove_any_file (CURRENT_FILE_NAME, recursive_unlink_option);
+#ifdef HAVE_SYMLINK
+      if (!unlink_destination (CURRENT_FILE_NAME))
+       break;
 
       while (status = symlink (current_link_name, CURRENT_FILE_NAME),
             status != 0)
@@ -743,27 +751,27 @@ Removing leading `/' from absolute path names in the archive")));
        }
       break;
 
-#else /* not S_ISLNK */
+#else
       {
        static int warned_once = 0;
 
        if (!warned_once)
          {
            warned_once = 1;
-           WARN ((0, 0, _("\
-Attempting extraction of symbolic links as hard links")));
+           WARN ((0, 0,
+                  _("Attempting extraction of symbolic links as hard links")));
          }
       }
       /* Fall through.  */
 
-#endif /* not S_ISLNK */
+#endif
 
     case LNKTYPE:
       if (to_stdout_option)
        break;
 
-      if (unlink_first_option)
-       remove_any_file (CURRENT_FILE_NAME, recursive_unlink_option);
+      if (!unlink_destination (CURRENT_FILE_NAME))
+       break;
 
     again_link:
       {
@@ -804,16 +812,16 @@ Attempting extraction of symbolic links as hard links")));
       current_stat.st_mode |= S_IFBLK;
 #endif
 
-#if defined(S_IFCHR) || defined(S_IFBLK)
+#if S_IFCHR || S_IFBLK
     make_node:
       if (to_stdout_option)
        break;
 
-      if (unlink_first_option)
-       remove_any_file (CURRENT_FILE_NAME, recursive_unlink_option);
+      if (!unlink_destination (CURRENT_FILE_NAME))
+       break;
 
-      status = mknod (CURRENT_FILE_NAME, (int) current_stat.st_mode,
-                    (int) current_stat.st_rdev);
+      status = mknod (CURRENT_FILE_NAME, current_stat.st_mode,
+                     current_stat.st_rdev);
       if (status != 0)
        {
          if (maybe_recoverable (CURRENT_FILE_NAME))
@@ -828,15 +836,15 @@ Attempting extraction of symbolic links as hard links")));
       break;
 #endif
 
-#ifdef S_ISFIFO
+#if HAVE_MKFIFO || defined mkfifo
     case FIFOTYPE:
       if (to_stdout_option)
        break;
 
-      if (unlink_first_option)
-       remove_any_file (CURRENT_FILE_NAME, recursive_unlink_option);
+      if (!unlink_destination (CURRENT_FILE_NAME))
+       break;
 
-      while (status = mkfifo (CURRENT_FILE_NAME, (int) current_stat.st_mode),
+      while (status = mkfifo (CURRENT_FILE_NAME, current_stat.st_mode),
             status != 0)
        if (!maybe_recoverable (CURRENT_FILE_NAME))
          break;
@@ -868,15 +876,16 @@ Attempting extraction of symbolic links as hard links")));
 
          gnu_restore (skipcrud);
        }
-      else if (current_header->header.typeflag == GNUTYPE_DUMPDIR)
-       skip_file ((long) (current_stat.st_size));
+      else if (typeflag == GNUTYPE_DUMPDIR)
+       skip_file (current_stat.st_size);
 
       if (to_stdout_option)
        break;
 
     again_dir:
       status = mkdir (CURRENT_FILE_NAME,
-                    (we_are_root ? 0 : 0300) | (int) current_stat.st_mode);
+                     ((we_are_root ? 0 : MODE_WXUSR)
+                      | current_stat.st_mode));
       if (status != 0)
        {
          /* If the directory creation fails, let's consider immediately the
@@ -929,9 +938,9 @@ Attempting extraction of symbolic links as hard links")));
        }
 
     check_perms:
-      if (!we_are_root && 0300 != (0300 & (int) current_stat.st_mode))
+      if (!we_are_root && MODE_WXUSR != (MODE_WXUSR & current_stat.st_mode))
        {
-         current_stat.st_mode |= 0300;
+         current_stat.st_mode |= MODE_WXUSR;
          WARN ((0, 0, _("Added write and execute permission to directory %s"),
                 CURRENT_FILE_NAME));
        }
@@ -970,10 +979,10 @@ Attempting extraction of symbolic links as hard links")));
       break;
 
     case GNUTYPE_MULTIVOL:
-      ERROR ((0, 0, _("\
-Cannot extract `%s' -- file is continued from another volume"),
+      ERROR ((0, 0,
+             _("Cannot extract `%s' -- file is continued from another volume"),
              current_file_name));
-      skip_file ((long) current_stat.st_size);
+      skip_file (current_stat.st_size);
       if (backup_option)
        undo_last_backup ();
       break;
@@ -981,7 +990,7 @@ Cannot extract `%s' -- file is continued from another volume"),
     case GNUTYPE_LONGNAME:
     case GNUTYPE_LONGLINK:
       ERROR ((0, 0, _("Visible long name error")));
-      skip_file ((long) current_stat.st_size);
+      skip_file (current_stat.st_size);
       if (backup_option)
        undo_last_backup ();
       break;
@@ -989,7 +998,7 @@ Cannot extract `%s' -- file is continued from another volume"),
     default:
       WARN ((0, 0,
             _("Unknown file type '%c' for %s, extracted as normal file"),
-            current_header->header.typeflag, CURRENT_FILE_NAME));
+            typeflag, CURRENT_FILE_NAME));
       goto again_file;
     }
 
This page took 0.040048 seconds and 4 git commands to generate.