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