]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/block.h
b376f3b492549f8bbdcabaa4a8f1f34bc78d5d7e
[bacula/bacula] / bacula / src / stored / block.h
1 /*
2  * Block definitions for Bacula media data format.
3  *
4  *    Kern Sibbald
5  *
6  */
7 /*
8    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
9
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.
14
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.
19
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,
23    MA 02111-1307, USA.
24
25  */
26
27
28 #ifndef __BLOCK_H
29 #define __BLOCK_H 1
30
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 */
33
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 */
39
40 /*
41  * This is the Media structure for a block header
42  *  Note, when written, it is serialized.
43  */
44 typedef struct s_block_hdr {
45    uint32_t CheckSum;
46    uint32_t block_size;
47    uint32_t BlockNumber;
48    char     Id[BLKHDR_ID_LENGTH+1];
49 } BLOCK_HDR;
50
51 /*
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
56  * multiple blocks.
57  *
58  *  This is the memory structure for a device block.
59  */
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.
65     */
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 
74                                        * Pool buffer!   
75                                        */
76 } DEV_BLOCK;
77
78 #endif