11556Srgrimes/*- 21556Srgrimes * Copyright (c) 1992 Keith Muller. 31556Srgrimes * Copyright (c) 1992, 1993 41556Srgrimes * The Regents of the University of California. All rights reserved. 51556Srgrimes * 61556Srgrimes * This code is derived from software contributed to Berkeley by 71556Srgrimes * Keith Muller of the University of California, San Diego. 81556Srgrimes * 91556Srgrimes * Redistribution and use in source and binary forms, with or without 101556Srgrimes * modification, are permitted provided that the following conditions 111556Srgrimes * are met: 121556Srgrimes * 1. Redistributions of source code must retain the above copyright 131556Srgrimes * notice, this list of conditions and the following disclaimer. 141556Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 151556Srgrimes * notice, this list of conditions and the following disclaimer in the 161556Srgrimes * documentation and/or other materials provided with the distribution. 171556Srgrimes * 4. Neither the name of the University nor the names of its contributors 181556Srgrimes * may be used to endorse or promote products derived from this software 191556Srgrimes * without specific prior written permission. 201556Srgrimes * 211556Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 221556Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 231556Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 241556Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 251556Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 261556Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 271556Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 281556Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 291556Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 301556Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 311556Srgrimes * SUCH DAMAGE. 321556Srgrimes * 331556Srgrimes * @(#)cpio.h 8.1 (Berkeley) 5/31/93 3450471Speter * $FreeBSD$ 351556Srgrimes */ 361556Srgrimes 371556Srgrimes/* 381556Srgrimes * Defines common to all versions of cpio 391556Srgrimes */ 401556Srgrimes#define TRAILER "TRAILER!!!" /* name in last archive record */ 411556Srgrimes 421556Srgrimes/* 431556Srgrimes * Header encoding of the different file types 441556Srgrimes */ 451556Srgrimes#define C_ISDIR 040000 /* Directory */ 461556Srgrimes#define C_ISFIFO 010000 /* FIFO */ 471556Srgrimes#define C_ISREG 0100000 /* Regular file */ 481556Srgrimes#define C_ISBLK 060000 /* Block special file */ 491556Srgrimes#define C_ISCHR 020000 /* Character special file */ 501556Srgrimes#define C_ISCTG 0110000 /* Reserved for contiguous files */ 511556Srgrimes#define C_ISLNK 0120000 /* Reserved for symbolic links */ 521556Srgrimes#define C_ISOCK 0140000 /* Reserved for sockets */ 531556Srgrimes#define C_IFMT 0170000 /* type of file */ 541556Srgrimes 551556Srgrimes/* 561556Srgrimes * Data Interchange Format - Extended cpio header format - POSIX 1003.1-1990 571556Srgrimes */ 581556Srgrimestypedef struct { 591556Srgrimes char c_magic[6]; /* magic cookie */ 601556Srgrimes char c_dev[6]; /* device number */ 611556Srgrimes char c_ino[6]; /* inode number */ 621556Srgrimes char c_mode[6]; /* file type/access */ 631556Srgrimes char c_uid[6]; /* owners uid */ 641556Srgrimes char c_gid[6]; /* owners gid */ 651556Srgrimes char c_nlink[6]; /* # of links at archive creation */ 661556Srgrimes char c_rdev[6]; /* block/char major/minor # */ 671556Srgrimes char c_mtime[11]; /* modification time */ 681556Srgrimes char c_namesize[6]; /* length of pathname */ 691556Srgrimes char c_filesize[11]; /* length of file in bytes */ 70203613Simp} HD_CPIO __aligned(1); 711556Srgrimes 721556Srgrimes#define MAGIC 070707 /* transportable archive id */ 731556Srgrimes 741556Srgrimes#ifdef _PAX_ 751556Srgrimes#define AMAGIC "070707" /* ascii equivalent string of MAGIC */ 761556Srgrimes#define CPIO_MASK 0x3ffff /* bits valid in the dev/ino fields */ 771556Srgrimes /* used for dev/inode remaps */ 781556Srgrimes#endif /* _PAX_ */ 791556Srgrimes 801556Srgrimes/* 818855Srgrimes * Binary cpio header structure 821556Srgrimes * 831556Srgrimes * CAUTION! CAUTION! CAUTION! 841556Srgrimes * Each field really represents a 16 bit short (NOT ASCII). Described as 851556Srgrimes * an array of chars in an attempt to improve portability!! 861556Srgrimes */ 871556Srgrimestypedef struct { 881556Srgrimes u_char h_magic[2]; 891556Srgrimes u_char h_dev[2]; 901556Srgrimes u_char h_ino[2]; 911556Srgrimes u_char h_mode[2]; 921556Srgrimes u_char h_uid[2]; 931556Srgrimes u_char h_gid[2]; 941556Srgrimes u_char h_nlink[2]; 951556Srgrimes u_char h_rdev[2]; 961556Srgrimes u_char h_mtime_1[2]; 971556Srgrimes u_char h_mtime_2[2]; 981556Srgrimes u_char h_namesize[2]; 991556Srgrimes u_char h_filesize_1[2]; 1001556Srgrimes u_char h_filesize_2[2]; 101203613Simp} HD_BCPIO __aligned(1); 1021556Srgrimes 1031556Srgrimes#ifdef _PAX_ 1041556Srgrimes/* 1051556Srgrimes * extraction and creation macros for binary cpio 1061556Srgrimes */ 1071556Srgrimes#define SHRT_EXT(ch) ((((unsigned)(ch)[0])<<8) | (((unsigned)(ch)[1])&0xff)) 1081556Srgrimes#define RSHRT_EXT(ch) ((((unsigned)(ch)[1])<<8) | (((unsigned)(ch)[0])&0xff)) 1091556Srgrimes#define CHR_WR_0(val) ((char)(((val) >> 24) & 0xff)) 1101556Srgrimes#define CHR_WR_1(val) ((char)(((val) >> 16) & 0xff)) 1111556Srgrimes#define CHR_WR_2(val) ((char)(((val) >> 8) & 0xff)) 1121556Srgrimes#define CHR_WR_3(val) ((char)((val) & 0xff)) 1131556Srgrimes 1141556Srgrimes/* 1151556Srgrimes * binary cpio masks and pads 1161556Srgrimes */ 1171556Srgrimes#define BCPIO_PAD(x) ((2 - ((x) & 1)) & 1) /* pad to next 2 byte word */ 1181556Srgrimes#define BCPIO_MASK 0xffff /* mask for dev/ino fields */ 1191556Srgrimes#endif /* _PAX_ */ 1201556Srgrimes 1211556Srgrimes/* 1221556Srgrimes * System VR4 cpio header structure (with/without file data crc) 1231556Srgrimes */ 1241556Srgrimestypedef struct { 1251556Srgrimes char c_magic[6]; /* magic cookie */ 1261556Srgrimes char c_ino[8]; /* inode number */ 1271556Srgrimes char c_mode[8]; /* file type/access */ 1281556Srgrimes char c_uid[8]; /* owners uid */ 1291556Srgrimes char c_gid[8]; /* owners gid */ 1301556Srgrimes char c_nlink[8]; /* # of links at archive creation */ 1311556Srgrimes char c_mtime[8]; /* modification time */ 1321556Srgrimes char c_filesize[8]; /* length of file in bytes */ 1331556Srgrimes char c_maj[8]; /* block/char major # */ 1341556Srgrimes char c_min[8]; /* block/char minor # */ 1351556Srgrimes char c_rmaj[8]; /* special file major # */ 1361556Srgrimes char c_rmin[8]; /* special file minor # */ 1371556Srgrimes char c_namesize[8]; /* length of pathname */ 1381556Srgrimes char c_chksum[8]; /* 0 OR CRC of bytes of FILE data */ 139203613Simp} HD_VCPIO __aligned(1); 1401556Srgrimes 1411556Srgrimes#define VMAGIC 070701 /* sVr4 new portable archive id */ 1421556Srgrimes#define VCMAGIC 070702 /* sVr4 new portable archive id CRC */ 1431556Srgrimes#ifdef _PAX_ 1441556Srgrimes#define AVMAGIC "070701" /* ascii string of above */ 1451556Srgrimes#define AVCMAGIC "070702" /* ascii string of above */ 1461556Srgrimes#define VCPIO_PAD(x) ((4 - ((x) & 3)) & 3) /* pad to next 4 byte word */ 1471556Srgrimes#define VCPIO_MASK 0xffffffff /* mask for dev/ino fields */ 1481556Srgrimes#endif /* _PAX_ */ 149