]> granicus.if.org Git - file/commitdiff
Identify gnu tar vs. posix tar.
authorChristos Zoulas <christos@zoulas.com>
Wed, 3 May 2006 15:19:25 +0000 (15:19 +0000)
committerChristos Zoulas <christos@zoulas.com>
Wed, 3 May 2006 15:19:25 +0000 (15:19 +0000)
src/is_tar.c
src/tar.h

index b6ad2e3c1bc2208f17ee9292e3dce68f1f112882..646172474a22c041bade180cc697c5c214c02944 100644 (file)
@@ -45,7 +45,7 @@
 #include "tar.h"
 
 #ifndef lint
-FILE_RCSID("@(#)$Id: is_tar.c,v 1.25 2004/09/11 19:15:57 christos Exp $")
+FILE_RCSID("@(#)$Id: is_tar.c,v 1.26 2006/05/03 15:19:25 christos Exp $")
 #endif
 
 #define        isodigit(c)     ( ((c) >= '0') && ((c) <= '7') )
@@ -71,6 +71,12 @@ file_is_tar(struct magic_set *ms, const unsigned char *buf, size_t nbytes)
                    "application/x-tar, POSIX" : "POSIX tar archive") == -1)
                        return -1;
                return 1;
+       case 3:
+               if (file_printf(ms, (ms->flags & MAGIC_MIME) ?
+                   "application/x-tar, POSIX (GNU)" :
+                   "POSIX tar archive (GNU)") == -1)
+                       return -1;
+               return 1;
        default:
                return 0;
        }
@@ -113,7 +119,9 @@ is_tar(const unsigned char *buf, size_t nbytes)
        if (sum != recsum)
                return 0;       /* Not a tar archive */
        
-       if (0==strcmp(header->header.magic, TMAGIC)) 
+       if (strcmp(header->header.magic, GNUTMAGIC) == 0) 
+               return 3;               /* GNU Unix Standard tar archive */
+       if (strcmp(header->header.magic, TMAGIC) == 0) 
                return 2;               /* Unix Standard tar archive */
 
        return 1;                       /* Old fashioned tar archive */
index c3fc185eec1417e7cc7071fb62cf7fe6eea3f6ca..4fb4276fb390c761f14fd648b842e77cbc17e7ce 100644 (file)
--- a/src/tar.h
+++ b/src/tar.h
@@ -32,7 +32,7 @@
  *
  * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu.
  *
- * $Id: tar.h,v 1.8 2004/09/11 19:15:58 christos Exp $ # checkin only
+ * $Id: tar.h,v 1.9 2006/05/03 15:19:25 christos Exp $ # checkin only
  */
 
 /*
@@ -82,7 +82,8 @@ union record {
 #define        CHKBLANKS       "        "      /* 8 blanks, no null */
 
 /* The magic field is filled with this if uname and gname are valid. */
-#define        TMAGIC          "ustar  "       /* 7 chars and a null */
+#define        TMAGIC          "ustar"         /* 5 chars and a null */
+#define        GNUTMAGIC       "ustar  "       /* 7 chars and a null */
 
 /* The linkflag defines the type of file */
 #define        LF_OLDNORMAL    '\0'            /* Normal disk file, Unix compat */