Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

tar(5) [bsd man page]

TAR(5)								File Formats Manual							    TAR(5)

NAME
tar - tape archive file format DESCRIPTION
Tar, (the tape archive command) dumps several files into one, in a medium suitable for transportation. A ``tar tape'' or file is a series of blocks. Each block is of size TBLOCK. A file on the tape is represented by a header block which describes the file, followed by zero or more blocks which give the contents of the file. At the end of the tape are two blocks filled with binary zeros, as an end-of-file indicator. The blocks are grouped for physical I/O operations. Each group of n blocks (where n is set by the b keyletter on the tar(1) command line -- default is 20 blocks) is written with a single system call; on nine-track tapes, the result of this write is a single tape record. The last group is always written at the full size, so blocks after the two zero blocks contain random data. On reading, the specified or default group size is used for the first read, but if that read returns less than a full tape block, the reduced block size is used for further reads. The header block looks like: #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 chksum[8]; char linkflag; char linkname[NAMSIZ]; } dbuf; }; Name is a null-terminated string. The other fields are zero-filled octal numbers in ASCII. Each field (of width w) contains w-2 digits, a space, and a null, except size and mtime, which do not contain the trailing null and chksum which has a null followed by a space. Name is the name of the file, as specified on the tar command line. Files dumped because they were in a directory which was named in the command line have the directory name as prefix and /filename as suffix. Mode is the file mode, with the top bit masked off. Uid and gid are the user and group numbers which own the file. Size is the size of the file in bytes. Links and symbolic links are dumped with this field specified as zero. Mtime is the modification time of the file at the time it was dumped. Chksum is an octal ASCII value which represents the sum of all the bytes in the header block. When calculating the checksum, the chksum field is treated as if it were all blanks. Link- flag is NULL if the file is ``normal'' or a special file, ASCII `1' if it is an hard link, and ASCII `2' if it is a symbolic link. The name linked-to, if any, is in linkname, with a trailing null. Unused fields of the header are binary zeros (and are included in the check- sum). The first time a given i-node number is dumped, it is dumped as a regular file. The second and subsequent times, it is dumped as a link instead. Upon retrieval, if a link entry is retrieved, but not the file it was linked to, an error message is printed and the tape must be manually re-scanned to retrieve the linked-to file. The encoding of the header is designed to be portable across machines. SEE ALSO
tar(1) BUGS
Names or linknames longer than NAMSIZ produce error reports and cannot be dumped. 4.2 Berkeley Distribution November 7, 1985 TAR(5)

Check Out this Related Man Page

archives(4)							   File Formats 						       archives(4)

NAME
archives - device header DESCRIPTION
/* Magic numbers */ #define CMN_ASC 0x070701 /* Cpio Magic Number for -c header */ #define CMN_BIN 070707 /* Cpio Magic Number for Binary header */ #define CMN_BBS 0143561 /* Cpio Magic Number for Byte-Swap header */ #define CMN_CRC 0x070702 /* Cpio Magic Number for CRC header */ #define CMS_ASC "070701" /* Cpio Magic String for -c header */ #define CMS_CHR "070707" /* Cpio Magic String for odc header */ #define CMS_CRC "070702" /* Cpio Magic String for CRC header */ #define CMS_LEN 6 /* Cpio Magic String length */ /* Various header and field lengths */ #define CHRSZ 76 /* -H odc size minus filename field */ #define ASCSZ 110 /* -c and CRC hdr size minus filename field */ #define TARSZ 512 /* TAR hdr size */ #define HNAMLEN 256 /* maximum filename length for binary and odc headers */ #define EXPNLEN 1024 /* maximum filename length for -c and CRC headers */ #define HTIMLEN 2 /* length of modification time field */ #define HSIZLEN 2 /* length of file size field */ /* cpio binary header definition */ struct hdr_cpio { short h_magic, /* magic number field */ h_dev; /* file system of file */ ushort_t h_ino, /* inode of file */ h_mode, /* modes of file */ h_uid, /* uid of file */ h_gid; /* gid of file */ short h_nlink, /* number of links to file */ h_rdev, /* maj/min numbers for special files */ h_mtime[HTIMLEN], /* modification time of file */ h_namesize, /* length of filename */ h_filesize[HSIZLEN]; /* size of file */ char h_name[HNAMLEN]; /* filename */ } ; /* cpio -H odc header format */ struct c_hdr { char c_magic[CMS_LEN], c_dev[6], c_ino[6], c_mode[6], c_uid[6], c_gid[6], c_nlink[6], c_rdev[6], c_mtime[11], c_namesz[6], c_filesz[11], c_name[HNAMLEN]; } ; /* -c and CRC header format */ struct Exp_cpio_hdr { char E_magic[CMS_LEN], E_ino[8], E_mode[8], E_uid[8], E_gid[8], E_nlink[8], E_mtime[8], E_filesize[8], E_maj[8], E_min[8], E_rmaj[8], E_rmin[8], E_namesize[8], E_chksum[8], E_name[EXPNLEN]; } ; /* Tar header structure and format */ #define TBLOCK 512 /* length of tar header and data blocks */ #define TNAMLEN 100 /* maximum length for tar file names */ #define TMODLEN 8 /* length of mode field */ #define TUIDLEN 8 /* length of uid field */ #define TGIDLEN 8 /* length of gid field */ #define TSIZLEN 12 /* length of size field */ #define TTIMLEN 12 /* length of modification time field */ #define TCRCLEN 8 /* length of header checksum field */ /* tar header definition */ union tblock { char dummy[TBLOCK]; struct header { char t_name[TNAMLEN]; /* name of file */ char t_mode[TMODLEN]; /* mode of file */ char t_uid[TUIDLEN]; /* uid of file */ char t_gid[TGIDLEN]; /* gid of file */ char t_size[TSIZLEN]; /* size of file in bytes */ char t_mtime[TTIMLEN]; /* modification time of file */ char t_chksum[TCRCLEN]; /* checksum of header */ char t_typeflag; /* flag to indicate type of file */ char t_linkname[TNAMLEN]; /* file this file is linked with */ char t_magic[6]; /* magic string always "ustar" */ char t_version[2]; /* version strings always "00" */ char t_uname[32]; /* owner of file in ASCII */ char t_gname[32]; /* group of file in ASCII */ char t_devmajor[8]; /* major number for special files */ char t_devminor[8]; /* minor number for special files */ char t_prefix[155]; /* pathname prefix */ } tbuf; } /* volcopy tape label format and structure */ #define VMAGLEN 8 #define VVOLLEN 6 #define VFILLEN 464 struct volcopy_label { char v_magic[VMAGLEN], v_volume[VVOLLEN], v_reels, v_reel; long v_time, v_length, v_dens, v_reelblks, /* u370 added field */ v_blksize, /* u370 added field */ v_nblocks; /* u370 added field */ char v_fill[VFILLEN]; long v_offset; /* used with -e and -reel options */ int v_type; /* does tape have nblocks field? */ } ; SunOS 5.10 3 Jul 1990 archives(4)
Man Page

Featured Tech Videos