Merge commit 'dc97a43d4a70c8773a619f11b95b07a787f6f5b7' into merges
[unleashed.git] / share / man / man3head / archives.h.3head
blobfd7f25e57b554438fd2cb356a3c29224bf523d7a
1 '\" te
2 .\" Copyright (C) 2007, Sun Microsystems, Inc. All Rights Reserved
3 .\"  Copyright 1989 AT&T
4 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
5 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
6 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
7 .TH ARCHIVES.H 3HEAD "Oct 22, 2007"
8 .SH NAME
9 archives.h, archives \- device header
10 .SH DESCRIPTION
11 .sp
12 .in +2
13 .nf
14 /* Magic numbers */
15 #define CMN_ASC 0x070701    /* Cpio Magic Number for -c header */
16 #define CMN_BIN 070707      /* Cpio Magic Number for Binary header */
17 #define CMN_BBS 0143561     /* Cpio Magic Number for Byte-Swap header */
18 #define CMN_CRC 0x070702    /* Cpio Magic Number for CRC header */
19 #define CMS_ASC "070701"    /* Cpio Magic String for -c header */
20 #define CMS_CHR "070707"    /* Cpio Magic String for odc header */
21 #define CMS_CRC "070702"    /* Cpio Magic String for CRC header */
22 #define CMS_LEN 6           /* Cpio Magic String length */
23 /* Various header and field lengths */
24 #define CHRSZ   76         /* -H odc size minus filename field */
25 #define ASCSZ   110        /* -c and CRC hdr size minus filename field */
26 #define TARSZ   512        /* TAR hdr size */
27 #define HNAMLEN 256        /* maximum filename length for binary and
28                           odc headers */
29 #define EXPNLEN 1024      /* maximum filename length for -c and
30                          CRC headers */
31 #define HTIMLEN 2         /* length of modification time field */
32 #define HSIZLEN 2         /* length of file size field */
33 /* cpio binary header definition */
34 struct hdr_cpio {
35        short   h_magic,           /* magic number field */
36                h_dev;             /* file system of file */
37        ushort_t  h_ino,           /* inode of file */
38                h_mode,            /* modes of file */
39                h_uid,             /* uid of file */
40                h_gid;             /* gid of file */
41        short   h_nlink,           /* number of links to file */
42                h_rdev,            /* maj/min numbers for special files */
43                h_mtime[HTIMLEN],  /* modification time of file */
44                h_namesize,        /* length of filename */
45           h_filesize[HSIZLEN];     /* size of file */
46      char h_name[HNAMLEN];    /* filename */
47 } ;
48 /* cpio -H odc header format */
49 struct c_hdr {
50        char c_magic[CMS_LEN],
51             c_dev[6],
52             c_ino[6],
53             c_mode[6],
54             c_uid[6],
55             c_gid[6],
56             c_nlink[6],
57             c_rdev[6],
58             c_mtime[11],
59             c_namesz[6],
60             c_filesz[11],
61             c_name[HNAMLEN];
62 } ;
63 /* -c and CRC header format */
64 struct Exp_cpio_hdr {
65      char E_magic[CMS_LEN],
66           E_ino[8],
67           E_mode[8],
68           E_uid[8],
69           E_gid[8],
70           E_nlink[8],
71           E_mtime[8],
72           E_filesize[8],
73           E_maj[8],
74           E_min[8],
75           E_rmaj[8],
76           E_rmin[8],
77           E_namesize[8],
78           E_chksum[8],
79           E_name[EXPNLEN];
80 } ;
81 /* Tar header structure and format */
82 #define TBLOCK 512  /* length of tar header and data blocks */
83 #define TNAMLEN     100  /* maximum length for tar file names */
84 #define TMODLEN     8    /* length of mode field */
85 #define TUIDLEN     8    /* length of uid field */
86 #define TGIDLEN     8    /* length of gid field */
87 #define TSIZLEN     12   /* length of size field */
88 #define TTIMLEN     12   /* length of modification time field */
89 #define TCRCLEN     8    /* length of header checksum field */
90 /* tar header definition */
91 union tblock {
92      char dummy[TBLOCK];
93      struct header {
94          char  t_name[TNAMLEN];     /* name of file */
95          char  t_mode[TMODLEN];     /* mode of file */
96          char  t_uid[TUIDLEN];      /* uid of file */
97          char  t_gid[TGIDLEN];      /* gid of file */
98          char  t_size[TSIZLEN];     /* size of file in bytes */
99          char  t_mtime[TTIMLEN];    /* modification time of file */
100          char  t_chksum[TCRCLEN];   /* checksum of header */
101          char  t_typeflag;          /* flag to indicate type of file */
102          char  t_linkname[TNAMLEN]; /* file this file is linked with */
103          char  t_magic[6];          /* magic string always "ustar" */
104          char  t_version[2];        /* version strings always "00" */
105          char  t_uname[32];         /* owner of file in ASCII */
106          char  t_gname[32];         /* group of file in ASCII */
107          char  t_devmajor[8];       /* major number for special files */
108          char  t_devminor[8];       /* minor number for special files */
109          char  t_prefix[155];       /* pathname prefix */
110      } tbuf;
112 /* volcopy tape label format and structure */
113 #define VMAGLEN 8
114 #define VVOLLEN     6
115 #define VFILLEN     464
116 struct volcopy_label {
117      char v_magic[VMAGLEN],
118           v_volume[VVOLLEN],
119           v_reels,
120           v_reel;
121      long v_time,
122           v_length,
123           v_dens,
124           v_reelblks,    /* u370 added field */
125           v_blksize,     /* u370 added field */
126           v_nblocks;     /* u370 added field */
127      char v_fill[VFILLEN];
128      long v_offset; /* used with -e and -reel options */
129      int  v_type;        /* does tape have nblocks field? */
130 } ;
133  * Define archive formats for extended attributes.
135  * Extended attributes are stored in two pieces.
136  * 1. An attribute header which has information about
137  *    what file the attribute is for and what the attribute
138  *    is named.
139  * 2. The attribute record itself.  Stored as a normal file type
140  *    of entry.
141  * Both the header and attribute record have special modes/typeflags
142  * associated with them.
144  * The names of the header in the archive look like:
145  * /dev/null/attr.hdr
147  * The name of the attribute looks like:
148  * /dev/null/attr.
150  * This is done so that an archiver that doesn't understand these formats
151  * can just dispose of the attribute records unless the user chooses to
152  * rename them via cpio -r or pax -i
154  * The format is composed of a fixed size header followed
155  * by a variable sized xattr_buf. If the attribute is a hard link
156  * to another attribute, then another xattr_buf section is included
157  * for the link.
159  * The xattr_buf is used to define the necessary "pathing" steps
160  * to get to the extended attribute.  This is necessary to support
161  * a fully recursive attribute model where an attribute may itself
162  * have an attribute.
164  * The basic layout looks like this.
166 *     --------------------------------
167  *     |                              |
168  *     |         xattr_hdr            |
169  *     |                              |
170  *     --------------------------------
171  *     --------------------------------
172  *     |                              |
173  *     |        xattr_buf             |
174  *     |                              |
175  *     --------------------------------
176  *     --------------------------------
177  *     |                              |
178  *     |      (optional link info)    |
179  *     |                              |
180  *     --------------------------------
181  *     --------------------------------
182  *     |                              |
183  *     |      attribute itself        |
184  *     |      stored as normal tar    |
185  *     |      or cpio data with       |
186  *     |      special mode or         |
187  *     |      typeflag                |
188  *     |                              |
189  *     --------------------------------
191  */
192 #define XATTR_ARCH_VERS "1.0"
195  * extended attribute fixed header
197  * h_version            format version.
198  * h_size               size of header + variable sized data sections.
199  * h_component_len      Length of entire pathing section.
200  * h_link_component_len Length of link component section.  Again same
201  *                      definition as h_component_len.
202  */
203 struct xattr_hdr {
204         char    h_version[7];
205         char    h_size[10];
206         char    h_component_len[10]; /* total length of path component */
207         char    h_link_component_len[10];
211  * The name is encoded like this:
212  * filepathNULattrpathNUL[attrpathNULL]...
213  */
214 struct xattr_buf {
215         char    h_namesz[7];  /* length of h_names */
216         char    h_typeflag;   /* actual typeflag of file being archived */
217         char    h_names[1];   /* filepathNULattrpathNUL... */
221  * Special values for tar archives
222  */
225  * typeflag for tar archives.
226  */
229  * Attribute hdr and attribute files have the following typeflag
230  */
231 #define _XATTR_HDRTYPE          'E'
234  * For cpio archives the header and attribute have
235  * _XATTR_CPIO_MODE ORED into the mode field in both
236  * character and binary versions of the archive format
237  */
238 #define _XATTR_CPIO_MODE        0xB000
240 .in -2