


     TTTTAAAARRRR((((5555))))             AAAAmmmmiiiiggggaaaaDDDDOOOOSSSS ((((11115555 OOOOccccttttoooobbbbeeeerrrr 1111999988887777))))              TTTTAAAARRRR((((5555))))



     NNNNAAAAMMMMEEEE
          tar - tape (or other media) archive file format

     DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
          A ``tar tape'' or file contains a series of records.  Each
          record contains TRECORDSIZE bytes (see below).  Although
          this format may be thought of as being on magnetic tape,
          other media are often used.  Each file archived is
          represented by a header record which describes the file,
          followed by zero or more records which give the contents of
          the file.  At the end of the archive file there may be a
          record filled with binary zeros as an end-of-file indicator.
          A reasonable system should write a record of zeros at the
          end, but must not assume that an end-of-file record exists
          when reading an archive.

          The records may be blocked for physical I/O operations.
          Each block of _N records (where _N is set by the ----bbbb option to
          _t_a_r) is written with a single write() operation.  On
          magnetic tapes, the result of such a write is a single tape
          record.  When writing an archive, the last block of records
          should be written at the full size, with records after the
          zero record containing all zeroes.  When reading an archive,
          a reasonable system should properly handle an archive whose
          last block is shorter than the rest, or which contains
          garbage records after a zero record.

          The header record is defined in the header file <tar.h> as
          follows:
9          /*
           * Standard Archive Format - Standard TAR - USTAR
           */
          #define   RECORDSIZE     512
          #define   NAMSIZ    100
          #define   TUNMLEN   32
          #define   TGNMLEN   32

          union record {
               char      charptr[RECORDSIZE];
               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];
                    char magic[8];
                    char uname[TUNMLEN];
                    char gname[TGNMLEN];


