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