]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/block.h
Start adding DeltaSeq
[bacula/bacula] / bacula / src / stored / block.h
1 /*
2    Bacula® - The Network Backup Solution
3
4    Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
5
6    The main author of Bacula is Kern Sibbald, with contributions from
7    many others, a complete list can be found in the file AUTHORS.
8    This program is Free Software; you can redistribute it and/or
9    modify it under the terms of version three of the GNU Affero General Public
10    License as published by the Free Software Foundation and included
11    in the file LICENSE.
12
13    This program is distributed in the hope that it will be useful, but
14    WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16    General Public License for more details.
17
18    You should have received a copy of the GNU Affero General Public License
19    along with this program; if not, write to the Free Software
20    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21    02110-1301, USA.
22
23    Bacula® is a registered trademark of Kern Sibbald.
24    The licensor of Bacula is the Free Software Foundation Europe
25    (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
26    Switzerland, email:ftf@fsfeurope.org.
27 */
28 /*
29  * Block definitions for Bacula media data format.
30  *
31  *    Kern Sibbald, MM
32  *
33  */
34
35
36 #ifndef __BLOCK_H
37 #define __BLOCK_H 1
38
39 #define MAX_BLOCK_LENGTH  20000000      /* this is a sort of sanity check */
40 #define DEFAULT_BLOCK_SIZE (512 * 126)  /* 64,512 N.B. do not use 65,636 here */
41
42 /* Block Header definitions. */
43 #define BLKHDR1_ID       "BB01"
44 #define BLKHDR2_ID       "BB02"
45 #define BLKHDR_ID_LENGTH  4
46 #define BLKHDR_CS_LENGTH  4             /* checksum length */
47 #define BLKHDR1_LENGTH   16             /* Total length */
48 #define BLKHDR2_LENGTH   24             /* Total length */
49
50 #define WRITE_BLKHDR_ID     BLKHDR2_ID
51 #define WRITE_BLKHDR_LENGTH BLKHDR2_LENGTH
52 #define BLOCK_VER               2
53
54 /* Record header definitions */
55 #define RECHDR1_LENGTH      20
56 #define RECHDR2_LENGTH      12
57 #define WRITE_RECHDR_LENGTH RECHDR2_LENGTH
58
59 /* Tape label and version definitions */
60 #define BaculaId    "Bacula 1.0 immortal\n"
61 #define OldBaculaId "Bacula 0.9 mortal\n"
62 #define BaculaTapeVersion 11
63 #define OldCompatibleBaculaTapeVersion1  10
64 #define OldCompatibleBaculaTapeVersion2   9
65
66
67 /*
68  * This is the Media structure for a block header
69  *  Note, when written, it is serialized.
70
71    uint32_t CheckSum;
72    uint32_t block_len;
73    uint32_t BlockNumber;
74    char     Id[BLKHDR_ID_LENGTH];
75
76  * for BB02 block, we also have
77
78    uint32_t VolSessionId;
79    uint32_t VolSessionTime;
80  */
81
82 class DEVICE;                         /* for forward reference */
83
84 /*
85  * DEV_BLOCK for reading and writing blocks.
86  * This is the basic unit that is written to the device, and
87  * it contains a Block Header followd by Records.  Note,
88  * at times (when reading a file), this block may contain
89  * multiple blocks.
90  *
91  *  This is the memory structure for a device block.
92  */
93 struct DEV_BLOCK {
94    DEV_BLOCK *next;                   /* pointer to next one */
95    DEVICE *dev;                       /* pointer to device */
96    /* binbuf is the number of bytes remaining in the buffer.
97     *   For writes, it is bytes not yet written.
98     *   For reads, it is remaining bytes not yet read.
99     */
100    uint32_t binbuf;                   /* bytes in buffer */
101    uint32_t block_len;                /* length of current block read */
102    uint32_t buf_len;                  /* max/default block length */
103    uint32_t BlockNumber;              /* sequential Bacula block number */
104    uint32_t read_len;                 /* bytes read into buffer, if zero, block empty */
105    uint32_t VolSessionId;             /* */
106    uint32_t VolSessionTime;           /* */
107    uint32_t read_errors;              /* block errors (checksum, header, ...) */
108    int      BlockVer;                 /* block version 1 or 2 */
109    bool     write_failed;             /* set if write failed */
110    bool     block_read;               /* set when block read */
111    int32_t  FirstIndex;               /* first index this block */
112    int32_t  LastIndex;                /* last index this block */
113    char    *bufp;                     /* pointer into buffer */
114    POOLMEM *buf;                      /* actual data buffer */
115 };
116
117 #define block_is_empty(block) ((block)->read_len == 0)
118
119 #endif