xref: /illumos-gate/usr/src/head/protocols/dumprestore.h (revision c5bab7026b8e0ac44b25ee08507ea360f177d844)
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 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 /*
43  * This header file defines two different versions of the
44  * ufsdump/ufsrestore interface.  If the defined constant
45  * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in
46  * this header file will support backups of more than 2 terabytes
47  * of data.
48  *
49  * In the old format (the format that only supports dumps
50  * of less than 2 terabytes), TP_BSIZE is the size of file blocks
51  * on the dump tapes.
52  * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
53  *
54  * In the new format, tp_bsize is used to store the
55  * tape block size, which is variable.  The tape block size
56  * is like 'fragsize', in that 'c_tapea' in each tape record
57  * contains the 'tape block record' number in a signed int.
58  * We set TP_BSIZE_MAX to 65536, which will handle 128TB
59  * of data.  The new format is indicated by a magic number
60  * in the tape header of MTB_MAGIC.  The new format is only
61  * used when the size of the backup exceeds 2 TB.  If the
62  * backup can be stored in less thatn 2 TB, ufsdump still
63  * uses the format indicated by the NFS_MAGIC magic number.
64  * Therefore, backups of less than 2 TB are still readable
65  * by earlier versions of ufsrestore.
66  *
67  * NTREC is the number of TP_BSIZE blocks that are written
68  * in each tape record. HIGHDENSITYTREC is the number of
69  * TP_BSIZE blocks that are written in each tape record on
70  * 6250 BPI or higher density tapes.  CARTRIDGETREC is the
71  * number of TP_BSIZE (or tp_bsize) blocks that are written
72  * in each tape record on cartridge tapes.
73  *
74  * TP_NINDIR is the number of indirect pointers in a TS_INODE
75  * or TS_ADDR record. Note that it must be a power of two.
76  *
77  */
78 #define	TP_BSIZE_MAX	65536
79 #define	TP_BSIZE_MIN	1024
80 #define	ESIZE_SHIFT_MAX	6	/* shift TP_BSIZE_MIN to TP_BSIZE_MAX */
81 
82 #ifdef SUPPORTS_MTB_TAPE_FORMAT
83 #define	TP_BUFSIZE	TP_BSIZE_MAX
84 extern	int32_t		tp_bsize;
85 #else
86 #define	TP_BSIZE	1024
87 #define	TP_BUFSIZE	TP_BSIZE
88 #endif /* SUPPORTS_MTB_TAPE_FORMAT */
89 
90 #define	NTREC		10
91 #define	HIGHDENSITYTREC	32
92 #define	CARTRIDGETREC	63
93 #define	TP_NINDIR	(TP_BSIZE_MIN/2)
94 #define	TP_NINOS	(TP_NINDIR / sizeof (long))
95 #define	LBLSIZE		16
96 #define	NAMELEN		64
97 
98 #define	OFS_MAGIC	(int)60011
99 #define	NFS_MAGIC	(int)60012
100 #define	MTB_MAGIC	(int)60013
101 #define	CHECKSUM	(int)84446
102 
103 union u_data {
104 	char	s_addrs[TP_NINDIR];	/* 1 => data; 0 => hole in inode */
105 	int32_t	s_inos[TP_NINOS];	/* starting inodes on tape */
106 };
107 
108 union u_shadow {
109 	struct s_nonsh {
110 		int32_t	c_level;		/* level of this dump */
111 		char	c_filesys[NAMELEN];	/* dumpped file system name */
112 		char	c_dev[NAMELEN];		/* name of dumpped device */
113 		char	c_host[NAMELEN];	/* name of dumpped host */
114 	} c_nonsh;
115 	char    c_shadow[1];
116 };
117 
118 /* if you change anything here, be sure to change normspcl in byteorder.c */
119 
120 union u_spcl {
121 	char dummy[TP_BUFSIZE];
122 	struct	s_spcl {
123 		int32_t	c_type;		    /* record type (see below) */
124 		time32_t c_date;	    /* date of previous dump */
125 		time32_t c_ddate;	    /* date of this dump */
126 		int32_t	c_volume;	    /* dump volume number */
127 		daddr32_t c_tapea;	    /* logical block of this record */
128 		ino32_t	c_inumber;	    /* number of inode */
129 		int32_t	c_magic;	    /* magic number (see above) */
130 		int32_t	c_checksum;	    /* record checksum */
131 		struct	dinode	c_dinode;   /* ownership and mode of inode */
132 		int32_t	c_count;	    /* number of valid c_addr entries */
133 		union	u_data c_data;	    /* see union above */
134 		char	c_label[LBLSIZE];   /* dump label */
135 		union	u_shadow c_shadow;  /* see union above */
136 		int32_t	c_flags;	    /* additional information */
137 		int32_t	c_firstrec;	    /* first record on volume */
138 #ifdef SUPPORTS_MTB_TAPE_FORMAT
139 		int32_t	c_tpbsize;	    /* tape block size */
140 		int32_t	c_spare[31];	    /* reserved for future uses */
141 #else
142 		int32_t c_spare[32];
143 #endif /* SUPPORTS_MTB_TAPE_FORMAT */
144 	} s_spcl;
145 } u_spcl;
146 #define	spcl u_spcl.s_spcl
147 #define	c_addr c_data.s_addrs
148 #define	c_inos c_data.s_inos
149 #define	c_level c_shadow.c_nonsh.c_level
150 #define	c_filesys c_shadow.c_nonsh.c_filesys
151 #define	c_dev c_shadow.c_nonsh.c_dev
152 #define	c_host c_shadow.c_nonsh.c_host
153 
154 /*
155  * special record types
156  */
157 #define	TS_TAPE		1	/* dump tape header */
158 #define	TS_INODE	2	/* beginning of file record */
159 #define	TS_ADDR		4	/* continuation of file record */
160 #define	TS_BITS		3	/* map of inodes on tape */
161 #define	TS_CLRI		6	/* map of inodes deleted since last dump */
162 #define	TS_END		5	/* end of volume marker */
163 #define	TS_EOM		7	/* floppy EOM - restore compat w/ old dump */
164 
165 /*
166  * flag values
167  */
168 #define	DR_NEWHEADER	1	/* new format tape header */
169 #define	DR_INODEINFO	2	/* header contains starting inode info */
170 #define	DR_REDUMP	4	/* dump contains recopies of active files */
171 #define	DR_TRUEINC	8	/* dump is a "true incremental"	*/
172 #define	DR_HASMETA	16	/* metadata in this header */
173 
174 
175 
176 #define	DUMPOUTFMT	"%-32s %c %s"		/* for printf */
177 						/* name, incno, ctime(date) */
178 #define	DUMPINFMT	"%258s %c %128[^\n]\n"	/* inverse for scanf */
179 
180 #ifdef __cplusplus
181 }
182 #endif
183 
184 #endif	/* !_PROTOCOLS_DUMPRESTORE_H */
185