]> git.wh0rd.org - dump.git/blob - compat/include/protocols/dumprestore.h
Added LZO compression.
[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.19 2003/03/31 09:42:57 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 CHECKSUM (int)84446
73
74 typedef u_int32_t dump_ino_t;
75
76 union u_data {
77 char s_addrs[TP_NINDIR]; /* 1 => data; 0 => hole in inode */
78 int32_t s_inos[TP_NINOS]; /* table of first inode on each volume */
79 } u_data;
80
81 union u_spcl {
82 char dummy[TP_BSIZE];
83 struct s_spcl {
84 int32_t c_type; /* record type (see below) */
85 int32_t c_date; /* date of this dump */
86 int32_t c_ddate; /* date of previous dump */
87 int32_t c_volume; /* dump volume number */
88 daddr_t c_tapea; /* logical block of this record */
89 dump_ino_t c_inumber; /* number of inode */
90 int32_t c_magic; /* magic number (see above) */
91 int32_t c_checksum; /* record checksum */
92 #ifdef __linux__
93 struct new_bsd_inode c_dinode;
94 #else
95 struct dinode c_dinode; /* ownership and mode of inode */
96 #endif
97 int32_t c_count; /* number of valid c_addr entries */
98 union u_data c_data; /* see above */
99 char c_label[LBLSIZE]; /* dump label */
100 int32_t c_level; /* level of this dump */
101 char c_filesys[NAMELEN]; /* name of dumpped file system */
102 char c_dev[NAMELEN]; /* name of dumpped device */
103 char c_host[NAMELEN]; /* name of dumpped host */
104 int32_t c_flags; /* additional information */
105 int32_t c_firstrec; /* first record on volume */
106 int32_t c_ntrec; /* blocksize on volume */
107 int32_t c_spare[31]; /* reserved for future uses */
108 } s_spcl;
109 } u_spcl;
110 #define spcl u_spcl.s_spcl
111 #define c_addr c_data.s_addrs
112 #define c_inos c_data.s_inos
113
114 /*
115 * special record types
116 */
117 #define TS_TAPE 1 /* dump tape header */
118 #define TS_INODE 2 /* beginning of file record */
119 #define TS_ADDR 4 /* continuation of file record */
120 #define TS_BITS 3 /* map of inodes on tape */
121 #define TS_CLRI 6 /* map of inodes deleted since last dump */
122 #define TS_END 5 /* end of volume marker */
123
124 /*
125 * flag values
126 */
127 #define DR_NEWHEADER 0x0001 /* new format tape header */
128 #define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */
129 #define DR_COMPRESSED 0x0080 /* dump tape is compressed */
130 #define DR_METAONLY 0x0100 /* only the metadata of the inode has
131 been dumped */
132 #define DR_INODEINFO 0x0002 /* TS_END header contains c_inos information */
133
134
135 /*
136 * compression flags for the tapebuf header.
137 */
138 #define COMPRESS_ZLIB 0
139 #define COMPRESS_BZLIB 1
140 #define COMPRESS_LZO 2
141
142 /* used for compressed dump tapes */
143 struct tapebuf {
144 unsigned int compressed:1;
145 unsigned int flags:3;
146 unsigned int length:28;
147 char buf[0]; /* the data */
148 };
149
150 #endif /* !_DUMPRESTORE_H_ */