xref: /openbsd/include/protocols/dumprestore.h (revision 9be7043f)
1 /*	$OpenBSD: dumprestore.h,v 1.11 2021/01/21 00:16:36 mortimer Exp $	*/
2 /*	$NetBSD: dumprestore.h,v 1.14 2005/12/26 19:01:47 perry Exp $	*/
3 
4 /*
5  * Copyright (c) 1980, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)dumprestore.h	8.2 (Berkeley) 1/21/94
38  */
39 
40 #ifndef _PROTOCOLS_DUMPRESTORE_H_
41 #define _PROTOCOLS_DUMPRESTORE_H_
42 
43 /*
44  * TP_BSIZE is the size of file blocks on the dump tapes.
45  * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
46  *
47  * NTREC is the number of TP_BSIZE blocks that are written
48  * in each tape record. HIGHDENSITYTREC is the number of
49  * TP_BSIZE blocks that are written in each tape record on
50  * 6250 BPI or higher density tapes.
51  *
52  * TP_NINDIR is the number of indirect pointers in a TS_INODE
53  * or TS_ADDR record. Note that it must be a power of two.
54  */
55 #define TP_BSIZE	1024
56 #define NTREC   	10
57 #define HIGHDENSITYTREC	32
58 #define TP_NINDIR	(TP_BSIZE/2)
59 #define LBLSIZE		16
60 #define NAMELEN		64
61 
62 #define OFS_MAGIC   	(int)60011
63 #define NFS_MAGIC   	(int)60012
64 #ifndef FS_UFS2_MAGIC
65 #define FS_UFS2_MAGIC   (int)0x19540119
66 #endif
67 #define CHECKSUM	(int)84446
68 
69 extern union u_spcl {
70 	char dummy[TP_BSIZE];
71 	struct	s_spcl {
72 		int32_t	c_type;		    /* record type (see below) */
73 		int32_t	c_old_date;	    /* date of this dump */
74 		int32_t	c_old_ddate;	    /* date of previous dump */
75 		int32_t	c_volume;	    /* dump volume number */
76 		int32_t	c_old_tapea;	    /* logical block of this record */
77 		uint32_t c_inumber;	    /* number of inode */
78 		int32_t	c_magic;	    /* magic number (see above) */
79 		int32_t	c_checksum;	    /* record checksum */
80 		union {
81 			struct ufs1_dinode __uc_dinode;
82 			struct {
83 				uint16_t __uc_mode;
84 				int16_t __uc_spare1[3];
85 				uint64_t __uc_size;
86 				int32_t __uc_old_atime;
87 				int32_t __uc_atimensec;
88 				int32_t __uc_old_mtime;
89 				int32_t __uc_mtimensec;
90 				int32_t __uc_spare2[2];
91 				int32_t __uc_rdev;
92 				int32_t __uc_birthtimensec;
93 				int64_t __uc_birthtime;
94 				int64_t __uc_atime;
95 				int64_t __uc_mtime;
96 				int32_t __uc_spare4[7];
97 				uint32_t __uc_file_flags;
98 				int32_t __uc_spare5[2];
99 				uint32_t __uc_uid;
100 				uint32_t __uc_gid;
101 				int32_t __uc_spare6[2];
102 			} __uc_ino;
103 		} __c_ino;
104 		int32_t	c_count;	    /* number of valid c_addr entries */
105 		char	c_addr[TP_NINDIR];  /* 1 => data; 0 => hole in inode */
106 		char	c_label[LBLSIZE];   /* dump label */
107 		int32_t	c_level;	    /* level of this dump */
108 		char	c_filesys[NAMELEN]; /* name of dumped file system */
109 		char	c_dev[NAMELEN];	    /* name of dumped device */
110 		char	c_host[NAMELEN];    /* name of dumped host */
111 		int32_t	c_flags;	    /* additional information */
112 		int32_t	c_old_firstrec;	    /* first record on volume */
113 		int64_t c_date;		    /* date of this dump */
114 		int64_t c_ddate;	    /* date of previous dump */
115 		int64_t c_tapea;	    /* logical block of this record */
116 		int64_t c_firstrec;	    /* first record on volume */
117 		int32_t	c_spare[24];	    /* reserved for future uses */
118 	} s_spcl;
119 } u_spcl;
120 #define spcl u_spcl.s_spcl
121 
122 #define c_dinode	__c_ino.__uc_dinode
123 #define c_mode		__c_ino.__uc_ino.__uc_mode
124 #define c_spare1	__c_ino.__uc_ino.__uc_spare1
125 #define c_size		__c_ino.__uc_ino.__uc_size
126 #define c_old_atime	__c_ino.__uc_ino.__uc_old_atime
127 #define c_atime		__c_ino.__uc_ino.__uc_atime
128 #define c_atimensec	__c_ino.__uc_ino.__uc_atimensec
129 #define c_mtime		__c_ino.__uc_ino.__uc_mtime
130 #define c_mtimensec	__c_ino.__uc_ino.__uc_mtimensec
131 #define c_birthtime	__c_ino.__uc_ino.__uc_birthtime
132 #define c_birthtimensec	__c_ino.__uc_ino.__uc_birthtimensec
133 #define c_old_mtime	__c_ino.__uc_ino.__uc_old_mtime
134 #define c_rdev		__c_ino.__uc_ino.__uc_rdev
135 #define c_file_flags	__c_ino.__uc_ino.__uc_file_flags
136 #define c_uid		__c_ino.__uc_ino.__uc_uid
137 #define c_gid		__c_ino.__uc_ino.__uc_gid
138 
139 /*
140  * special record types
141  */
142 #define TS_TAPE 	1	/* dump tape header */
143 #define TS_INODE	2	/* beginning of file record */
144 #define TS_ADDR 	4	/* continuation of file record */
145 #define TS_BITS 	3	/* map of inodes on tape */
146 #define TS_CLRI 	6	/* map of inodes deleted since last dump */
147 #define TS_END  	5	/* end of volume marker */
148 
149 /*
150  * flag values
151  */
152 #define DR_NEWHEADER	0x0001	/* new format tape header */
153 #define DR_NEWINODEFMT	0x0002	/* new format inodes on tape */
154 
155 #define	DUMPOUTFMT	"%-18s %c %s"		/* for printf */
156 						/* name, level, ctime(date) */
157 #define	DUMPINFMT	"%18s %c %[^\n]\n"	/* inverse for scanf */
158 
159 #endif /* !_PROTOCOLS_DUMPRESTORE_H_ */
160