]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/record.h
Tweak version date
[bacula/bacula] / bacula / src / stored / record.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  * Record, and label definitions for Bacula
30  *  media data format.
31  *
32  *   Kern Sibbald, MM
33  *
34  */
35
36
37 #ifndef __RECORD_H
38 #define __RECORD_H 1
39
40 /* Return codes from read_device_volume_label() */
41 enum {
42    VOL_NOT_READ = 1,                      /* Volume label not read */
43    VOL_OK,                                /* volume name OK */
44    VOL_NO_LABEL,                          /* volume not labeled */
45    VOL_IO_ERROR,                          /* volume I/O error */
46    VOL_NAME_ERROR,                        /* Volume name mismatch */
47    VOL_CREATE_ERROR,                      /* Error creating label */
48    VOL_VERSION_ERROR,                     /* Bacula version error */
49    VOL_LABEL_ERROR,                       /* Bad label type */
50    VOL_NO_MEDIA                           /* Hard error -- no media present */
51 };
52
53
54 /*  See block.h for RECHDR_LENGTH */
55
56 /*
57  * This is the Media structure for a record header.
58  *  NB: when it is written it is serialized.
59
60    uint32_t VolSessionId;
61    uint32_t VolSessionTime;
62
63  * The above 8 bytes are only written in a BB01 block, BB02
64  *  and later blocks contain these values in the block header
65  *  rather than the record header.
66
67    int32_t  FileIndex;
68    int32_t  Stream;
69    uint32_t data_len;
70
71  */
72
73 /* Record state bit definitions */
74 #define REC_NO_HEADER        (1<<0)   /* No header read */
75 #define REC_PARTIAL_RECORD   (1<<1)   /* returning partial record */
76 #define REC_BLOCK_EMPTY      (1<<2)   /* not enough data in block */
77 #define REC_NO_MATCH         (1<<3)   /* No match on continuation data */
78 #define REC_CONTINUATION     (1<<4)   /* Continuation record found */
79 #define REC_ISTAPE           (1<<5)   /* Set if device is tape */
80
81 #define is_partial_record(r) ((r)->state & REC_PARTIAL_RECORD)
82 #define is_block_empty(r)    ((r)->state & REC_BLOCK_EMPTY)
83
84 /*
85  * DEV_RECORD for reading and writing records.
86  * It consists of a Record Header, and the Record Data
87  *
88  *  This is the memory structure for the record header.
89  */
90 struct BSR;                           /* satisfy forward reference */
91 struct DEV_RECORD {
92    dlink link;                        /* link for chaining in read_record.c */
93    /* File and Block are always returned during reading
94     *  and writing records.
95     */
96    uint32_t File;                     /* File number */
97    uint32_t Block;                    /* Block number */
98    uint32_t VolSessionId;             /* sequential id within this session */
99    uint32_t VolSessionTime;           /* session start time */
100    int32_t  FileIndex;                /* sequential file number */
101    int32_t  Stream;                   /* Full Stream number with high bits */
102    int32_t  maskedStream;             /* Masked Stream without high bits */
103    uint32_t data_len;                 /* current record length */
104    uint32_t remainder;                /* remaining bytes to read/write */
105    uint32_t state;                    /* state bits */
106    BSR *bsr;                          /* pointer to bsr that matched */
107    uint8_t  ser_buf[WRITE_RECHDR_LENGTH];   /* serialized record header goes here */
108    POOLMEM *data;                     /* Record data. This MUST be a memory pool item */
109    int32_t match_stat;                /* bsr match status */
110    uint32_t last_VolSessionId;        /* used in sequencing FI for Vbackup */
111    uint32_t last_VolSessionTime;
112    int32_t  last_FileIndex;
113 };
114
115
116 /*
117  * Values for LabelType that are put into the FileIndex field
118  * Note, these values are negative to distinguish them
119  * from user records where the FileIndex is forced positive.
120  */
121 #define PRE_LABEL   -1                /* Vol label on unwritten tape */
122 #define VOL_LABEL   -2                /* Volume label first file */
123 #define EOM_LABEL   -3                /* Writen at end of tape */
124 #define SOS_LABEL   -4                /* Start of Session */
125 #define EOS_LABEL   -5                /* End of Session */
126 #define EOT_LABEL   -6                /* End of physical tape (2 eofs) */
127 #define SOB_LABEL   -7                /* Start of object -- file/directory */
128 #define EOB_LABEL   -8                /* End of object (after all streams) */
129
130 /*
131  *   Volume Label Record.  This is the in-memory definition. The
132  *     tape definition is defined in the serialization code itself
133  *     ser_volume_label() and unser_volume_label() and is slightly different.
134  */
135
136
137 struct Volume_Label {
138   /*
139    * The first items in this structure are saved
140    * in the DEVICE buffer, but are not actually written
141    * to the tape.
142    */
143   int32_t LabelType;                  /* This is written in header only */
144   uint32_t LabelSize;                 /* length of serialized label */
145   /*
146    * The items below this line are stored on
147    * the tape
148    */
149   char Id[32];                        /* Bacula Immortal ... */
150
151   uint32_t VerNum;                    /* Label version number */
152
153   /* VerNum <= 10 */
154   float64_t label_date;               /* Date tape labeled */
155   float64_t label_time;               /* Time tape labeled */
156
157   /* VerNum >= 11 */
158   btime_t   label_btime;              /* tdate tape labeled */
159   btime_t   write_btime;              /* tdate tape written */
160
161   /* Unused with VerNum >= 11 */
162   float64_t write_date;               /* Date this label written */
163   float64_t write_time;               /* Time this label written */
164
165   char VolumeName[MAX_NAME_LENGTH];   /* Volume name */
166   char PrevVolumeName[MAX_NAME_LENGTH]; /* Previous Volume Name */
167   char PoolName[MAX_NAME_LENGTH];     /* Pool name */
168   char PoolType[MAX_NAME_LENGTH];     /* Pool type */
169   char MediaType[MAX_NAME_LENGTH];    /* Type of this media */
170
171   char HostName[MAX_NAME_LENGTH];     /* Host name of writing computer */
172   char LabelProg[50];                 /* Label program name */
173   char ProgVersion[50];               /* Program version */
174   char ProgDate[50];                  /* Program build date/time */
175 };
176
177 #define SER_LENGTH_Volume_Label 1024   /* max serialised length of volume label */
178 #define SER_LENGTH_Session_Label 1024  /* max serialised length of session label */
179
180 typedef struct Volume_Label VOLUME_LABEL;
181
182 /*
183  * Session Start/End Label
184  *  This record is at the beginning and end of each session
185  */
186 struct Session_Label {
187   char Id[32];                        /* Bacula Immortal ... */
188
189   uint32_t VerNum;                    /* Label version number */
190
191   uint32_t JobId;                     /* Job id */
192   uint32_t VolumeIndex;               /* Sequence no of volume for this job */
193
194   /* VerNum >= 11 */
195   btime_t   write_btime;              /* Tdate this label written */
196
197   /* VerNum < 11 */
198   float64_t write_date;               /* Date this label written */
199
200   /* Unused VerNum >= 11 */
201   float64_t write_time;               /* Time this label written */
202
203   char PoolName[MAX_NAME_LENGTH];     /* Pool name */
204   char PoolType[MAX_NAME_LENGTH];     /* Pool type */
205   char JobName[MAX_NAME_LENGTH];      /* base Job name */
206   char ClientName[MAX_NAME_LENGTH];
207   char Job[MAX_NAME_LENGTH];          /* Unique name of this Job */
208   char FileSetName[MAX_NAME_LENGTH];
209   char FileSetMD5[MAX_NAME_LENGTH];
210   uint32_t JobType;
211   uint32_t JobLevel;
212   /* The remainder are part of EOS label only */
213   uint32_t JobFiles;
214   uint64_t JobBytes;
215   uint32_t StartBlock;
216   uint32_t EndBlock;
217   uint32_t StartFile;
218   uint32_t EndFile;
219   uint32_t JobErrors;
220   uint32_t JobStatus;                 /* Job status */
221
222 };
223 typedef struct Session_Label SESSION_LABEL;
224
225 #define SERIAL_BUFSIZE  1024          /* volume serialisation buffer size */
226
227 #endif