]> Dogcows Code - chaz/tar/blobdiff - src/list.c
Support for POSIX ACLs
[chaz/tar] / src / list.c
index c65e171976ecf86b66a73cf386e271a327725216..f2605ad0c258d68ab6214ed5af1eeb8e68707951 100644 (file)
@@ -1,7 +1,8 @@
 /* List a tar archive, with support routines for reading a tar archive.
 
    Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1998, 1999, 2000,
-   2001, 2003, 2004, 2005, 2006, 2007, 2010 Free Software Foundation, Inc.
+   2001, 2003, 2004, 2005, 2006, 2007, 2010, 2012
+   Free Software Foundation, Inc.
 
    Written by John Gilmore, on 1985-08-26.
 
@@ -122,7 +123,7 @@ transform_stat_info (int typeflag, struct tar_stat_info *stat_info)
   if (typeflag == GNUTYPE_VOLHDR)
     /* Name transformations don't apply to volume headers. */
     return;
-  
+
   transform_member_name (&stat_info->file_name, XFORM_REGFILE);
   switch (typeflag)
     {
@@ -433,15 +434,13 @@ read_header (union block **return_block, struct tar_stat_info *info,
 
              if (header->header.typeflag == GNUTYPE_LONGNAME)
                {
-                 if (next_long_name)
-                   free (next_long_name);
+                 free (next_long_name);
                  next_long_name = header_copy;
                  next_long_name_blocks = size / BLOCKSIZE;
                }
              else
                {
-                 if (next_long_link)
-                   free (next_long_link);
+                 free (next_long_link);
                  next_long_link = header_copy;
                  next_long_link_blocks = size / BLOCKSIZE;
                }
@@ -500,8 +499,7 @@ read_header (union block **return_block, struct tar_stat_info *info,
          struct posix_header const *h = &header->header;
          char namebuf[sizeof h->prefix + 1 + NAME_FIELD_SIZE + 1];
 
-         if (recent_long_name)
-           free (recent_long_name);
+         free (recent_long_name);
 
          if (next_long_name)
            {
@@ -532,8 +530,7 @@ read_header (union block **return_block, struct tar_stat_info *info,
          assign_string (&info->file_name, name);
          info->had_trailing_slash = strip_trailing_slashes (info->file_name);
 
-         if (recent_long_link)
-           free (recent_long_link);
+         free (recent_long_link);
 
          if (next_long_link)
            {
@@ -592,7 +589,9 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
       else
        format = USTAR_FORMAT;
     }
-  else if (strcmp (header->header.magic, OLDGNU_MAGIC) == 0)
+  else if (strcmp (header->buffer + offsetof (struct posix_header, magic),
+                  OLDGNU_MAGIC)
+          == 0)
     format = hbits ? OLDGNU_FORMAT : GNU_FORMAT;
   else
     format = V7_FORMAT;
@@ -606,6 +605,8 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
   assign_string (&stat_info->gname,
                 header->header.gname[0] ? header->header.gname : NULL);
 
+  xheader_xattr_init (stat_info);
+
   if (format == OLDGNU_FORMAT && incremental_option)
     {
       stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime);
@@ -1066,7 +1067,7 @@ static void
 simple_print_header (struct tar_stat_info *st, union block *blk,
                     off_t block_ordinal)
 {
-  char modes[11];
+  char modes[12];
   char const *time_stamp;
   int time_stamp_len;
   char *temp_name;
@@ -1158,6 +1159,9 @@ simple_print_header (struct tar_stat_info *st, union block *blk,
 
       pax_decode_mode (st->stat.st_mode, modes + 1);
 
+      /* extended attributes:  GNU `ls -l'-like preview */
+      xattrs_print_char (st, modes + 10);
+
       /* Time stamp.  */
 
       time_stamp = tartime (st->mtime, full_time_option);
@@ -1303,6 +1307,7 @@ simple_print_header (struct tar_stat_info *st, union block *blk,
        }
     }
   fflush (stdlis);
+  xattrs_print (st);
 }
 
 
@@ -1359,8 +1364,8 @@ print_for_mkdir (char *dirname, int length, mode_t mode)
                   STRINGIFY_BIGINT (current_block_ordinal (), buf));
        }
 
-      fprintf (stdlis, "%s %*s %.*s\n", modes, ugswidth + 1 + datewidth,
-              _("Creating directory:"), length, quotearg (dirname));
+      fprintf (stdlis, "%s %*s %s\n", modes, ugswidth + 1 + datewidth,
+              _("Creating directory:"), quotearg (dirname));
     }
 }
 
@@ -1417,7 +1422,7 @@ skip_member (void)
 }
 
 void
-test_archive_label ()
+test_archive_label (void)
 {
   base64_init ();
   name_gather ();
This page took 0.024176 seconds and 4 git commands to generate.