2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
17 * Block definitions for Bacula media data format.
19 * Written by Kern Sibbald, MM
27 #define MAX_BLOCK_LENGTH 20000000 /* this is a sort of sanity check */
28 #define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
30 /* Block Header definitions. */
31 #define BLKHDR1_ID "BB01"
32 #define BLKHDR2_ID "BB02"
33 #define BLKHDR_ID_LENGTH 4
34 #define BLKHDR_CS_LENGTH 4 /* checksum length */
35 #define BLKHDR1_LENGTH 16 /* Total length */
36 #define BLKHDR2_LENGTH 24 /* Total length */
38 #define WRITE_BLKHDR_ID BLKHDR2_ID
39 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
42 /* Record header definitions */
43 #define RECHDR1_LENGTH 20
45 * Record header consists of:
48 * uint32_t data_length
50 #define RECHDR2_LENGTH (3*sizeof(int32_t))
51 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
53 /* Tape label and version definitions */
54 #define BaculaId "Bacula 1.0 immortal\n"
55 #define OldBaculaId "Bacula 0.9 mortal\n"
56 #define BaculaTapeVersion 11
57 #define OldCompatibleBaculaTapeVersion1 10
58 #define OldCompatibleBaculaTapeVersion2 9
61 * This is the Media structure for a block header
62 * Note, when written, it is serialized.
68 char Id[BLKHDR_ID_LENGTH];
70 * for BB02 block, we have
76 char Id[BLKHDR_ID_LENGTH];
77 uint32_t VolSessionId;
78 uint32_t VolSessionTime;
82 class DEVICE; /* for forward reference */
85 * DEV_BLOCK for reading and writing blocks.
86 * This is the basic unit that is written to the device, and
87 * it contains a Block Header followd by Records. Note,
88 * at times (when reading a file), this block may contain
91 * This is the memory structure for a device block.
94 DEV_BLOCK *next; /* pointer to next one */
95 DEVICE *dev; /* pointer to device */
96 /* binbuf is the number of bytes remaining in the buffer.
97 * For writes, it is bytes not yet written.
98 * For reads, it is remaining bytes not yet read.
100 uint64_t BlockAddr; /* Block address */
101 uint32_t binbuf; /* bytes in buffer */
102 uint32_t block_len; /* length of current block read */
103 uint32_t buf_len; /* max/default block length */
104 uint32_t reclen; /* Last record length put in block */
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 uint32_t CheckSum; /* Block checksum */
111 int BlockVer; /* block version 1 or 2 */
112 bool write_failed; /* set if write failed */
113 bool block_read; /* set when block read */
114 bool needs_write; /* block must be written */
115 bool no_header; /* Set if no block header */
116 bool new_fi; /* New FI arrived */
117 int32_t FirstIndex; /* first index this block */
118 int32_t LastIndex; /* last index this block */
119 int32_t rechdr_items; /* number of items in rechdr queue */
120 char *bufp; /* pointer into buffer */
121 char ser_buf[BLKHDR2_LENGTH]; /* Serial buffer for data */
122 POOLMEM *rechdr_queue; /* record header queue */
123 POOLMEM *buf; /* actual data buffer */
126 #define block_is_empty(block) ((block)->read_len == 0)