Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 12 Dec 1995 07:34:00 -0500 (EST)
From:      Marc Ramirez <mrami@mramirez.sy.yale.edu>
To:        M C Wong <mcw@hpato.aus.hp.com>
Cc:        freebsd-questions@freefall.freebsd.org
Subject:   Re: tar
Message-ID:  <Pine.BSF.3.91.951212072155.27813A-100000@mramirez.sy.yale.edu>
In-Reply-To: <199512120032.AA010738367@hp.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 12 Dec 1995, M C Wong wrote:

> Where can I find the higher level description of tar format (tar header and
> etc) files ? I need to understand the format briefly without diving into
> the code immediately. I will have to implement extraction from a tar
> file (not directly from the tape device at all at any time).

For some reason, there is no tar(5).  Anyway, the format is (taken from 
tar(5) in my O'Reilly):

#define TBLOCK 512
#define NAMSIZ 100

union hblock {
	char dummy[TBLOCK];
	struct header {
		char name[NAMSIZ];
		char mode[8];
		char uid[8];
		char gid[8];
		char size[12];
		char mtime[12];
		char cksum[8];
		char linkflag;
		char linkname[NAMSIZ];
	} dbuf;
}

'name' and 'linkname' are null-terminated strings, and the rest are
zero-filled octal numbers in ASCII representation.  'uid' and 'gid' are
the uid and gid, 'size' is the size in bytes, 'mtime' is the last
modification time. 'cksum' is the sum of all the bytes in the header
block.  When computing 'cksum', it is assumed the field contains all
blanks [sic].  'linkflag' is NULL if the file is a normal file, ASCII '1'
if it is a hard link, and '2' if it is a symbolic link.  The name of the
file linked to is contained in 'linkname'. 

The first time a particular i-node is dumped, it is dumped as a regular 
file.  All subsequent times, it is sumped as a link instead.

Marc.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.3.91.951212072155.27813A-100000>