2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2007 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from
7 many others, a complete list can be found in the file AUTHORS.
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version two of the GNU General Public
10 License as published by the Free Software Foundation and included
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 Bacula® is a registered trademark of Kern Sibbald.
24 The licensor of Bacula is the Free Software Foundation Europe
25 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26 Switzerland, email:ftf@fsfeurope.org.
29 * Block definitions for Bacula media data format.
41 #define MAX_BLOCK_LENGTH 2000000 /* this is a sort of sanity check */
42 #define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
44 /* Block Header definitions. */
45 #define BLKHDR1_ID "BB01"
46 #define BLKHDR2_ID "BB02"
47 #define BLKHDR_ID_LENGTH 4
48 #define BLKHDR_CS_LENGTH 4 /* checksum length */
49 #define BLKHDR1_LENGTH 16 /* Total length */
50 #define BLKHDR2_LENGTH 24 /* Total length */
52 #define WRITE_BLKHDR_ID BLKHDR2_ID
53 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
56 /* Record header definitions */
57 #define RECHDR1_LENGTH 20
58 #define RECHDR2_LENGTH 12
59 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
61 /* Tape label and version definitions */
62 #define BaculaId "Bacula 1.0 immortal\n"
63 #define OldBaculaId "Bacula 0.9 mortal\n"
64 #define BaculaTapeVersion 11
65 #define OldCompatibleBaculaTapeVersion1 10
66 #define OldCompatibleBaculaTapeVersion2 9
70 * This is the Media structure for a block header
71 * Note, when written, it is serialized.
76 char Id[BLKHDR_ID_LENGTH];
78 * for BB02 block, we also have
80 uint32_t VolSessionId;
81 uint32_t VolSessionTime;
84 class DEVICE; /* for forward reference */
87 * DEV_BLOCK for reading and writing blocks.
88 * This is the basic unit that is written to the device, and
89 * it contains a Block Header followd by Records. Note,
90 * at times (when reading a file), this block may contain
93 * This is the memory structure for a device block.
96 DEV_BLOCK *next; /* pointer to next one */
97 DEVICE *dev; /* pointer to device */
98 /* binbuf is the number of bytes remaining in the buffer.
99 * For writes, it is bytes not yet written.
100 * For reads, it is remaining bytes not yet read.
102 uint32_t binbuf; /* bytes in buffer */
103 uint32_t block_len; /* length of current block read */
104 uint32_t buf_len; /* max/default block length */
105 uint32_t BlockNumber; /* sequential Bacula block number */
106 uint32_t read_len; /* bytes read into buffer, if zero, block empty */
107 uint32_t VolSessionId; /* */
108 uint32_t VolSessionTime; /* */
109 uint32_t read_errors; /* block errors (checksum, header, ...) */
110 int BlockVer; /* block version 1 or 2 */
111 bool write_failed; /* set if write failed */
112 bool block_read; /* set when block read */
113 int32_t FirstIndex; /* first index this block */
114 int32_t LastIndex; /* last index this block */
115 char *bufp; /* pointer into buffer */
116 POOLMEM *buf; /* actual data buffer */
119 #define block_is_empty(block) ((block)->read_len == 0)