2 * Block definitions for Bacula media data format.
10 Copyright (C) 2000-2006 Kern Sibbald
12 This program is free software; you can redistribute it and/or
13 modify it under the terms of the GNU General Public License
14 version 2 as amended with additional clauses defined in the
15 file LICENSE in the main source directory.
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
20 the file LICENSE for additional details.
28 #define MAX_BLOCK_LENGTH (1024*1024 + 1) /* this is a sort of sanity check */
29 #define DEFAULT_BLOCK_SIZE (512 * 126) /* 64,512 N.B. do not use 65,636 here */
31 /* Block Header definitions. */
32 #define BLKHDR1_ID "BB01"
33 #define BLKHDR2_ID "BB02"
34 #define BLKHDR_ID_LENGTH 4
35 #define BLKHDR_CS_LENGTH 4 /* checksum length */
36 #define BLKHDR1_LENGTH 16 /* Total length */
37 #define BLKHDR2_LENGTH 24 /* Total length */
39 #define WRITE_BLKHDR_ID BLKHDR2_ID
40 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
43 /* Record header definitions */
44 #define RECHDR1_LENGTH 20
45 #define RECHDR2_LENGTH 12
46 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
48 /* Tape label and version definitions */
49 #define BaculaId "Bacula 1.0 immortal\n"
50 #define OldBaculaId "Bacula 0.9 mortal\n"
51 #define BaculaTapeVersion 11
52 #define OldCompatibleBaculaTapeVersion1 10
53 #define OldCompatibleBaculaTapeVersion2 9
57 * This is the Media structure for a block header
58 * Note, when written, it is serialized.
63 char Id[BLKHDR_ID_LENGTH];
65 * for BB02 block, we also have
67 uint32_t VolSessionId;
68 uint32_t VolSessionTime;
71 class DEVICE; /* for forward reference */
74 * DEV_BLOCK for reading and writing blocks.
75 * This is the basic unit that is written to the device, and
76 * it contains a Block Header followd by Records. Note,
77 * at times (when reading a file), this block may contain
80 * This is the memory structure for a device block.
83 DEV_BLOCK *next; /* pointer to next one */
84 DEVICE *dev; /* pointer to device */
85 /* binbuf is the number of bytes remaining in the buffer.
86 * For writes, it is bytes not yet written.
87 * For reads, it is remaining bytes not yet read.
89 uint32_t binbuf; /* bytes in buffer */
90 uint32_t block_len; /* length of current block read */
91 uint32_t buf_len; /* max/default block length */
92 uint32_t BlockNumber; /* sequential Bacula block number */
93 uint32_t read_len; /* bytes read into buffer, if zero, block empty */
94 uint32_t VolSessionId; /* */
95 uint32_t VolSessionTime; /* */
96 uint32_t read_errors; /* block errors (checksum, header, ...) */
97 int BlockVer; /* block version 1 or 2 */
98 bool write_failed; /* set if write failed */
99 bool block_read; /* set when block read */
100 int32_t FirstIndex; /* first index this block */
101 int32_t LastIndex; /* last index this block */
102 char *bufp; /* pointer into buffer */
103 POOLMEM *buf; /* actual data buffer */
106 #define block_is_empty(block) ((block)->read_len == 0)