2 * Block definitions for Bacula media data format.
8 Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
10 This program is free software; you can redistribute it and/or
11 modify it under the terms of the GNU General Public License as
12 published by the Free Software Foundation; either version 2 of
13 the License, or (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 General Public License for more details.
20 You should have received a copy of the GNU General Public
21 License along with this program; if not, write to the Free
22 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
31 #define MAX_BLOCK_LENGTH 500001 /* 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 BLKHDR_ID "BB01"
36 #define BLKHDR_ID_LENGTH 4
37 #define BLKHDR_CS_LENGTH 4 /* checksum length */
38 #define BLKHDR_LENGTH 16 /* Total length */
41 * This is the Media structure for a block header
42 * Note, when written, it is serialized.
44 typedef struct s_block_hdr {
48 char Id[BLKHDR_ID_LENGTH+1];
52 * DEV_BLOCK for reading and writing blocks.
53 * This is the basic unit that is written to the device, and
54 * it contains a Block Header followd by Records. Note,
55 * at times (when reading a file), this block may contain
58 * This is the memory structure for a device block.
60 typedef struct s_dev_block {
61 struct s_dev_block *next; /* pointer to next one */
62 /* binbuf is the number of bytes remaining
63 * in the buffer. For writes, it is bytes not yet written.
64 * For reads, it is remaining bytes not yet read.
66 uint32_t binbuf; /* bytes in buffer */
67 uint32_t block_len; /* length of current block read */
68 uint32_t buf_len; /* max/default block length */
69 uint32_t BlockNumber; /* sequential block number */
70 uint32_t read_len; /* bytes read into buffer */
71 int failed_write; /* set if write failed */
72 char *bufp; /* pointer into buffer */
73 char *buf; /* actual data buffer. This is a