9     Page 1                                           (printed 3/8/90)






     TTTTAAAARRRR((((5555))))             AAAAmmmmiiiiggggaaaaDDDDOOOOSSSS ((((11115555 OOOOccccttttoooobbbbeeeerrrr 1111999988887777))))              TTTTAAAARRRR((((5555))))



                    char devmajor[8];
                    char devminor[8];
               } header;
          };

          /* The checksum field is filled with this while the checksum is computed. */
          #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 */

          /* The linkflag defines the type of file */
          #define   LF_OLDNORMAL '\0'        /* Normal disk file, Unix compatible */
          #define   LF_NORMAL '0'       /* Normal disk file */
          #define   LF_LINK   '1'       /* Link to previously dumped file */
          #define   LF_SYMLINK     '2'       /* Symbolic link */
          #define   LF_CHR    '3'       /* Character special file */
          #define   LF_BLK    '4'       /* Block special file */
          #define   LF_DIR         '5'       /* Directory */
          #define   LF_FIFO   '6'       /* FIFO special file */
          #define   LF_CONTIG '7'       /* Contiguous file */
          /* Further link types may be defined later. */

          /* Bits used in the mode field - values in octal */
          #define   TSUID          04000          /* Set UID on execution */
          #define   TSGID          02000          /* Set GID on execution */
          #define   TSVTX          01000          /* Save text (sticky bit) */

          /* File permissions */
          #define   TUREAD    00400          /* read by owner */
          #define   TUWRITE   00200          /* write by owner */
          #define   TUEXEC    00100          /* execute/search by owner */
          #define   TGREAD    00040          /* read by group */
          #define   TGWRITE   00020          /* write by group */
          #define   TGEXEC    00010          /* execute/search by group */
          #define   TOREAD    00004          /* read by other */
          #define   TOWRITE   00002          /* write by other */
          #define   TOEXEC    00001          /* execute/search by other */

          All characters in header records are represented using 8-bit
          characters in the local variant of ASCII.  Each field within
          the structure is contiguous; that is, there is no padding
          used within the structure.  Each character on the archive
          medium is stored contiguously.

          Bytes representing the contents of files (after the header
          record of each file) are not translated in any way and are
          not constrained to represent characters or to be in any
          character set.  The _t_a_r(5) format does not distinguish text
          files from binary files, and no translation of file contents
          should be performed.




     Page 2                                           (printed 3/8/90)






     TTTTAAAARRRR((((5555))))             AAAAmmmmiiiiggggaaaaDDDDOOOOSSSS ((((11115555 OOOOccccttttoooobbbbeeeerrrr 1111999988887777))))              TTTTAAAARRRR((((5555))))



          The fields _n_a_m_e, _l_i_n_k_n_a_m_e, _m_a_g_i_c, _u_n_a_m_e, and _g_n_a_m_e are
          null-terminated character strings.  All other fields are
          zero-filled octal numbers in ASCII.  Each numeric field (of
          width _w) contains _w-2 digits, a space, and a null, except
          _s_i_z_e and _m_t_i_m_e, which do not contain the trailing null.

          The _n_a_m_e field is the pathname of the file, with directory
          names (if any) preceding the file name, separated by
          slashes.

          The _m_o_d_e field provides nine bits specifying file
          permissions and three bits to specify the Set UID, Set GID
          and Save Text (TSVTX) modes.  Values for these bits are
          defined above.  When special permissions are required to
          create a file with a given mode, and the user restoring
          files from the archive does not hold such permissions, the
          mode bit(s) specifying those special permissions are
          ignored.  Modes which are not supported by the operating
          system restoring files from the archive will be ignored.
          Unsupported modes should be faked up when creating an
          archive; e.g.  the group permission could be copied from the
          `other' permission.

          The _u_i_d and _g_i_d fields are the user and group ID of the file
          owners, respectively.

          The _s_i_z_e field is the size of the file in bytes; linked
          files are archived with this field specified as zero.

          The _m_t_i_m_e field is the modification time of the file at the
          time it was archived.  It is the ASCII representation of the
          octal value of the last time the file was modified,
          represented as in integer number of seconds since January 1,
          1970, 00:00 Coordinated Universal Time.

          The _c_h_k_s_u_m field is the ASCII representaion of the octal
          value of the simple sum of all bytes in the header record.
          Each 8-bit byte in the header is treated as an unsigned
          value.  These values are added to an unsigned integer,
          initialized to zero, the precision of which shall be no less
          than seventeen bits.  When calculating the checksum, the
          _c_h_k_s_u_m field is treated as if it were all blanks.

          The _t_y_p_e_f_l_a_g field specifies the type of file archived.  If
          a particular implementation does not recognize or permit the
          specified type, the file will be extracted as if it were a
          regular file.  As this action occurs, _t_a_r issues a warning
          to the standard error.

          LF_NORMAL or LF_OLDNORMAL
               represents a regular file.  For backward compatibility,
               a _t_y_p_e_f_l_a_g value of LF_OLDNORMAL should be silently



     Page 3                                           (printed 3/8/90)






     TTTTAAAARRRR((((5555))))             AAAAmmmmiiiiggggaaaaDDDDOOOOSSSS ((((11115555 OOOOccccttttoooobbbbeeeerrrr 1111999988887777))))              TTTTAAAARRRR((((5555))))



               recognized as a regular file.  New archives should be
               created using LF_NORMAL.  Also, for backward
               compatability, _t_a_r treats a regular file whose name
               ends with a slash as a directory.

          LF_LINK
               represents a file linked to another file, of any type,
               previously archived.  Such files are identified in Unix
               by each file having the same device and inode number.
               The linked-to name is specified in the _l_i_n_k_n_a_m_e field
               with a trailing null.

          LF_SYMLINK
               represents a symbolic link to another file.  The
               linked-to name is specified in the _l_i_n_k_n_a_m_e field with
               a trailing null.

          LF_CHR or LF_BLK
               represent character special files and block special
               files respectively.  In this case the _d_e_v_m_a_j_o_r and
               _d_e_v_m_i_n_o_r fields will contain the major and minor device
               numbers respectively.  Operating systems may map the
               device specifications to their own local specification,
               or may ignore the entry.

          LF_DIR
               specifies a directory or sub-directory.  The directory
               name in the _n_a_m_e field should end with a slash.  On
               systems where disk allocation is performed on a
               directory basis the _s_i_z_e field will contain the maximum
               number of bytes (which may be rounded to the nearest
               disk block allocation unit) which the directory may
               hold.  A _s_i_z_e field of zero indicates no such limiting.
               Systems which do not support limiting in this manner
               should ignore the _s_i_z_e field.

          LF_FIFO
               specifies a FIFO special file.  Note that the archiving
               of a FIFO file archives the existence of this file and
               not its contents.

          LF_CONTIG
               specifies a contiguous file, which is the same as a
               normal file except that, in operating systems which
               support it, all its space is allocated contiguously on
               the disk.  Operating systems which do not allow
               contiguous allocation should silently treat this type
               as a normal file.

          `A' - `Z'
               are reserved for custom implementations.  None are used
               by this version of the _t_a_r program.



     Page 4                                           (printed 3/8/90)






     TTTTAAAARRRR((((5555))))             AAAAmmmmiiiiggggaaaaDDDDOOOOSSSS ((((11115555 OOOOccccttttoooobbbbeeeerrrr 1111999988887777))))              TTTTAAAARRRR((((5555))))



          _o_t_h_e_r
               values are reserved for specification in future
               revisions of the P1003 standard, and should not be used
               by any _t_a_r program.

          The _m_a_g_i_c field indicates that this archive was output in
          the P1003 archive format.  If this field contains TMAGIC,
          then the _u_n_a_m_e and _g_n_a_m_e fields will contain the ASCII
          representation of the owner and group of the file
          respectively.  If found, the user and group ID represented
          by these names will be used rather than the values contained
          within the _u_i_d and _g_i_d fields.  User names longer than
          TUNMLEN-1 or group names longer than TGNMLEN-1 characters
          will be truncated.

     SSSSEEEEEEEE AAAALLLLSSSSOOOO
          tar(1), ar(5), cpio(5), dump(8), restor(8), restore(8)

     BBBBUUUUGGGGSSSS
          Names or link names longer than NAMSIZ-1 characters cannot
          be archived.

          This format does not yet address multi-volume archives.

     NNNNOOOOTTTTEEEESSSS
          This manual page was adapted by John Gilmore from Draft 6 of
          the P1003 specification




























     Page 5                                           (printed 3/8/90)



