xref: /illumos-gate/usr/src/head/protocols/dumprestore.h (revision e0dfa398a76c38cdf3380b38117ee2d1ed3249f0)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
247c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /* Copyright (c) 1983,1984,1985,1986,1987,1988,1989  AT&T. */
287c478bd9Sstevel@tonic-gate /*	All rights reserved. */
297c478bd9Sstevel@tonic-gate 
307c478bd9Sstevel@tonic-gate /*
317c478bd9Sstevel@tonic-gate  * Portions of this source code were derived from Berkeley 4.3 BSD
327c478bd9Sstevel@tonic-gate  * under license from the Regents of the University of California.
337c478bd9Sstevel@tonic-gate  */
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate #ifndef _PROTOCOLS_DUMPRESTORE_H
367c478bd9Sstevel@tonic-gate #define	_PROTOCOLS_DUMPRESTORE_H
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
397c478bd9Sstevel@tonic-gate extern "C" {
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate /*
437c478bd9Sstevel@tonic-gate  * This header file defines two different versions of the
447c478bd9Sstevel@tonic-gate  * ufsdump/ufsrestore interface.  If the defined constant
457c478bd9Sstevel@tonic-gate  * SUPPORTS_MTB_TAPE_FORMAT is set, the data structures in
467c478bd9Sstevel@tonic-gate  * this header file will support backups of more than 2 terabytes
477c478bd9Sstevel@tonic-gate  * of data.
487c478bd9Sstevel@tonic-gate  *
497c478bd9Sstevel@tonic-gate  * In the old format (the format that only supports dumps
507c478bd9Sstevel@tonic-gate  * of less than 2 terabytes), TP_BSIZE is the size of file blocks
517c478bd9Sstevel@tonic-gate  * on the dump tapes.
527c478bd9Sstevel@tonic-gate  * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
537c478bd9Sstevel@tonic-gate  *
547c478bd9Sstevel@tonic-gate  * In the new format, tp_bsize is used to store the
557c478bd9Sstevel@tonic-gate  * tape block size, which is variable.  The tape block size
567c478bd9Sstevel@tonic-gate  * is like 'fragsize', in that 'c_tapea' in each tape record
577c478bd9Sstevel@tonic-gate  * contains the 'tape block record' number in a signed int.
587c478bd9Sstevel@tonic-gate  * We set TP_BSIZE_MAX to 65536, which will handle 128TB
597c478bd9Sstevel@tonic-gate  * of data.  The new format is indicated by a magic number
607c478bd9Sstevel@tonic-gate  * in the tape header of MTB_MAGIC.  The new format is only
617c478bd9Sstevel@tonic-gate  * used when the size of the backup exceeds 2 TB.  If the
627c478bd9Sstevel@tonic-gate  * backup can be stored in less thatn 2 TB, ufsdump still
637c478bd9Sstevel@tonic-gate  * uses the format indicated by the NFS_MAGIC magic number.
647c478bd9Sstevel@tonic-gate  * Therefore, backups of less than 2 TB are still readable
657c478bd9Sstevel@tonic-gate  * by earlier versions of ufsrestore.
667c478bd9Sstevel@tonic-gate  *
677c478bd9Sstevel@tonic-gate  * NTREC is the number of TP_BSIZE blocks that are written
687c478bd9Sstevel@tonic-gate  * in each tape record. HIGHDENSITYTREC is the number of
697c478bd9Sstevel@tonic-gate  * TP_BSIZE blocks that are written in each tape record on
707c478bd9Sstevel@tonic-gate  * 6250 BPI or higher density tapes.  CARTRIDGETREC is the
717c478bd9Sstevel@tonic-gate  * number of TP_BSIZE (or tp_bsize) blocks that are written
727c478bd9Sstevel@tonic-gate  * in each tape record on cartridge tapes.
737c478bd9Sstevel@tonic-gate  *
747c478bd9Sstevel@tonic-gate  * TP_NINDIR is the number of indirect pointers in a TS_INODE
757c478bd9Sstevel@tonic-gate  * or TS_ADDR record. Note that it must be a power of two.
767c478bd9Sstevel@tonic-gate  *
777c478bd9Sstevel@tonic-gate  */
787c478bd9Sstevel@tonic-gate #define	TP_BSIZE_MAX	65536
797c478bd9Sstevel@tonic-gate #define	TP_BSIZE_MIN	1024
807c478bd9Sstevel@tonic-gate #define	ESIZE_SHIFT_MAX	6	/* shift TP_BSIZE_MIN to TP_BSIZE_MAX */
817c478bd9Sstevel@tonic-gate 
827c478bd9Sstevel@tonic-gate #ifdef SUPPORTS_MTB_TAPE_FORMAT
837c478bd9Sstevel@tonic-gate #define	TP_BUFSIZE	TP_BSIZE_MAX
847c478bd9Sstevel@tonic-gate extern	int32_t		tp_bsize;
857c478bd9Sstevel@tonic-gate #else
867c478bd9Sstevel@tonic-gate #define	TP_BSIZE	1024
877c478bd9Sstevel@tonic-gate #define	TP_BUFSIZE	TP_BSIZE
887c478bd9Sstevel@tonic-gate #endif /* SUPPORTS_MTB_TAPE_FORMAT */
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate #define	NTREC		10
917c478bd9Sstevel@tonic-gate #define	HIGHDENSITYTREC	32
927c478bd9Sstevel@tonic-gate #define	CARTRIDGETREC	63
937c478bd9Sstevel@tonic-gate #define	TP_NINDIR	(TP_BSIZE_MIN/2)
947c478bd9Sstevel@tonic-gate #define	TP_NINOS	(TP_NINDIR / sizeof (long))
957c478bd9Sstevel@tonic-gate #define	LBLSIZE		16
967c478bd9Sstevel@tonic-gate #define	NAMELEN		64
977c478bd9Sstevel@tonic-gate 
987c478bd9Sstevel@tonic-gate #define	OFS_MAGIC	(int)60011
997c478bd9Sstevel@tonic-gate #define	NFS_MAGIC	(int)60012
1007c478bd9Sstevel@tonic-gate #define	MTB_MAGIC	(int)60013
1017c478bd9Sstevel@tonic-gate #define	CHECKSUM	(int)84446
1027c478bd9Sstevel@tonic-gate 
1037c478bd9Sstevel@tonic-gate union u_data {
1047c478bd9Sstevel@tonic-gate 	char	s_addrs[TP_NINDIR];	/* 1 => data; 0 => hole in inode */
1057c478bd9Sstevel@tonic-gate 	int32_t	s_inos[TP_NINOS];	/* starting inodes on tape */
1067c478bd9Sstevel@tonic-gate };
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate union u_shadow {
1097c478bd9Sstevel@tonic-gate 	struct s_nonsh {
1107c478bd9Sstevel@tonic-gate 		int32_t	c_level;		/* level of this dump */
1117c478bd9Sstevel@tonic-gate 		char	c_filesys[NAMELEN];	/* dumpped file system name */
1127c478bd9Sstevel@tonic-gate 		char	c_dev[NAMELEN];		/* name of dumpped device */
1137c478bd9Sstevel@tonic-gate 		char	c_host[NAMELEN];	/* name of dumpped host */
1147c478bd9Sstevel@tonic-gate 	} c_nonsh;
1157c478bd9Sstevel@tonic-gate 	char    c_shadow[1];
1167c478bd9Sstevel@tonic-gate };
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate /* if you change anything here, be sure to change normspcl in byteorder.c */
1197c478bd9Sstevel@tonic-gate 
120*e0dfa398SToomas Soome extern union u_spcl {
1217c478bd9Sstevel@tonic-gate 	char dummy[TP_BUFSIZE];
1227c478bd9Sstevel@tonic-gate 	struct	s_spcl {
1237c478bd9Sstevel@tonic-gate 		int32_t	c_type;		    /* record type (see below) */
1247c478bd9Sstevel@tonic-gate 		time32_t c_date;	    /* date of previous dump */
1257c478bd9Sstevel@tonic-gate 		time32_t c_ddate;	    /* date of this dump */
1267c478bd9Sstevel@tonic-gate 		int32_t	c_volume;	    /* dump volume number */
1277c478bd9Sstevel@tonic-gate 		daddr32_t c_tapea;	    /* logical block of this record */
1287c478bd9Sstevel@tonic-gate 		ino32_t	c_inumber;	    /* number of inode */
1297c478bd9Sstevel@tonic-gate 		int32_t	c_magic;	    /* magic number (see above) */
1307c478bd9Sstevel@tonic-gate 		int32_t	c_checksum;	    /* record checksum */
1317c478bd9Sstevel@tonic-gate 		struct	dinode	c_dinode;   /* ownership and mode of inode */
1327c478bd9Sstevel@tonic-gate 		int32_t	c_count;	    /* number of valid c_addr entries */
1337c478bd9Sstevel@tonic-gate 		union	u_data c_data;	    /* see union above */
1347c478bd9Sstevel@tonic-gate 		char	c_label[LBLSIZE];   /* dump label */
1357c478bd9Sstevel@tonic-gate 		union	u_shadow c_shadow;  /* see union above */
1367c478bd9Sstevel@tonic-gate 		int32_t	c_flags;	    /* additional information */
1377c478bd9Sstevel@tonic-gate 		int32_t	c_firstrec;	    /* first record on volume */
1387c478bd9Sstevel@tonic-gate #ifdef SUPPORTS_MTB_TAPE_FORMAT
1397c478bd9Sstevel@tonic-gate 		int32_t	c_tpbsize;	    /* tape block size */
1407c478bd9Sstevel@tonic-gate 		int32_t	c_spare[31];	    /* reserved for future uses */
1417c478bd9Sstevel@tonic-gate #else
1427c478bd9Sstevel@tonic-gate 		int32_t c_spare[32];
1437c478bd9Sstevel@tonic-gate #endif /* SUPPORTS_MTB_TAPE_FORMAT */
1447c478bd9Sstevel@tonic-gate 	} s_spcl;
1457c478bd9Sstevel@tonic-gate } u_spcl;
1467c478bd9Sstevel@tonic-gate #define	spcl u_spcl.s_spcl
1477c478bd9Sstevel@tonic-gate #define	c_addr c_data.s_addrs
1487c478bd9Sstevel@tonic-gate #define	c_inos c_data.s_inos
1497c478bd9Sstevel@tonic-gate #define	c_level c_shadow.c_nonsh.c_level
1507c478bd9Sstevel@tonic-gate #define	c_filesys c_shadow.c_nonsh.c_filesys
1517c478bd9Sstevel@tonic-gate #define	c_dev c_shadow.c_nonsh.c_dev
1527c478bd9Sstevel@tonic-gate #define	c_host c_shadow.c_nonsh.c_host
1537c478bd9Sstevel@tonic-gate 
1547c478bd9Sstevel@tonic-gate /*
1557c478bd9Sstevel@tonic-gate  * special record types
1567c478bd9Sstevel@tonic-gate  */
1577c478bd9Sstevel@tonic-gate #define	TS_TAPE		1	/* dump tape header */
1587c478bd9Sstevel@tonic-gate #define	TS_INODE	2	/* beginning of file record */
1597c478bd9Sstevel@tonic-gate #define	TS_ADDR		4	/* continuation of file record */
1607c478bd9Sstevel@tonic-gate #define	TS_BITS		3	/* map of inodes on tape */
1617c478bd9Sstevel@tonic-gate #define	TS_CLRI		6	/* map of inodes deleted since last dump */
1627c478bd9Sstevel@tonic-gate #define	TS_END		5	/* end of volume marker */
1637c478bd9Sstevel@tonic-gate #define	TS_EOM		7	/* floppy EOM - restore compat w/ old dump */
1647c478bd9Sstevel@tonic-gate 
1657c478bd9Sstevel@tonic-gate /*
1667c478bd9Sstevel@tonic-gate  * flag values
1677c478bd9Sstevel@tonic-gate  */
1687c478bd9Sstevel@tonic-gate #define	DR_NEWHEADER	1	/* new format tape header */
1697c478bd9Sstevel@tonic-gate #define	DR_INODEINFO	2	/* header contains starting inode info */
1707c478bd9Sstevel@tonic-gate #define	DR_REDUMP	4	/* dump contains recopies of active files */
1717c478bd9Sstevel@tonic-gate #define	DR_TRUEINC	8	/* dump is a "true incremental"	*/
1727c478bd9Sstevel@tonic-gate #define	DR_HASMETA	16	/* metadata in this header */
1737c478bd9Sstevel@tonic-gate 
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 
1767c478bd9Sstevel@tonic-gate #define	DUMPOUTFMT	"%-32s %c %s"		/* for printf */
1777c478bd9Sstevel@tonic-gate 						/* name, incno, ctime(date) */
1787c478bd9Sstevel@tonic-gate #define	DUMPINFMT	"%258s %c %128[^\n]\n"	/* inverse for scanf */
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate #ifdef __cplusplus
1817c478bd9Sstevel@tonic-gate }
1827c478bd9Sstevel@tonic-gate #endif
1837c478bd9Sstevel@tonic-gate 
1847c478bd9Sstevel@tonic-gate #endif	/* !_PROTOCOLS_DUMPRESTORE_H */
185