2 * Block definitions for Bacula media data format.
10 Copyright (C) 2000-2003 Kern Sibbald and John Walker
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License as
14 published by the Free Software Foundation; either version 2 of
15 the License, or (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 General Public License for more details.
22 You should have received a copy of the GNU General Public
23 License along with this program; if not, write to the Free
24 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
33 #define MAX_BLOCK_LENGTH 500001 /* this is a sort of sanity check */
34 #define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
36 /* Block Header definitions. */
37 #define BLKHDR1_ID "BB01"
38 #define BLKHDR2_ID "BB02"
39 #define BLKHDR_ID_LENGTH 4
40 #define BLKHDR_CS_LENGTH 4 /* checksum length */
41 #define BLKHDR1_LENGTH 16 /* Total length */
42 #define BLKHDR2_LENGTH 24 /* Total length */
44 #define WRITE_BLKHDR_ID BLKHDR2_ID
45 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
48 /* Record header definitions */
49 #define RECHDR1_LENGTH 20
50 #define RECHDR2_LENGTH 12
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
62 * This is the Media structure for a block header
63 * Note, when written, it is serialized.
68 char Id[BLKHDR_ID_LENGTH];
70 * for BB02 block, we also have
72 uint32_t VolSessionId;
73 uint32_t VolSessionTime;
77 * DEV_BLOCK for reading and writing blocks.
78 * This is the basic unit that is written to the device, and
79 * it contains a Block Header followd by Records. Note,
80 * at times (when reading a file), this block may contain
83 * This is the memory structure for a device block.
86 DEV_BLOCK *next; /* pointer to next one */
87 void *dev; /* pointer to device (DEVICE not defined yet) */
88 /* binbuf is the number of bytes remaining in the buffer.
89 * For writes, it is bytes not yet written.
90 * For reads, it is remaining bytes not yet read.
92 uint32_t binbuf; /* bytes in buffer */
93 uint32_t block_len; /* length of current block read */
94 uint32_t buf_len; /* max/default block length */
95 uint32_t BlockNumber; /* sequential Bacula block number */
96 uint32_t read_len; /* bytes read into buffer, if zero, block empty */
97 uint32_t VolSessionId; /* */
98 uint32_t VolSessionTime; /* */
99 uint32_t read_errors; /* block errors (checksum, header, ...) */
100 int BlockVer; /* block version 1 or 2 */
101 bool write_failed; /* set if write failed */
102 bool block_read; /* set when block read */
103 int32_t FirstIndex; /* first index this block */
104 int32_t LastIndex; /* last index this block */
105 char *bufp; /* pointer into buffer */
106 POOLMEM *buf; /* actual data buffer */
109 #define block_is_empty(block) ((block)->read_len == 0)