xref: /netbsd-src/include/protocols/dumprestore.h (revision e2325e1f91ff78a0a3b9bef376747a1a1ae02cc6)
1*e2325e1fSchristos /*	$NetBSD: dumprestore.h,v 1.20 2021/06/19 13:56:34 christos Exp $	*/
24d2cbfceScgd 
3e6b5ddd9Scgd /*
4cd1c282aScgd  * Copyright (c) 1980, 1993
5cd1c282aScgd  *	The Regents of the University of California.  All rights reserved.
6e6b5ddd9Scgd  * (c) UNIX System Laboratories, Inc.
7e6b5ddd9Scgd  * All or some portions of this file are derived from material licensed
8e6b5ddd9Scgd  * to the University of California by American Telephone and Telegraph
9e6b5ddd9Scgd  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
10e6b5ddd9Scgd  * the permission of UNIX System Laboratories, Inc.
11e6b5ddd9Scgd  *
12e6b5ddd9Scgd  * Redistribution and use in source and binary forms, with or without
13e6b5ddd9Scgd  * modification, are permitted provided that the following conditions
14e6b5ddd9Scgd  * are met:
15e6b5ddd9Scgd  * 1. Redistributions of source code must retain the above copyright
16e6b5ddd9Scgd  *    notice, this list of conditions and the following disclaimer.
17e6b5ddd9Scgd  * 2. Redistributions in binary form must reproduce the above copyright
18e6b5ddd9Scgd  *    notice, this list of conditions and the following disclaimer in the
19e6b5ddd9Scgd  *    documentation and/or other materials provided with the distribution.
20039cc956Sagc  * 3. Neither the name of the University nor the names of its contributors
21e6b5ddd9Scgd  *    may be used to endorse or promote products derived from this software
22e6b5ddd9Scgd  *    without specific prior written permission.
23e6b5ddd9Scgd  *
24e6b5ddd9Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25e6b5ddd9Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26e6b5ddd9Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27e6b5ddd9Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28e6b5ddd9Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29e6b5ddd9Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30e6b5ddd9Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31e6b5ddd9Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32e6b5ddd9Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33e6b5ddd9Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34e6b5ddd9Scgd  * SUCH DAMAGE.
35e6b5ddd9Scgd  *
364d2cbfceScgd  *	@(#)dumprestore.h	8.2 (Berkeley) 1/21/94
37e6b5ddd9Scgd  */
38e6b5ddd9Scgd 
393b3774fcSperry #ifndef _PROTOCOLS_DUMPRESTORE_H_
403b3774fcSperry #define _PROTOCOLS_DUMPRESTORE_H_
41e6b5ddd9Scgd 
42a8c9c98eSdholland #include <stdint.h>
43a8c9c98eSdholland #include <ufs/ufs/dinode.h>
44a8c9c98eSdholland 
45e6b5ddd9Scgd /*
46e6b5ddd9Scgd  * TP_BSIZE is the size of file blocks on the dump tapes.
47e6b5ddd9Scgd  * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
48e6b5ddd9Scgd  *
49e6b5ddd9Scgd  * NTREC is the number of TP_BSIZE blocks that are written
50e6b5ddd9Scgd  * in each tape record. HIGHDENSITYTREC is the number of
51e6b5ddd9Scgd  * TP_BSIZE blocks that are written in each tape record on
52e6b5ddd9Scgd  * 6250 BPI or higher density tapes.
53e6b5ddd9Scgd  *
54e6b5ddd9Scgd  * TP_NINDIR is the number of indirect pointers in a TS_INODE
55e6b5ddd9Scgd  * or TS_ADDR record. Note that it must be a power of two.
56e6b5ddd9Scgd  */
57e6b5ddd9Scgd #define TP_BSIZE	1024
58e6b5ddd9Scgd #define NTREC   	10
59e6b5ddd9Scgd #define HIGHDENSITYTREC	32
60e6b5ddd9Scgd #define TP_NINDIR	(TP_BSIZE/2)
61e6b5ddd9Scgd #define LBLSIZE		16
62e6b5ddd9Scgd #define NAMELEN		64
63e6b5ddd9Scgd 
64e6b5ddd9Scgd #define OFS_MAGIC   	(int)60011
65e6b5ddd9Scgd #define NFS_MAGIC   	(int)60012
6642614ed3Sfvdl #ifndef FS_UFS2_MAGIC
6742614ed3Sfvdl #define FS_UFS2_MAGIC   (int)0x19540119
6842614ed3Sfvdl #endif
69e6b5ddd9Scgd #define CHECKSUM	(int)84446
70e6b5ddd9Scgd 
716ce4f404Sjoerg extern union u_spcl {
72e6b5ddd9Scgd 	char dummy[TP_BSIZE];
73e6b5ddd9Scgd 	struct	s_spcl {
74a0c5caa0Scgd 		int32_t	c_type;		    /* record type (see below) */
7542614ed3Sfvdl 		int32_t	c_old_date;	    /* date of this dump */
7642614ed3Sfvdl 		int32_t	c_old_ddate;	    /* date of previous dump */
77a0c5caa0Scgd 		int32_t	c_volume;	    /* dump volume number */
7842614ed3Sfvdl 		int32_t	c_old_tapea;	    /* logical block of this record */
795f65228bSperry 		uint32_t c_inumber;	    /* number of inode */
80a0c5caa0Scgd 		int32_t	c_magic;	    /* magic number (see above) */
81a0c5caa0Scgd 		int32_t	c_checksum;	    /* record checksum */
8242614ed3Sfvdl 		union {
8342614ed3Sfvdl 			struct ufs1_dinode __uc_dinode;
8442614ed3Sfvdl 			struct {
855f65228bSperry 				uint16_t __uc_mode;
8642614ed3Sfvdl 				int16_t __uc_spare1[3];
875f65228bSperry 				uint64_t __uc_size;
8842614ed3Sfvdl 				int32_t __uc_old_atime;
8942614ed3Sfvdl 				int32_t __uc_atimensec;
9042614ed3Sfvdl 				int32_t __uc_old_mtime;
9142614ed3Sfvdl 				int32_t __uc_mtimensec;
9242614ed3Sfvdl 				int32_t __uc_spare2[2];
9342614ed3Sfvdl 				int32_t __uc_rdev;
9442614ed3Sfvdl 				int32_t __uc_birthtimensec;
9542614ed3Sfvdl 				int64_t __uc_birthtime;
9642614ed3Sfvdl 				int64_t __uc_atime;
9742614ed3Sfvdl 				int64_t __uc_mtime;
98*e2325e1fSchristos 				int32_t __uc_extsize;
99*e2325e1fSchristos 				int32_t __uc_spare4[6];
1005f65228bSperry 				uint32_t __uc_file_flags;
10142614ed3Sfvdl 				int32_t __uc_spare5[2];
1025f65228bSperry 				uint32_t __uc_uid;
1035f65228bSperry 				uint32_t __uc_gid;
10442614ed3Sfvdl 				int32_t __uc_spare6[2];
10542614ed3Sfvdl 			} __uc_ino;
10642614ed3Sfvdl 		} __c_ino;
107a0c5caa0Scgd 		int32_t	c_count;	    /* number of valid c_addr entries */
108e6b5ddd9Scgd 		char	c_addr[TP_NINDIR];  /* 1 => data; 0 => hole in inode */
109e6b5ddd9Scgd 		char	c_label[LBLSIZE];   /* dump label */
110a0c5caa0Scgd 		int32_t	c_level;	    /* level of this dump */
111e6b5ddd9Scgd 		char	c_filesys[NAMELEN]; /* name of dumpped file system */
112e6b5ddd9Scgd 		char	c_dev[NAMELEN];	    /* name of dumpped device */
113e6b5ddd9Scgd 		char	c_host[NAMELEN];    /* name of dumpped host */
114a0c5caa0Scgd 		int32_t	c_flags;	    /* additional information */
11542614ed3Sfvdl 		int32_t	c_old_firstrec;	    /* first record on volume */
11642614ed3Sfvdl 		int64_t c_date;		    /* date of this dump */
11742614ed3Sfvdl 		int64_t c_ddate;	    /* date of previous dump */
11842614ed3Sfvdl 		int64_t c_tapea;	    /* logical block of this record */
11942614ed3Sfvdl 		int64_t c_firstrec;	    /* first record on volume */
12042614ed3Sfvdl 		int32_t	c_spare[24];	    /* reserved for future uses */
121e6b5ddd9Scgd 	} s_spcl;
122e6b5ddd9Scgd } u_spcl;
123e6b5ddd9Scgd #define spcl u_spcl.s_spcl
12442614ed3Sfvdl 
12542614ed3Sfvdl #define c_dinode	__c_ino.__uc_dinode
12642614ed3Sfvdl #define c_mode		__c_ino.__uc_ino.__uc_mode
12742614ed3Sfvdl #define c_spare1	__c_ino.__uc_ino.__uc_spare1
12842614ed3Sfvdl #define c_size		__c_ino.__uc_ino.__uc_size
129*e2325e1fSchristos #define c_extsize	__c_ino.__uc_ino.__uc_extsize
13042614ed3Sfvdl #define c_old_atime	__c_ino.__uc_ino.__uc_old_atime
13142614ed3Sfvdl #define c_atime		__c_ino.__uc_ino.__uc_atime
13242614ed3Sfvdl #define c_atimensec	__c_ino.__uc_ino.__uc_atimensec
13342614ed3Sfvdl #define c_mtime		__c_ino.__uc_ino.__uc_mtime
13442614ed3Sfvdl #define c_mtimensec	__c_ino.__uc_ino.__uc_mtimensec
13542614ed3Sfvdl #define c_birthtime	__c_ino.__uc_ino.__uc_birthtime
13642614ed3Sfvdl #define c_birthtimensec	__c_ino.__uc_ino.__uc_birthtimensec
13742614ed3Sfvdl #define c_old_mtime	__c_ino.__uc_ino.__uc_old_mtime
13842614ed3Sfvdl #define c_rdev		__c_ino.__uc_ino.__uc_rdev
13942614ed3Sfvdl #define c_file_flags	__c_ino.__uc_ino.__uc_file_flags
14042614ed3Sfvdl #define c_uid		__c_ino.__uc_ino.__uc_uid
14142614ed3Sfvdl #define c_gid		__c_ino.__uc_ino.__uc_gid
14242614ed3Sfvdl 
143e6b5ddd9Scgd /*
144e6b5ddd9Scgd  * special record types
145e6b5ddd9Scgd  */
146e6b5ddd9Scgd #define TS_TAPE 	1	/* dump tape header */
147e6b5ddd9Scgd #define TS_INODE	2	/* beginning of file record */
148e6b5ddd9Scgd #define TS_ADDR 	4	/* continuation of file record */
149e6b5ddd9Scgd #define TS_BITS 	3	/* map of inodes on tape */
150e6b5ddd9Scgd #define TS_CLRI 	6	/* map of inodes deleted since last dump */
151e6b5ddd9Scgd #define TS_END  	5	/* end of volume marker */
152e6b5ddd9Scgd 
153e6b5ddd9Scgd /*
154e6b5ddd9Scgd  * flag values
155e6b5ddd9Scgd  */
156e6b5ddd9Scgd #define DR_NEWHEADER	0x0001	/* new format tape header */
157e6b5ddd9Scgd #define DR_NEWINODEFMT	0x0002	/* new format inodes on tape */
1587586bc88Shannken #define DR_EXTATTRIBUTES 0x8000	/* linux: extended attributes */
159e6b5ddd9Scgd 
160fcc3c956Schristos /* 511 == NAME_MAX */
161fcc3c956Schristos #define	DUMPOUTFMT	"%-511s %c %s"		/* for printf */
162e6b5ddd9Scgd 						/* name, level, ctime(date) */
163fcc3c956Schristos #define	DUMPINFMT	"%511s %c %[^\n]\n"	/* inverse for scanf */
164e6b5ddd9Scgd 
1653b3774fcSperry #endif /* !_PROTOCOLS_DUMPRESTORE_H_ */
166