]> git.wh0rd.org - dump.git/blob - compat/include/protocols/dumprestore.h
Made restore understand FreeBSD UFS2 dumps.
[dump.git] / compat / include / protocols / dumprestore.h
1 /*
2 * Ported to Linux's Second Extended File System as part of the
3 * dump and restore backup suit
4 * Remy Card <card@Linux.EU.Org>, 1994-1997
5 * Stelian Pop <stelian@popies.net>, 1999-2000
6 * Stelian Pop <stelian@popies.net> - AlcĂ´ve <www.alcove.com>, 2000-2002
7 *
8 * $Id: dumprestore.h,v 1.21 2004/04/13 13:03:55 stelian Exp $
9 */
10
11 /*
12 * Copyright (c) 1980, 1993
13 * The Regents of the University of California. All rights reserved.
14 * (c) UNIX System Laboratories, Inc.
15 * All or some portions of this file are derived from material licensed
16 * to the University of California by American Telephone and Telegraph
17 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
18 * the permission of UNIX System Laboratories, Inc.
19 *
20 * Redistribution and use in source and binary forms, with or without
21 * modification, are permitted provided that the following conditions
22 * are met:
23 * 1. Redistributions of source code must retain the above copyright
24 * notice, this list of conditions and the following disclaimer.
25 * 2. Redistributions in binary form must reproduce the above copyright
26 * notice, this list of conditions and the following disclaimer in the
27 * documentation and/or other materials provided with the distribution.
28 * 3. Neither the name of the University nor the names of its contributors
29 * may be used to endorse or promote products derived from this software
30 * without specific prior written permission.
31 *
32 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
33 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
35 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
36 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
40 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
41 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
42 * SUCH DAMAGE.
43 */
44
45 #ifndef _PROTOCOLS_DUMPRESTORE_H_
46 #define _PROTOCOLS_DUMPRESTORE_H_
47
48 #include <config.h>
49
50 /*
51 * TP_BSIZE is the size of file blocks on the dump tapes.
52 * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
53 *
54 * NTREC is the number of TP_BSIZE blocks that are written
55 * in each tape record. HIGHDENSITYTREC is the number of
56 * TP_BSIZE blocks that are written in each tape record on
57 * 6250 BPI or higher density tapes.
58 *
59 * TP_NINDIR is the number of indirect pointers in a TS_INODE
60 * or TS_ADDR record. Note that it must be a power of two.
61 */
62 #define TP_BSIZE 1024
63 #define NTREC 10
64 #define HIGHDENSITYTREC 32
65 #define TP_NINDIR (TP_BSIZE/2)
66 #define TP_NINOS (TP_NINDIR / sizeof (int32_t))
67 #define LBLSIZE 16
68 #define NAMELEN 64
69
70 #define OFS_MAGIC (int)60011
71 #define NFS_MAGIC (int)60012
72 #define FS_UFS2_MAGIC (int)0x19540119
73 #define CHECKSUM (int)84446
74
75 #ifdef __linux__
76 typedef u_int32_t dump_ino_t;
77 #endif
78
79 #ifdef sunos
80 typedef unsigned int dump_ino_t;
81 #endif
82
83 union u_data {
84 char s_addrs[TP_NINDIR]; /* 1 => data; 0 => hole in inode */
85 int32_t s_inos[TP_NINOS]; /* table of first inode on each volume */
86 } u_data;
87
88 union u_spcl {
89 char dummy[TP_BSIZE];
90 struct s_spcl {
91 int32_t c_type; /* record type (see below) */
92 int32_t c_date; /* date of this dump */
93 int32_t c_ddate; /* date of previous dump */
94 int32_t c_volume; /* dump volume number */
95 daddr_t c_tapea; /* logical block of this record */
96 dump_ino_t c_inumber; /* number of inode */
97 int32_t c_magic; /* magic number (see above) */
98 int32_t c_checksum; /* record checksum */
99 #ifdef __linux__
100 struct new_bsd_inode c_dinode;
101 #else
102 #ifdef sunos
103 struct new_bsd_inode c_dinode;
104 #else
105 struct dinode c_dinode; /* ownership and mode of inode */
106 #endif
107 #endif
108 int32_t c_count; /* number of valid c_addr entries */
109 union u_data c_data; /* see above */
110 char c_label[LBLSIZE]; /* dump label */
111 int32_t c_level; /* level of this dump */
112 char c_filesys[NAMELEN]; /* name of dumpped file system */
113 char c_dev[NAMELEN]; /* name of dumpped device */
114 char c_host[NAMELEN]; /* name of dumpped host */
115 int32_t c_flags; /* additional information */
116 int32_t c_firstrec; /* first record on volume */
117 int32_t c_ntrec; /* blocksize on volume */
118 int32_t c_extattributes; /* additional inode info */
119 int32_t c_spare[30]; /* reserved for future uses */
120 } s_spcl;
121 } u_spcl;
122 #define spcl u_spcl.s_spcl
123 #define c_addr c_data.s_addrs
124 #define c_inos c_data.s_inos
125
126 /*
127 * special record types
128 */
129 #define TS_TAPE 1 /* dump tape header */
130 #define TS_INODE 2 /* beginning of file record */
131 #define TS_ADDR 4 /* continuation of file record */
132 #define TS_BITS 3 /* map of inodes on tape */
133 #define TS_CLRI 6 /* map of inodes deleted since last dump */
134 #define TS_END 5 /* end of volume marker */
135
136 /*
137 * flag values
138 */
139 #define DR_NEWHEADER 0x0001 /* new format tape header */
140 #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */
141 #define DR_COMPRESSED 0x0080 /* dump tape is compressed */
142 #define DR_METAONLY 0x0100 /* only the metadata of the inode has
143 been dumped */
144 #define DR_INODEINFO 0x0002 /* TS_END header contains c_inos information */
145 #define DR_EXTATTRIBUTES 0x8000
146
147 /*
148 * extattributes inode info
149 */
150 #define EXT_REGULAR 0
151 #define EXT_MACOSFNDRINFO 1
152 #define EXT_MACOSRESFORK 2
153 #define EXT_ACL 3
154
155
156 /*
157 * compression flags for the tapebuf header.
158 */
159 #define COMPRESS_ZLIB 0
160 #define COMPRESS_BZLIB 1
161 #define COMPRESS_LZO 2
162
163 /* used for compressed dump tapes */
164 struct tapebuf {
165 unsigned int compressed:1;
166 unsigned int flags:3;
167 unsigned int length:28;
168 #ifdef sunos
169 char buf;
170 #else
171 char buf[0]; /* the data */
172 #endif
173 };
174
175 #endif /* !_DUMPRESTORE_H_ */