]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/block.h
First cut AutoPrune
[bacula/bacula] / bacula / src / stored / block.h
1 /*
2  * Block definitions for Bacula media data format.
3  *
4  *    Kern Sibbald
5  *
6  *   Version $Id$
7  *
8  */
9 /*
10    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
11
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.
16
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.
21
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,
25    MA 02111-1307, USA.
26
27  */
28
29
30 #ifndef __BLOCK_H
31 #define __BLOCK_H 1
32
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 */
35
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 */
41
42 /*
43  * This is the Media structure for a block header
44  *  Note, when written, it is serialized.
45  */
46 typedef struct s_block_hdr {
47    uint32_t CheckSum;
48    uint32_t block_size;
49    uint32_t BlockNumber;
50    char     Id[BLKHDR_ID_LENGTH+1];
51 } BLOCK_HDR;
52
53 /*
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
58  * multiple blocks.
59  *
60  *  This is the memory structure for a device block.
61  */
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.
67     */
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 
76                                        * Pool buffer!   
77                                        */
78 } DEV_BLOCK;
79
80 #endif