2 * Block definitions for Bacula media data format.
10 Copyright (C) 2000, 2001, 2002 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 BLKHDR_ID "BB01"
38 #define BLKHDR_ID_LENGTH 4
39 #define BLKHDR_CS_LENGTH 4 /* checksum length */
40 #define BLKHDR_LENGTH 16 /* Total length */
43 * This is the Media structure for a block header
44 * Note, when written, it is serialized.
46 typedef struct s_block_hdr {
50 char Id[BLKHDR_ID_LENGTH+1];
54 * DEV_BLOCK for reading and writing blocks.
55 * This is the basic unit that is written to the device, and
56 * it contains a Block Header followd by Records. Note,
57 * at times (when reading a file), this block may contain
60 * This is the memory structure for a device block.
62 typedef struct s_dev_block {
63 struct s_dev_block *next; /* pointer to next one */
64 /* binbuf is the number of bytes remaining
65 * in the buffer. For writes, it is bytes not yet written.
66 * For reads, it is remaining bytes not yet read.
68 uint32_t binbuf; /* bytes in buffer */
69 uint32_t block_len; /* length of current block read */
70 uint32_t buf_len; /* max/default block length */
71 uint32_t BlockNumber; /* sequential block number */
72 uint32_t read_len; /* bytes read into buffer */
73 int failed_write; /* set if write failed */
74 char *bufp; /* pointer into buffer */
75 char *buf; /* actual data buffer. This is a