2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2015 Kern Sibbald
5 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
7 The original author of Bacula is Kern Sibbald, with contributions
8 from many others, a complete list can be found in the file AUTHORS.
10 You may use this file and others of this release according to the
11 license defined in the LICENSE file, which includes the Affero General
12 Public License, v3.0 ("AGPLv3") and some additional permissions and
13 terms pursuant to its AGPLv3 Section 7.
15 This notice must be preserved when any source code is
16 conveyed and/or propagated.
18 Bacula(R) is a registered trademark of Kern Sibbald.
21 * Block definitions for Bacula media data format.
31 #define MAX_BLOCK_LENGTH 20000000 /* this is a sort of sanity check */
32 #define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
34 /* Block Header definitions. */
35 #define BLKHDR1_ID "BB01"
36 #define BLKHDR2_ID "BB02"
37 #define BLKHDR_ID_LENGTH 4
38 #define BLKHDR_CS_LENGTH 4 /* checksum length */
39 #define BLKHDR1_LENGTH 16 /* Total length */
40 #define BLKHDR2_LENGTH 24 /* Total length */
42 #define WRITE_BLKHDR_ID BLKHDR2_ID
43 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
46 /* Record header definitions */
47 #define RECHDR1_LENGTH 20
49 * Record header consists of:
52 * uint32_t data_length
54 #define RECHDR2_LENGTH (3*sizeof(int32_t))
55 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
57 /* Tape label and version definitions */
58 #define BaculaId "Bacula 1.0 immortal\n"
59 #define OldBaculaId "Bacula 0.9 mortal\n"
60 #define BaculaTapeVersion 11
61 #define OldCompatibleBaculaTapeVersion1 10
62 #define OldCompatibleBaculaTapeVersion2 9
65 * This is the Media structure for a block header
66 * Note, when written, it is serialized.
72 char Id[BLKHDR_ID_LENGTH];
74 * for BB02 block, we have
80 char Id[BLKHDR_ID_LENGTH];
81 uint32_t VolSessionId;
82 uint32_t VolSessionTime;
86 class DEVICE; /* for forward reference */
89 * DEV_BLOCK for reading and writing blocks.
90 * This is the basic unit that is written to the device, and
91 * it contains a Block Header followd by Records. Note,
92 * at times (when reading a file), this block may contain
95 * This is the memory structure for a device block.
98 DEV_BLOCK *next; /* pointer to next one */
99 DEVICE *dev; /* pointer to device */
100 /* binbuf is the number of bytes remaining in the buffer.
101 * For writes, it is bytes not yet written.
102 * For reads, it is remaining bytes not yet read.
104 uint64_t BlockAddr; /* Block address */
105 uint32_t File; /* Block address on volume */
106 uint32_t Block; /* Block address on volume */
107 uint32_t binbuf; /* bytes in buffer */
108 uint32_t block_len; /* length of current block read */
109 uint32_t buf_len; /* max/default block length */
110 uint32_t reclen; /* Last record length put in block */
111 uint32_t BlockNumber; /* sequential Bacula block number */
112 uint32_t read_len; /* bytes read into buffer, if zero, block empty */
113 uint32_t VolSessionId; /* */
114 uint32_t VolSessionTime; /* */
115 uint32_t read_errors; /* block errors (checksum, header, ...) */
116 uint32_t CheckSum; /* Block checksum */
117 uint32_t RecNum; /* Number of records read from the current block */
118 int BlockVer; /* block version 1 or 2 */
119 bool write_failed; /* set if write failed */
120 bool block_read; /* set when block read */
121 bool needs_write; /* block must be written */
122 bool adata; /* adata block */
123 bool no_header; /* Set if no block header */
124 bool new_fi; /* New FI arrived */
125 int32_t FirstIndex; /* first index this block */
126 int32_t LastIndex; /* last index this block */
127 int32_t rechdr_items; /* number of items in rechdr queue */
128 char *bufp; /* pointer into buffer */
129 char ser_buf[BLKHDR2_LENGTH]; /* Serial buffer for data */
130 POOLMEM *rechdr_queue; /* record header queue */
131 POOLMEM *buf; /* actual data buffer */
134 #define block_is_empty(block) ((block)->read_len == 0)