From: Christos Zoulas Date: Wed, 3 May 2006 15:19:25 +0000 (+0000) Subject: Identify gnu tar vs. posix tar. X-Git-Tag: FILE5_05~752 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e90a73007cc0f53a8077c8ae8ea0b4f27156f723;p=file Identify gnu tar vs. posix tar. --- diff --git a/src/is_tar.c b/src/is_tar.c index b6ad2e3c..64617247 100644 --- a/src/is_tar.c +++ b/src/is_tar.c @@ -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 */ diff --git a/src/tar.h b/src/tar.h index c3fc185e..4fb4276f 100644 --- 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 */