1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 1988,1997-1998,2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 28*0Sstevel@tonic-gate /* All Rights Reserved */ 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate #ifndef _ARCHIVES_H 32*0Sstevel@tonic-gate #define _ARCHIVES_H 33*0Sstevel@tonic-gate 34*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #include <tar.h> 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate #ifdef __cplusplus 39*0Sstevel@tonic-gate extern "C" { 40*0Sstevel@tonic-gate #endif 41*0Sstevel@tonic-gate 42*0Sstevel@tonic-gate /* Magic numbers */ 43*0Sstevel@tonic-gate 44*0Sstevel@tonic-gate #define CMN_ASC 0x070701 /* Cpio Magic Number for ASCii header */ 45*0Sstevel@tonic-gate #define CMN_BIN 070707 /* Cpio Magic Number for Binary header */ 46*0Sstevel@tonic-gate #define CMN_BBS 0143561 /* Cpio Magic Number for Byte-Swap header */ 47*0Sstevel@tonic-gate #define CMN_CRC 0x070702 /* Cpio Magic Number for CRC header */ 48*0Sstevel@tonic-gate #define CMS_ASC "070701" /* Cpio Magic String for ASCii header */ 49*0Sstevel@tonic-gate #define CMS_CHR "070707" /* Cpio Magic String for CHR (-c) header */ 50*0Sstevel@tonic-gate #define CMS_CRC "070702" /* Cpio Magic String for CRC header */ 51*0Sstevel@tonic-gate #define CMS_LEN 6 /* Cpio Magic String LENgth */ 52*0Sstevel@tonic-gate 53*0Sstevel@tonic-gate /* Various header and field lengths */ 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate #define CHRSZ 76 /* -c hdr size minus filename field */ 56*0Sstevel@tonic-gate #define ASCSZ 110 /* ASC and CRC hdr size minus filename field */ 57*0Sstevel@tonic-gate #define TARSZ 512 /* TAR hdr size */ 58*0Sstevel@tonic-gate 59*0Sstevel@tonic-gate #define HNAMLEN 256 /* maximum filename length for binary and -c headers */ 60*0Sstevel@tonic-gate #define EXPNLEN 1024 /* maximum filename length for ASC and CRC headers */ 61*0Sstevel@tonic-gate #define HTIMLEN 2 /* length of modification time field */ 62*0Sstevel@tonic-gate #define HSIZLEN 2 /* length of file size field */ 63*0Sstevel@tonic-gate 64*0Sstevel@tonic-gate /* cpio binary header definition */ 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate struct hdr_cpio { 67*0Sstevel@tonic-gate short h_magic, /* magic number field */ 68*0Sstevel@tonic-gate h_dev; /* file system of file */ 69*0Sstevel@tonic-gate ushort_t h_ino, /* inode of file */ 70*0Sstevel@tonic-gate h_mode, /* modes of file */ 71*0Sstevel@tonic-gate h_uid, /* uid of file */ 72*0Sstevel@tonic-gate h_gid; /* gid of file */ 73*0Sstevel@tonic-gate short h_nlink, /* number of links to file */ 74*0Sstevel@tonic-gate h_rdev, /* maj/min numbers for special files */ 75*0Sstevel@tonic-gate h_mtime[HTIMLEN], /* modification time of file */ 76*0Sstevel@tonic-gate h_namesize, /* length of filename */ 77*0Sstevel@tonic-gate h_filesize[HSIZLEN]; /* size of file */ 78*0Sstevel@tonic-gate char h_name[HNAMLEN]; /* filename */ 79*0Sstevel@tonic-gate }; 80*0Sstevel@tonic-gate 81*0Sstevel@tonic-gate /* cpio ODC header format */ 82*0Sstevel@tonic-gate 83*0Sstevel@tonic-gate struct c_hdr { 84*0Sstevel@tonic-gate char c_magic[CMS_LEN], 85*0Sstevel@tonic-gate c_dev[6], 86*0Sstevel@tonic-gate c_ino[6], 87*0Sstevel@tonic-gate c_mode[6], 88*0Sstevel@tonic-gate c_uid[6], 89*0Sstevel@tonic-gate c_gid[6], 90*0Sstevel@tonic-gate c_nlink[6], 91*0Sstevel@tonic-gate c_rdev[6], 92*0Sstevel@tonic-gate c_mtime[11], 93*0Sstevel@tonic-gate c_namesz[6], 94*0Sstevel@tonic-gate c_filesz[11], 95*0Sstevel@tonic-gate c_name[HNAMLEN]; 96*0Sstevel@tonic-gate }; 97*0Sstevel@tonic-gate 98*0Sstevel@tonic-gate /* -c and CRC header format */ 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate struct Exp_cpio_hdr { 101*0Sstevel@tonic-gate char E_magic[CMS_LEN], 102*0Sstevel@tonic-gate E_ino[8], 103*0Sstevel@tonic-gate E_mode[8], 104*0Sstevel@tonic-gate E_uid[8], 105*0Sstevel@tonic-gate E_gid[8], 106*0Sstevel@tonic-gate E_nlink[8], 107*0Sstevel@tonic-gate E_mtime[8], 108*0Sstevel@tonic-gate E_filesize[8], 109*0Sstevel@tonic-gate E_maj[8], 110*0Sstevel@tonic-gate E_min[8], 111*0Sstevel@tonic-gate E_rmaj[8], 112*0Sstevel@tonic-gate E_rmin[8], 113*0Sstevel@tonic-gate E_namesize[8], 114*0Sstevel@tonic-gate E_chksum[8], 115*0Sstevel@tonic-gate E_name[EXPNLEN]; 116*0Sstevel@tonic-gate }; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* Tar header structure and format */ 119*0Sstevel@tonic-gate 120*0Sstevel@tonic-gate #define TBLOCK 512 /* length of tar header and data blocks */ 121*0Sstevel@tonic-gate #define TNAMLEN 100 /* maximum length for tar file names */ 122*0Sstevel@tonic-gate #define TMODLEN 8 /* length of mode field */ 123*0Sstevel@tonic-gate #define TUIDLEN 8 /* length of uid field */ 124*0Sstevel@tonic-gate #define TGIDLEN 8 /* length of gid field */ 125*0Sstevel@tonic-gate #define TSIZLEN 12 /* length of size field */ 126*0Sstevel@tonic-gate #define TTIMLEN 12 /* length of modification time field */ 127*0Sstevel@tonic-gate #define TCRCLEN 8 /* length of header checksum field */ 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate /* tar header definition */ 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate union tblock { 132*0Sstevel@tonic-gate char dummy[TBLOCK]; 133*0Sstevel@tonic-gate struct tar_hdr { 134*0Sstevel@tonic-gate char t_name[TNAMLEN], /* name of file */ 135*0Sstevel@tonic-gate t_mode[TMODLEN], /* mode of file */ 136*0Sstevel@tonic-gate t_uid[TUIDLEN], /* uid of file */ 137*0Sstevel@tonic-gate t_gid[TGIDLEN], /* gid of file */ 138*0Sstevel@tonic-gate t_size[TSIZLEN], /* size of file in bytes */ 139*0Sstevel@tonic-gate t_mtime[TTIMLEN], /* modification time of file */ 140*0Sstevel@tonic-gate t_cksum[TCRCLEN], /* checksum of header */ 141*0Sstevel@tonic-gate t_typeflag, 142*0Sstevel@tonic-gate t_linkname[TNAMLEN], /* file this file linked with */ 143*0Sstevel@tonic-gate t_magic[TMAGLEN], 144*0Sstevel@tonic-gate t_version[TVERSLEN], 145*0Sstevel@tonic-gate t_uname[32], 146*0Sstevel@tonic-gate t_gname[32], 147*0Sstevel@tonic-gate t_devmajor[8], 148*0Sstevel@tonic-gate t_devminor[8], 149*0Sstevel@tonic-gate t_prefix[155]; 150*0Sstevel@tonic-gate } tbuf; 151*0Sstevel@tonic-gate }; 152*0Sstevel@tonic-gate 153*0Sstevel@tonic-gate /* volcopy tape label format and structure */ 154*0Sstevel@tonic-gate 155*0Sstevel@tonic-gate #define VMAGLEN 8 156*0Sstevel@tonic-gate #define VVOLLEN 6 157*0Sstevel@tonic-gate #define VFILLEN 464 158*0Sstevel@tonic-gate 159*0Sstevel@tonic-gate struct volcopy_label { 160*0Sstevel@tonic-gate char v_magic[VMAGLEN], 161*0Sstevel@tonic-gate v_volume[VVOLLEN], 162*0Sstevel@tonic-gate v_reels, 163*0Sstevel@tonic-gate v_reel; 164*0Sstevel@tonic-gate int v_time, 165*0Sstevel@tonic-gate v_length, 166*0Sstevel@tonic-gate v_dens, 167*0Sstevel@tonic-gate v_reelblks, /* u370 added field */ 168*0Sstevel@tonic-gate v_blksize, /* u370 added field */ 169*0Sstevel@tonic-gate v_nblocks; /* u370 added field */ 170*0Sstevel@tonic-gate char v_fill[VFILLEN]; 171*0Sstevel@tonic-gate int v_offset; /* used with -e and -reel options */ 172*0Sstevel@tonic-gate int v_type; /* does tape have nblocks field? */ 173*0Sstevel@tonic-gate }; 174*0Sstevel@tonic-gate 175*0Sstevel@tonic-gate /* 176*0Sstevel@tonic-gate * Define archive formats for extended attributes. 177*0Sstevel@tonic-gate * 178*0Sstevel@tonic-gate * Extended attributes are stored in two pieces. 179*0Sstevel@tonic-gate * 1. An attribute header which has information about 180*0Sstevel@tonic-gate * what file the attribute is for and what the attribute 181*0Sstevel@tonic-gate * is named. 182*0Sstevel@tonic-gate * 2. The attribute record itself. Stored as a normal file type 183*0Sstevel@tonic-gate * of entry. 184*0Sstevel@tonic-gate * Both the header and attribute record have special modes/typeflags 185*0Sstevel@tonic-gate * associated with them. 186*0Sstevel@tonic-gate * 187*0Sstevel@tonic-gate * The names of the header in the archive look like: 188*0Sstevel@tonic-gate * /dev/null/attr.hdr 189*0Sstevel@tonic-gate * 190*0Sstevel@tonic-gate * The name of the attribute looks like: 191*0Sstevel@tonic-gate * /dev/null/attr. 192*0Sstevel@tonic-gate * 193*0Sstevel@tonic-gate * This is done so that an archiver that doesn't understand these formats 194*0Sstevel@tonic-gate * can just dispose of the attribute records unless the user chooses to 195*0Sstevel@tonic-gate * rename them via cpio -r or pax -i 196*0Sstevel@tonic-gate * 197*0Sstevel@tonic-gate * The format is composed of a fixed size header followed 198*0Sstevel@tonic-gate * by a variable sized xattr_buf. If the attribute is a hard link 199*0Sstevel@tonic-gate * to another attribute, then another xattr_buf section is included 200*0Sstevel@tonic-gate * for the link. 201*0Sstevel@tonic-gate * 202*0Sstevel@tonic-gate * The xattr_buf is used to define the necessary "pathing" steps 203*0Sstevel@tonic-gate * to get to the extended attribute. This is necessary to support 204*0Sstevel@tonic-gate * a fully recursive attribute model where an attribute may itself 205*0Sstevel@tonic-gate * have an attribute. 206*0Sstevel@tonic-gate * 207*0Sstevel@tonic-gate * The basic layout looks like this. 208*0Sstevel@tonic-gate * 209*0Sstevel@tonic-gate * -------------------------------- 210*0Sstevel@tonic-gate * | | 211*0Sstevel@tonic-gate * | xattr_hdr | 212*0Sstevel@tonic-gate * | | 213*0Sstevel@tonic-gate * -------------------------------- 214*0Sstevel@tonic-gate * -------------------------------- 215*0Sstevel@tonic-gate * | | 216*0Sstevel@tonic-gate * | xattr_buf | 217*0Sstevel@tonic-gate * | | 218*0Sstevel@tonic-gate * -------------------------------- 219*0Sstevel@tonic-gate * -------------------------------- 220*0Sstevel@tonic-gate * | | 221*0Sstevel@tonic-gate * | (optional link info) | 222*0Sstevel@tonic-gate * | | 223*0Sstevel@tonic-gate * -------------------------------- 224*0Sstevel@tonic-gate * -------------------------------- 225*0Sstevel@tonic-gate * | | 226*0Sstevel@tonic-gate * | attribute itself | 227*0Sstevel@tonic-gate * | stored as normal tar | 228*0Sstevel@tonic-gate * | or cpio data with | 229*0Sstevel@tonic-gate * | special mode or | 230*0Sstevel@tonic-gate * | typeflag | 231*0Sstevel@tonic-gate * | | 232*0Sstevel@tonic-gate * -------------------------------- 233*0Sstevel@tonic-gate * 234*0Sstevel@tonic-gate */ 235*0Sstevel@tonic-gate #define XATTR_ARCH_VERS "1.0" 236*0Sstevel@tonic-gate 237*0Sstevel@tonic-gate /* 238*0Sstevel@tonic-gate * extended attribute fixed header 239*0Sstevel@tonic-gate * 240*0Sstevel@tonic-gate * h_version format version. 241*0Sstevel@tonic-gate * h_size size of header + variable sized data sections. 242*0Sstevel@tonic-gate * h_component_len Length of entire pathing section. 243*0Sstevel@tonic-gate * h_link_component_len Length of link component section. Again same definition 244*0Sstevel@tonic-gate * as h_component_len. 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate struct xattr_hdr { 247*0Sstevel@tonic-gate char h_version[7]; 248*0Sstevel@tonic-gate char h_size[10]; 249*0Sstevel@tonic-gate char h_component_len[10]; /* total length of path component */ 250*0Sstevel@tonic-gate char h_link_component_len[10]; 251*0Sstevel@tonic-gate }; 252*0Sstevel@tonic-gate 253*0Sstevel@tonic-gate /* 254*0Sstevel@tonic-gate * The name is encoded like this: 255*0Sstevel@tonic-gate * filepathNULattrpathNUL[attrpathNULL]... 256*0Sstevel@tonic-gate */ 257*0Sstevel@tonic-gate struct xattr_buf { 258*0Sstevel@tonic-gate char h_namesz[7]; /* length of h_names */ 259*0Sstevel@tonic-gate char h_typeflag; /* actual typeflag of file being archived */ 260*0Sstevel@tonic-gate char h_names[1]; /* filepathNULattrpathNUL... */ 261*0Sstevel@tonic-gate }; 262*0Sstevel@tonic-gate 263*0Sstevel@tonic-gate /* 264*0Sstevel@tonic-gate * Special values for tar archives 265*0Sstevel@tonic-gate */ 266*0Sstevel@tonic-gate 267*0Sstevel@tonic-gate /* 268*0Sstevel@tonic-gate * typeflag for tar archives. 269*0Sstevel@tonic-gate */ 270*0Sstevel@tonic-gate 271*0Sstevel@tonic-gate /* 272*0Sstevel@tonic-gate * Attribute hdr and attribute files have the following typeflag 273*0Sstevel@tonic-gate */ 274*0Sstevel@tonic-gate #define _XATTR_HDRTYPE 'E' 275*0Sstevel@tonic-gate 276*0Sstevel@tonic-gate /* 277*0Sstevel@tonic-gate * For cpio archives the header and attribute have 278*0Sstevel@tonic-gate * _XATTR_CPIO_MODE ORED into the mode field in both 279*0Sstevel@tonic-gate * character and binary versions of the archive format 280*0Sstevel@tonic-gate */ 281*0Sstevel@tonic-gate #define _XATTR_CPIO_MODE 0xB000 282*0Sstevel@tonic-gate 283*0Sstevel@tonic-gate #ifdef __cplusplus 284*0Sstevel@tonic-gate } 285*0Sstevel@tonic-gate #endif 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate #endif /* _ARCHIVES_H */ 288