2 Bacula® - The Network Backup Solution
4 Copyright (C) 2000-2014 Free Software Foundation Europe e.V.
6 The main author of Bacula is Kern Sibbald, with contributions from many
7 others, a complete list can be found in the file AUTHORS.
9 You may use this file and others of this release according to the
10 license defined in the LICENSE file, which includes the Affero General
11 Public License, v3.0 ("AGPLv3") and some additional permissions and
12 terms pursuant to its AGPLv3 Section 7.
14 Bacula® is a registered trademark of Kern Sibbald.
17 * Record, and label definitions for Bacula
28 /* Return codes from read_device_volume_label() */
30 VOL_NOT_READ = 1, /* Volume label not read */
31 VOL_OK, /* volume name OK */
32 VOL_NO_LABEL, /* volume not labeled */
33 VOL_IO_ERROR, /* volume I/O error */
34 VOL_NAME_ERROR, /* Volume name mismatch */
35 VOL_CREATE_ERROR, /* Error creating label */
36 VOL_VERSION_ERROR, /* Bacula version error */
37 VOL_LABEL_ERROR, /* Bad label type */
38 VOL_NO_MEDIA, /* Hard error -- no media present */
39 VOL_TYPE_ERROR /* Volume type (aligned/non-aligned) error */
43 st_none, /* No state */
44 st_header, /* Write header */
45 st_cont_header, /* Write continuation header */
46 st_data /* Write data record */
50 /* See block.h for RECHDR_LENGTH */
53 * This is the Media structure for a record header.
54 * NB: when it is written it is serialized.
56 uint32_t VolSessionId;
57 uint32_t VolSessionTime;
59 * The above 8 bytes are only written in a BB01 block, BB02
60 * and later blocks contain these values in the block header
61 * rather than the record header.
69 /* Record state bit definitions */
70 #define REC_NO_HEADER (1<<0) /* No header read */
71 #define REC_PARTIAL_RECORD (1<<1) /* returning partial record */
72 #define REC_BLOCK_EMPTY (1<<2) /* Not enough data in block */
73 #define REC_NO_MATCH (1<<3) /* No match on continuation data */
74 #define REC_CONTINUATION (1<<4) /* Continuation record found */
75 #define REC_ISTAPE (1<<5) /* Set if device is tape */
77 #define is_partial_record(r) ((r)->state_bits & REC_PARTIAL_RECORD)
78 #define is_block_marked_empty(r) ((r)->state_bits & (REC_BLOCK_EMPTY))
81 * DEV_RECORD for reading and writing records.
82 * It consists of a Record Header, and the Record Data
84 * This is the memory structure for the record header.
86 struct BSR; /* satisfy forward reference */
88 dlink link; /* link for chaining in read_record.c */
89 /* File and Block are always returned during reading
90 * and writing records.
92 uint64_t StreamLen; /* Expected data stream length */
93 uint32_t File; /* File number */
94 uint32_t Block; /* Block number */
95 uint32_t VolSessionId; /* sequential id within this session */
96 uint32_t VolSessionTime; /* session start time */
97 int32_t FileIndex; /* sequential file number */
98 int32_t Stream; /* Full Stream number with high bits */
99 int32_t last_FI; /* previous fi for adata */
100 int32_t last_Stream; /* previous stream for adata */
101 int32_t maskedStream; /* Masked Stream without high bits */
102 uint32_t data_len; /* current record length */
103 uint32_t remainder; /* remaining bytes to read/write */
104 uint32_t adata_remainder; /* remaining adata bytes to read/write */
105 uint32_t remlen; /* temp remainder bytes */
106 uint32_t data_bytes; /* data_bytes */
107 uint32_t state_bits; /* state bits */
108 rec_state wstate; /* state of write_record_to_block */
109 rec_state rstate; /* state of read_record_from_block */
110 BSR *bsr; /* pointer to bsr that matched */
111 POOLMEM *data; /* Record data. This MUST be a memory pool item */
112 int32_t match_stat; /* bsr match status */
113 uint32_t last_VolSessionId; /* used in sequencing FI for Vbackup */
114 uint32_t last_VolSessionTime;
115 int32_t last_FileIndex;
120 * Values for LabelType that are put into the FileIndex field
121 * Note, these values are negative to distinguish them
122 * from user records where the FileIndex is forced positive.
124 #define PRE_LABEL -1 /* Vol label on unwritten tape */
125 #define VOL_LABEL -2 /* Volume label first file */
126 #define EOM_LABEL -3 /* Writen at end of tape */
127 #define SOS_LABEL -4 /* Start of Session */
128 #define EOS_LABEL -5 /* End of Session */
129 #define EOT_LABEL -6 /* End of physical tape (2 eofs) */
130 #define SOB_LABEL -7 /* Start of object -- file/directory */
131 #define EOB_LABEL -8 /* End of object (after all streams) */
134 * Volume Label Record. This is the in-memory definition. The
135 * tape definition is defined in the serialization code itself
136 * ser_volume_label() and unser_volume_label() and is slightly different.
140 struct Volume_Label {
142 * The first items in this structure are saved
143 * in the DEVICE buffer, but are not actually written
146 int32_t LabelType; /* This is written in header only */
147 uint32_t LabelSize; /* length of serialized label */
149 * The items below this line are stored on
152 char Id[32]; /* Bacula Immortal ... */
154 uint32_t VerNum; /* Label version number */
157 float64_t label_date; /* Date tape labeled */
158 float64_t label_time; /* Time tape labeled */
161 btime_t label_btime; /* tdate tape labeled */
162 btime_t write_btime; /* tdate tape written */
164 /* Unused with VerNum >= 11 */
165 float64_t write_date; /* Date this label written */
166 float64_t write_time; /* Time this label written */
168 char VolumeName[MAX_NAME_LENGTH]; /* Volume name */
169 char PrevVolumeName[MAX_NAME_LENGTH]; /* Previous Volume Name */
170 char PoolName[MAX_NAME_LENGTH]; /* Pool name */
171 char PoolType[MAX_NAME_LENGTH]; /* Pool type */
172 char MediaType[MAX_NAME_LENGTH]; /* Type of this media */
174 char HostName[MAX_NAME_LENGTH]; /* Host name of writing computer */
175 char LabelProg[50]; /* Label program name */
176 char ProgVersion[50]; /* Program version */
177 char ProgDate[50]; /* Program build date/time */
180 #define SER_LENGTH_Volume_Label 1024 /* max serialised length of volume label */
181 #define SER_LENGTH_Session_Label 1024 /* max serialised length of session label */
183 typedef struct Volume_Label VOLUME_LABEL;
186 * Session Start/End Label
187 * This record is at the beginning and end of each session
189 struct Session_Label {
190 char Id[32]; /* Bacula Immortal ... */
192 uint32_t VerNum; /* Label version number */
194 uint32_t JobId; /* Job id */
195 uint32_t VolumeIndex; /* Sequence no of volume for this job */
198 btime_t write_btime; /* Tdate this label written */
201 float64_t write_date; /* Date this label written */
203 /* Unused VerNum >= 11 */
204 float64_t write_time; /* Time this label written */
206 char PoolName[MAX_NAME_LENGTH]; /* Pool name */
207 char PoolType[MAX_NAME_LENGTH]; /* Pool type */
208 char JobName[MAX_NAME_LENGTH]; /* base Job name */
209 char ClientName[MAX_NAME_LENGTH];
210 char Job[MAX_NAME_LENGTH]; /* Unique name of this Job */
211 char FileSetName[MAX_NAME_LENGTH];
212 char FileSetMD5[MAX_NAME_LENGTH];
215 /* The remainder are part of EOS label only */
223 uint32_t JobStatus; /* Job status */
226 typedef struct Session_Label SESSION_LABEL;
228 #define SERIAL_BUFSIZE 1024 /* volume serialisation buffer size */