mv tar to /usr/src/old
[unix-history] / usr / src / bin / pax / tar.h
CommitLineData
79aa58f4
KM
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992 The Regents of the University of California.
4 * All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *
9 * %sccs.include.redist.c%
10 *
445ebf89 11 * @(#)tar.h 1.2 (Berkeley) %G%
79aa58f4
KM
12 */
13
14/*
15 * defines and data structures common to all tar formats
16 */
445ebf89 17#define CHK_LEN 8 /* length of checksum field */
79aa58f4 18#define TNMSZ 100 /* size of name field */
445ebf89
KM
19#ifdef _PAX_
20#define NULLCNT 2 /* number of null blocks in trailer */
79aa58f4 21#define CHK_OFFSET 148 /* start of chksum field */
79aa58f4 22#define BLNKSUM 256L /* sum of checksum field using ' ' */
445ebf89 23#endif /* _PAX_ */
79aa58f4
KM
24
25/*
445ebf89
KM
26 * Values used in typeflag field in all tar formats
27 * (only REGTYPE, LNKTYPE and SYMTYPE are used in old bsd tar headers)
79aa58f4 28 */
445ebf89
KM
29#define REGTYPE '0' /* Regular File */
30#define AREGTYPE '\0' /* Regular File */
31#define LNKTYPE '1' /* Link */
32#define SYMTYPE '2' /* Symlink */
33#define CHRTYPE '3' /* Character Special File */
34#define BLKTYPE '4' /* Block Special File */
35#define DIRTYPE '5' /* Directory */
36#define FIFOTYPE '6' /* FIFO */
37#define CONTTYPE '7' /* high perf file */
79aa58f4
KM
38
39/*
445ebf89 40 * Mode field encoding of the different file types - values in octal
79aa58f4 41 */
445ebf89
KM
42#define TSUID 04000 /* Set UID on execution */
43#define TSGID 02000 /* Set GID on execution */
44#define TSVTX 01000 /* Reserved */
45#define TUREAD 00400 /* Read by owner */
46#define TUWRITE 00200 /* Write by owner */
47#define TUEXEC 00100 /* Execute/Search by owner */
48#define TGREAD 00040 /* Read by group */
49#define TGWRITE 00020 /* Write by group */
50#define TGEXEC 00010 /* Execute/Search by group */
51#define TOREAD 00004 /* Read by other */
52#define TOWRITE 00002 /* Write by other */
53#define TOEXEC 00001 /* Execute/Search by other */
79aa58f4 54
445ebf89 55#ifdef _PAX_
79aa58f4 56/*
445ebf89
KM
57 * Pad with a bit mask, much faster than doing a mod but only works on powers
58 * of 2. Macro below is for block of 512 bytes.
59 */
60#define TAR_PAD(x) ((512 - ((x) & 511)) & 511)
61#endif /* _PAX_ */
62
63/*
64 * structure of an old tar header as it appeared in BSD releases
79aa58f4
KM
65 */
66typedef struct {
67 char name[TNMSZ]; /* name of entry */
68 char mode[8]; /* mode */
69 char uid[8]; /* uid */
70 char gid[8]; /* gid */
71 char size[12]; /* size */
72 char mtime[12]; /* modification time */
445ebf89 73 char chksum[CHK_LEN]; /* checksum */
79aa58f4
KM
74 char linkflag; /* norm, hard, or sym. */
75 char linkname[TNMSZ]; /* linked to name */
76} HD_TAR;
77
445ebf89
KM
78#ifdef _PAX_
79/*
80 * -o options for BSD tar to not write directories to the archive
81 */
82#define TAR_NODIR "nodir"
83#define TAR_OPTION "write_opt"
84#endif /* _PAX_ */
85
79aa58f4 86/*
445ebf89 87 * Data Interchange Format - Extended tar header format - POSIX 1003.1-1990
79aa58f4
KM
88 */
89#define TPFSZ 155
90#define TMAGIC "ustar" /* ustar and a null */
91#define TMAGLEN 6
92#define TVERSION "00" /* 00 and no null */
93#define TVERSLEN 2
94
95typedef struct {
96 char name[TNMSZ]; /* name of entry */
97 char mode[8]; /* mode */
98 char uid[8]; /* uid */
99 char gid[8]; /* gid */
100 char size[12]; /* size */
101 char mtime[12]; /* modification time */
445ebf89 102 char chksum[CHK_LEN]; /* checksum */
79aa58f4
KM
103 char typeflag; /* type of file. */
104 char linkname[TNMSZ]; /* linked to name */
105 char magic[TMAGLEN]; /* magic cookie */
106 char version[TVERSLEN]; /* version */
107 char uname[32]; /* ascii owner name */
108 char gname[32]; /* ascii group name */
109 char devmajor[8]; /* major device number */
110 char devminor[8]; /* minor device number */
111 char prefix[TPFSZ]; /* linked to name */
112} HD_USTAR;