1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1983,1984,1985,1986,1987,1988,1989 AT&T. */ 28*7c478bd9Sstevel@tonic-gate /* All rights reserved. */ 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate /* 31*7c478bd9Sstevel@tonic-gate * Portions of this source code were derived from Berkeley 4.3 BSD 32*7c478bd9Sstevel@tonic-gate * under license from the Regents of the University of California. 33*7c478bd9Sstevel@tonic-gate */ 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate #ifndef _PROTOCOLS_DUMPRESTORE_H 36*7c478bd9Sstevel@tonic-gate #define _PROTOCOLS_DUMPRESTORE_H 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 39*7c478bd9Sstevel@tonic-gate 40*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 41*7c478bd9Sstevel@tonic-gate extern "C" { 42*7c478bd9Sstevel@tonic-gate #endif 43*7c478bd9Sstevel@tonic-gate 44*7c478bd9Sstevel@tonic-gate /* 45*7c478bd9Sstevel@tonic-gate * This header file defines two different versions of the 46*7c478bd9Sstevel@tonic-gate * ufsdump/ufsrestore interface. If the defined constant 47*7c478bd9Sstevel@tonic-gate * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in 48*7c478bd9Sstevel@tonic-gate * this header file will support backups of more than 2 terabytes 49*7c478bd9Sstevel@tonic-gate * of data. 50*7c478bd9Sstevel@tonic-gate * 51*7c478bd9Sstevel@tonic-gate * In the old format (the format that only supports dumps 52*7c478bd9Sstevel@tonic-gate * of less than 2 terabytes), TP_BSIZE is the size of file blocks 53*7c478bd9Sstevel@tonic-gate * on the dump tapes. 54*7c478bd9Sstevel@tonic-gate * Note that TP_BSIZE must be a multiple of DEV_BSIZE. 55*7c478bd9Sstevel@tonic-gate * 56*7c478bd9Sstevel@tonic-gate * In the new format, tp_bsize is used to store the 57*7c478bd9Sstevel@tonic-gate * tape block size, which is variable. The tape block size 58*7c478bd9Sstevel@tonic-gate * is like 'fragsize', in that 'c_tapea' in each tape record 59*7c478bd9Sstevel@tonic-gate * contains the 'tape block record' number in a signed int. 60*7c478bd9Sstevel@tonic-gate * We set TP_BSIZE_MAX to 65536, which will handle 128TB 61*7c478bd9Sstevel@tonic-gate * of data. The new format is indicated by a magic number 62*7c478bd9Sstevel@tonic-gate * in the tape header of MTB_MAGIC. The new format is only 63*7c478bd9Sstevel@tonic-gate * used when the size of the backup exceeds 2 TB. If the 64*7c478bd9Sstevel@tonic-gate * backup can be stored in less thatn 2 TB, ufsdump still 65*7c478bd9Sstevel@tonic-gate * uses the format indicated by the NFS_MAGIC magic number. 66*7c478bd9Sstevel@tonic-gate * Therefore, backups of less than 2 TB are still readable 67*7c478bd9Sstevel@tonic-gate * by earlier versions of ufsrestore. 68*7c478bd9Sstevel@tonic-gate * 69*7c478bd9Sstevel@tonic-gate * NTREC is the number of TP_BSIZE blocks that are written 70*7c478bd9Sstevel@tonic-gate * in each tape record. HIGHDENSITYTREC is the number of 71*7c478bd9Sstevel@tonic-gate * TP_BSIZE blocks that are written in each tape record on 72*7c478bd9Sstevel@tonic-gate * 6250 BPI or higher density tapes. CARTRIDGETREC is the 73*7c478bd9Sstevel@tonic-gate * number of TP_BSIZE (or tp_bsize) blocks that are written 74*7c478bd9Sstevel@tonic-gate * in each tape record on cartridge tapes. 75*7c478bd9Sstevel@tonic-gate * 76*7c478bd9Sstevel@tonic-gate * TP_NINDIR is the number of indirect pointers in a TS_INODE 77*7c478bd9Sstevel@tonic-gate * or TS_ADDR record. Note that it must be a power of two. 78*7c478bd9Sstevel@tonic-gate * 79*7c478bd9Sstevel@tonic-gate */ 80*7c478bd9Sstevel@tonic-gate #define TP_BSIZE_MAX 65536 81*7c478bd9Sstevel@tonic-gate #define TP_BSIZE_MIN 1024 82*7c478bd9Sstevel@tonic-gate #define ESIZE_SHIFT_MAX 6 /* shift TP_BSIZE_MIN to TP_BSIZE_MAX */ 83*7c478bd9Sstevel@tonic-gate 84*7c478bd9Sstevel@tonic-gate #ifdef SUPPORTS_MTB_TAPE_FORMAT 85*7c478bd9Sstevel@tonic-gate #define TP_BUFSIZE TP_BSIZE_MAX 86*7c478bd9Sstevel@tonic-gate extern int32_t tp_bsize; 87*7c478bd9Sstevel@tonic-gate #else 88*7c478bd9Sstevel@tonic-gate #define TP_BSIZE 1024 89*7c478bd9Sstevel@tonic-gate #define TP_BUFSIZE TP_BSIZE 90*7c478bd9Sstevel@tonic-gate #endif /* SUPPORTS_MTB_TAPE_FORMAT */ 91*7c478bd9Sstevel@tonic-gate 92*7c478bd9Sstevel@tonic-gate #define NTREC 10 93*7c478bd9Sstevel@tonic-gate #define HIGHDENSITYTREC 32 94*7c478bd9Sstevel@tonic-gate #define CARTRIDGETREC 63 95*7c478bd9Sstevel@tonic-gate #define TP_NINDIR (TP_BSIZE_MIN/2) 96*7c478bd9Sstevel@tonic-gate #define TP_NINOS (TP_NINDIR / sizeof (long)) 97*7c478bd9Sstevel@tonic-gate #define LBLSIZE 16 98*7c478bd9Sstevel@tonic-gate #define NAMELEN 64 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate #define OFS_MAGIC (int)60011 101*7c478bd9Sstevel@tonic-gate #define NFS_MAGIC (int)60012 102*7c478bd9Sstevel@tonic-gate #define MTB_MAGIC (int)60013 103*7c478bd9Sstevel@tonic-gate #define CHECKSUM (int)84446 104*7c478bd9Sstevel@tonic-gate 105*7c478bd9Sstevel@tonic-gate union u_data { 106*7c478bd9Sstevel@tonic-gate char s_addrs[TP_NINDIR]; /* 1 => data; 0 => hole in inode */ 107*7c478bd9Sstevel@tonic-gate int32_t s_inos[TP_NINOS]; /* starting inodes on tape */ 108*7c478bd9Sstevel@tonic-gate }; 109*7c478bd9Sstevel@tonic-gate 110*7c478bd9Sstevel@tonic-gate union u_shadow { 111*7c478bd9Sstevel@tonic-gate struct s_nonsh { 112*7c478bd9Sstevel@tonic-gate int32_t c_level; /* level of this dump */ 113*7c478bd9Sstevel@tonic-gate char c_filesys[NAMELEN]; /* dumpped file system name */ 114*7c478bd9Sstevel@tonic-gate char c_dev[NAMELEN]; /* name of dumpped device */ 115*7c478bd9Sstevel@tonic-gate char c_host[NAMELEN]; /* name of dumpped host */ 116*7c478bd9Sstevel@tonic-gate } c_nonsh; 117*7c478bd9Sstevel@tonic-gate char c_shadow[1]; 118*7c478bd9Sstevel@tonic-gate }; 119*7c478bd9Sstevel@tonic-gate 120*7c478bd9Sstevel@tonic-gate /* if you change anything here, be sure to change normspcl in byteorder.c */ 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate union u_spcl { 123*7c478bd9Sstevel@tonic-gate char dummy[TP_BUFSIZE]; 124*7c478bd9Sstevel@tonic-gate struct s_spcl { 125*7c478bd9Sstevel@tonic-gate int32_t c_type; /* record type (see below) */ 126*7c478bd9Sstevel@tonic-gate time32_t c_date; /* date of previous dump */ 127*7c478bd9Sstevel@tonic-gate time32_t c_ddate; /* date of this dump */ 128*7c478bd9Sstevel@tonic-gate int32_t c_volume; /* dump volume number */ 129*7c478bd9Sstevel@tonic-gate daddr32_t c_tapea; /* logical block of this record */ 130*7c478bd9Sstevel@tonic-gate ino32_t c_inumber; /* number of inode */ 131*7c478bd9Sstevel@tonic-gate int32_t c_magic; /* magic number (see above) */ 132*7c478bd9Sstevel@tonic-gate int32_t c_checksum; /* record checksum */ 133*7c478bd9Sstevel@tonic-gate struct dinode c_dinode; /* ownership and mode of inode */ 134*7c478bd9Sstevel@tonic-gate int32_t c_count; /* number of valid c_addr entries */ 135*7c478bd9Sstevel@tonic-gate union u_data c_data; /* see union above */ 136*7c478bd9Sstevel@tonic-gate char c_label[LBLSIZE]; /* dump label */ 137*7c478bd9Sstevel@tonic-gate union u_shadow c_shadow; /* see union above */ 138*7c478bd9Sstevel@tonic-gate int32_t c_flags; /* additional information */ 139*7c478bd9Sstevel@tonic-gate int32_t c_firstrec; /* first record on volume */ 140*7c478bd9Sstevel@tonic-gate #ifdef SUPPORTS_MTB_TAPE_FORMAT 141*7c478bd9Sstevel@tonic-gate int32_t c_tpbsize; /* tape block size */ 142*7c478bd9Sstevel@tonic-gate int32_t c_spare[31]; /* reserved for future uses */ 143*7c478bd9Sstevel@tonic-gate #else 144*7c478bd9Sstevel@tonic-gate int32_t c_spare[32]; 145*7c478bd9Sstevel@tonic-gate #endif /* SUPPORTS_MTB_TAPE_FORMAT */ 146*7c478bd9Sstevel@tonic-gate } s_spcl; 147*7c478bd9Sstevel@tonic-gate } u_spcl; 148*7c478bd9Sstevel@tonic-gate #define spcl u_spcl.s_spcl 149*7c478bd9Sstevel@tonic-gate #define c_addr c_data.s_addrs 150*7c478bd9Sstevel@tonic-gate #define c_inos c_data.s_inos 151*7c478bd9Sstevel@tonic-gate #define c_level c_shadow.c_nonsh.c_level 152*7c478bd9Sstevel@tonic-gate #define c_filesys c_shadow.c_nonsh.c_filesys 153*7c478bd9Sstevel@tonic-gate #define c_dev c_shadow.c_nonsh.c_dev 154*7c478bd9Sstevel@tonic-gate #define c_host c_shadow.c_nonsh.c_host 155*7c478bd9Sstevel@tonic-gate 156*7c478bd9Sstevel@tonic-gate /* 157*7c478bd9Sstevel@tonic-gate * special record types 158*7c478bd9Sstevel@tonic-gate */ 159*7c478bd9Sstevel@tonic-gate #define TS_TAPE 1 /* dump tape header */ 160*7c478bd9Sstevel@tonic-gate #define TS_INODE 2 /* beginning of file record */ 161*7c478bd9Sstevel@tonic-gate #define TS_ADDR 4 /* continuation of file record */ 162*7c478bd9Sstevel@tonic-gate #define TS_BITS 3 /* map of inodes on tape */ 163*7c478bd9Sstevel@tonic-gate #define TS_CLRI 6 /* map of inodes deleted since last dump */ 164*7c478bd9Sstevel@tonic-gate #define TS_END 5 /* end of volume marker */ 165*7c478bd9Sstevel@tonic-gate #define TS_EOM 7 /* floppy EOM - restore compat w/ old dump */ 166*7c478bd9Sstevel@tonic-gate 167*7c478bd9Sstevel@tonic-gate /* 168*7c478bd9Sstevel@tonic-gate * flag values 169*7c478bd9Sstevel@tonic-gate */ 170*7c478bd9Sstevel@tonic-gate #define DR_NEWHEADER 1 /* new format tape header */ 171*7c478bd9Sstevel@tonic-gate #define DR_INODEINFO 2 /* header contains starting inode info */ 172*7c478bd9Sstevel@tonic-gate #define DR_REDUMP 4 /* dump contains recopies of active files */ 173*7c478bd9Sstevel@tonic-gate #define DR_TRUEINC 8 /* dump is a "true incremental" */ 174*7c478bd9Sstevel@tonic-gate #define DR_HASMETA 16 /* metadata in this header */ 175*7c478bd9Sstevel@tonic-gate 176*7c478bd9Sstevel@tonic-gate 177*7c478bd9Sstevel@tonic-gate 178*7c478bd9Sstevel@tonic-gate #define DUMPOUTFMT "%-32s %c %s" /* for printf */ 179*7c478bd9Sstevel@tonic-gate /* name, incno, ctime(date) */ 180*7c478bd9Sstevel@tonic-gate #define DUMPINFMT "%258s %c %128[^\n]\n" /* inverse for scanf */ 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 183*7c478bd9Sstevel@tonic-gate } 184*7c478bd9Sstevel@tonic-gate #endif 185*7c478bd9Sstevel@tonic-gate 186*7c478bd9Sstevel@tonic-gate #endif /* !_PROTOCOLS_DUMPRESTORE_H */ 187