1 /* 2 * Header file for public domain tar (tape archive) program. 3 * 4 * @(#)tar.h 1.20 86/10/29 Public Domain. 5 * 6 * Created 25 August 1985 by John Gilmore, ihnp4!hoptoad!gnu. 7 * 8 * $Id: is_tar.h,v 1.2 2007/02/11 00:41:13 tkojm Exp $ # checkin only 9 */ 10 11 /* 12 * Header block on tape. 13 * 14 * I'm going to use traditional DP naming conventions here. 15 * A "block" is a big chunk of stuff that we do I/O on. 16 * A "record" is a piece of info that we care about. 17 * Typically many "record"s fit into a "block". 18 */ 19 #define RECORDSIZE 512 20 #define NAMSIZ 100 21 #define TUNMLEN 32 22 #define TGNMLEN 32 23 24 union record { 25 char charptr[RECORDSIZE]; 26 struct header { 27 char name[NAMSIZ]; 28 char mode[8]; 29 char uid[8]; 30 char gid[8]; 31 char size[12]; 32 char mtime[12]; 33 char chksum[8]; 34 char linkflag; 35 char linkname[NAMSIZ]; 36 char magic[8]; 37 char uname[TUNMLEN]; 38 char gname[TGNMLEN]; 39 char devmajor[8]; 40 char devminor[8]; 41 } header; 42 }; 43 44 /* The magic field is filled with this if uname and gname are valid. */ 45 #define TMAGIC "ustar " /* 7 chars and a null */ 46 47 /** 48 * @brief Figure out whether a given buffer is a tar archive. 49 * 50 * @param buf Pointer to the buffer 51 * @param nbytes Size of the buffer 52 * @return int 0 if the checksum is bad (i.e., probably not a tar archive), 53 * 1 for old UNIX tar file, 54 * 2 for Unix Std (POSIX) tar file. 55 */ 56 int is_tar(const unsigned char *buf, unsigned int nbytes); 57