]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/stored/record.h
6cf5c1f7d7ab09bf9a7b17cf8dbaf58363987d14
[bacula/bacula] / bacula / src / stored / record.h
1 /*
2  * Record, and label definitions for Bacula
3  *  media data format.
4  *
5  */
6 /*
7    Copyright (C) 2000, 2001, 2002 Kern Sibbald and John Walker
8
9    This program is free software; you can redistribute it and/or
10    modify it under the terms of the GNU General Public License as
11    published by the Free Software Foundation; either version 2 of
12    the License, or (at your option) any later version.
13
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17    General Public License for more details.
18
19    You should have received a copy of the GNU General Public
20    License along with this program; if not, write to the Free
21    Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22    MA 02111-1307, USA.
23
24  */
25
26
27 #ifndef __RECORD_H
28 #define __RECORD_H 1
29
30 /* Return codes from read_device_volume_label() */
31 #define VOL_NOT_READ      0               /* Volume label not read */
32 #define VOL_OK            1               /* volume name OK */
33 #define VOL_NO_LABEL      2               /* volume not labeled */
34 #define VOL_IO_ERROR      3               /* volume I/O error */
35 #define VOL_NAME_ERROR    4               /* Volume name mismatch */
36 #define VOL_CREATE_ERROR  5               /* Error creating label */
37 #define VOL_VERSION_ERROR 6               /* Bacula version error */
38 #define VOL_LABEL_ERROR   7               /* Bad label type */
39
40
41 /* Length of Record Header (5 * 4 bytes) */
42 #define RECHDR_LENGTH 20
43
44 /*
45  * This is the Media structure for a record header.
46  *  NB: when it is written it is serialized.
47  */
48 typedef struct s_record_hdr {
49    uint32_t VolSessionId;
50    uint32_t VolSessionTime;
51    int32_t  FileIndex;
52    int32_t  Stream;
53    uint32_t data_len;
54 } RECORD_HDR;
55
56 /*
57  * DEV_RECORD for reading and writing records.
58  * It consists of a Record Header, and the Record Data
59  * 
60  *  This is the memory structure for the record header.
61  */
62 typedef struct s_dev_rec {
63    int      sync;                     /* synchronous */
64    uint32_t File;                     /* File number, returned if sync set */
65    uint32_t Block;                    /* Block number, returned if sync set */
66    uint32_t VolSessionId;             /* sequential id within this session */
67    uint32_t VolSessionTime;           /* session start time */
68    int32_t  FileIndex;                /* sequential file number */
69    int32_t  Stream;                   /* stream number */
70    uint32_t data_len;                 /* current record length */
71    uint32_t remainder;                /* remaining bytes to read/write */
72    uint8_t  ser_buf[RECHDR_LENGTH];   /* serialized record header goes here */
73    char *data;                        /* Record data. This MUST be a memory pool item */
74 } DEV_RECORD;
75
76
77 /*
78  * Values for LabelType that are put into the FileIndex field
79  * Note, these values are negative to distinguish them
80  * from user records where the FileIndex is forced positive.
81  */
82 #define PRE_LABEL   -1                /* Vol label on unwritten tape */
83 #define VOL_LABEL   -2                /* Volume label first file */
84 #define EOM_LABEL   -3                /* Writen at end of tape */        
85 #define SOS_LABEL   -4                /* Start of Session */
86 #define EOS_LABEL   -5                /* End of Session */
87  
88
89 /* 
90  *   Volume Label Record
91  */
92 struct Volume_Label {
93   /*  
94    * The first items in this structure are saved
95    * in the DEVICE buffer, but are not actually written
96    * to the tape.
97    */
98   int32_t LabelType;                  /* This is written in header only */
99   uint32_t LabelSize;                 /* length of serialized label */
100   /*
101    * The items below this line are stored on 
102    * the tape
103    */
104   char Id[32];                        /* Bacula Immortal ... */
105
106   uint32_t VerNum;                    /* Label version number */
107
108   float64_t label_date;               /* Date tape labeled */
109   float64_t label_time;               /* Time tape labeled */
110   float64_t write_date;               /* Date this label written */
111   float64_t write_time;               /* Time this label written */
112
113   char VolName[MAX_NAME_LENGTH];      /* Volume name */
114   char PrevVolName[MAX_NAME_LENGTH];  /* Previous Volume Name */
115   char PoolName[MAX_NAME_LENGTH];     /* Pool name */
116   char PoolType[MAX_NAME_LENGTH];     /* Pool type */
117   char MediaType[MAX_NAME_LENGTH];    /* Type of this media */
118
119   char HostName[MAX_NAME_LENGTH];     /* Host name of writing computer */
120   char LabelProg[32];                 /* Label program name */
121   char ProgVersion[32];               /* Program version */
122   char ProgDate[32];                  /* Program build date/time */
123 };
124
125 #define SER_LENGTH_Volume_Label 1024   /* max serialised length of volume label */
126 #define SER_LENGTH_Session_Label 1024  /* max serialised length of session label */
127
128 typedef struct Volume_Label VOLUME_LABEL;
129
130 /*
131  * Session Start/End Label
132  *  This record is at the beginning and end of each session
133  */
134 struct Session_Label {
135   char Id[32];                        /* Bacula Immortal ... */
136
137   uint32_t VerNum;                    /* Label version number */
138
139   uint32_t JobId;                     /* Job id */
140   uint32_t VolumeIndex;               /* Sequence no of volume for this job */
141
142   float64_t write_date;               /* Date this label written */
143   float64_t write_time;               /* Time this label written */
144
145   char PoolName[MAX_NAME_LENGTH];     /* Pool name */
146   char PoolType[MAX_NAME_LENGTH];     /* Pool type */
147   char JobName[MAX_NAME_LENGTH];
148   char ClientName[MAX_NAME_LENGTH];
149   uint32_t JobFiles;
150   uint64_t JobBytes;
151   uint32_t start_block;
152   uint32_t end_block;
153   uint32_t start_file;
154   uint32_t end_file;
155   uint32_t JobErrors;
156
157 };
158 typedef struct Session_Label SESSION_LABEL;
159
160 #define SERIAL_BUFSIZE  1024          /* volume serialisation buffer size */
161
162 #endif