2 * Bacula JCR Structure definition for Daemons and the Library
3 * This definition consists of a "Global" definition common
4 * to all daemons and used by the library routines, and a
5 * daemon specific part that is enabled with #defines.
12 Copyright (C) 2000, 2001 Kern Sibbald and John Walker
14 This program is free software; you can redistribute it and/or
15 modify it under the terms of the GNU General Public License
16 as published by the Free Software Foundation; either version 2
17 of the License, or (at your option) any later version.
19 This program is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License
25 along with this program; if not, write to the Free Software
26 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 /* Backup/Verify level code */
34 #define L_INCREMENTAL 'I' /* since last backup */
35 #define L_DIFFERENTIAL 'D' /* since last full backup */
38 #define L_VERIFY_CATALOG 'C' /* verify from catalog */
39 #define L_VERIFY_INIT 'V' /* verify save (init DB) */
40 #define L_VERIFY_VOLUME 'O' /* verify we can read volume */
41 #define L_VERIFY_DATA 'A' /* verify data on volume */
47 #define JT_RESTORE 'R'
48 #define JT_CONSOLE 'C' /* console program */
51 #define JS_Created 'C'
52 #define JS_Running 'R'
53 #define JS_Blocked 'B'
54 #define JS_Terminated 'T' /* terminated normally */
55 #define JS_ErrorTerminated 'E'
56 #define JS_Errored 'E'
57 #define JS_Differences 'D' /* Verify differences */
58 #define JS_Cancelled 'A' /* cancelled by user */
59 #define JS_WaitFD 'F' /* waiting on File daemon */
60 #define JS_WaitSD 'S' /* waiting on the Storage daemon */
61 #define JS_WaitMedia 'm' /* waiting for new media */
62 #define JS_WaitMount 'M' /* waiting for Mount */
64 #define job_cancelled(jcr) \
65 (jcr->JobStatus == JS_Cancelled || jcr->JobStatus == JS_ErrorTerminated)
67 typedef void (JCR_free_HANDLER)(struct s_jcr *jcr);
69 /* Job Control Record (JCR) */
71 /* Global part of JCR common to all daemons */
74 pthread_t my_thread_id; /* id of thread controlling jcr */
75 pthread_mutex_t mutex; /* jcr mutex */
76 BSOCK *dir_bsock; /* Director bsock or NULL if we are him */
77 BSOCK *store_bsock; /* Storage connection socket */
78 BSOCK *file_bsock; /* File daemon connection socket */
79 JCR_free_HANDLER *daemon_free_jcr; /* Local free routine */
80 int use_count; /* use count */
81 char *errmsg; /* edited error message */
82 char Job[MAX_NAME_LENGTH]; /* Job name */
83 uint32_t JobId; /* Director's JobId */
84 uint32_t VolSessionId;
85 uint32_t VolSessionTime;
86 uint32_t JobFiles; /* Number of files written, this job */
88 uint64_t JobBytes; /* Number of bytes processed this job */
89 int JobStatus; /* ready, running, blocked, terminated */
90 int JobTermCode; /* termination code */
91 int JobType; /* backup, restore, verify ... */
93 int authenticated; /* set when client authenticated */
94 time_t sched_time; /* job schedule time, i.e. when it should start */
95 time_t start_time; /* when job actually started */
96 time_t run_time; /* used for computing speed */
97 time_t end_time; /* job end time */
98 char *VolumeName; /* Volume name desired -- pool_memory */
99 char *client_name; /* client name */
100 char *sd_auth_key; /* SD auth key */
101 DEST *dest_chain; /* Job message destination chain */
102 char send_msg[nbytes_for_bits(M_MAX+1)]; /* message bit mask */
104 /* Daemon specific part of JCR */
105 /* This should be empty in the library */
107 #ifdef DIRECTOR_DAEMON
108 /* Director Daemon specific part of JCR */
109 pthread_t SD_msg_chan; /* Message channel thread id */
110 pthread_cond_t term_wait; /* Wait for job termination */
111 int msg_thread_done; /* Set when Storage message thread terms */
112 BSOCK *ua; /* User agent */
113 JOB *job; /* Job resource */
114 STORE *store; /* Storage resource */
115 CLIENT *client; /* Client resource */
116 POOL *pool; /* Pool resource */
117 FILESET *fileset; /* FileSet resource */
118 CAT *catalog; /* Catalog resource */
119 int SDJobStatus; /* Storage Job Status */
120 int mode; /* manual/auto run */
121 B_DB *db; /* database pointer */
122 int MediaId; /* DB record IDs associated with this job */
123 int ClientId; /* Client associated with file */
124 uint32_t PoolId; /* Pool record id */
125 FileId_t FileId; /* Last file id inserted */
126 uint32_t FileIndex; /* Last FileIndex processed */
127 char *fname; /* name to put into catalog */
128 int fn_printed; /* printed filename */
129 char *stime; /* start time for incremental/differential */
130 JOB_DBR jr; /* Job record in Database */
131 int RestoreJobId; /* Id specified by UA */
132 char *RestoreWhere; /* Where to restore the files */
133 #endif /* DIRECTOR_DAEMON */
136 /* File Daemon specific part of JCR */
137 uint32_t num_files_examined; /* files examined this job */
138 char *last_fname; /* last file saved */
139 /*********FIXME********* add missing files and files to be retried */
140 int incremental; /* set if incremental for SINCE */
141 time_t mtime; /* begin time for SINCE */
142 int mode; /* manual/auto run */
143 int status; /* job status */
144 long Ticket; /* Ticket */
145 int save_level; /* save level */
146 char *big_buf; /* I/O buffer */
147 char *compress_buf; /* Compression buffer */
148 char *where; /* Root where to restore */
149 int buf_size; /* length of buffer */
150 FF_PKT *ff; /* Find Files packet */
151 char stored_addr[MAX_NAME_LENGTH]; /* storage daemon address */
156 #endif /* FILE_DAEMON */
158 #ifdef STORAGE_DAEMON
159 /* Storage Daemon specific part of JCR */
160 pthread_cond_t job_start_wait; /* Wait for FD to start Job */
162 DEVRES *device; /* device to use */
163 VOLUME_CAT_INFO VolCatInfo; /* Catalog info for desired volume */
164 char *pool_name; /* pool to use */
165 char *pool_type; /* pool type to use */
166 char *job_name; /* job name */
167 char *media_type; /* media type */
168 char *dev_name; /* device name */
169 long NumVolumes; /* number of volumes used */
170 long CurVolume; /* current volume number */
171 int mode; /* manual/auto run */
172 int label_status; /* device volume label status */
174 DEV_RECORD rec; /* Read/Write record */
175 long Ticket; /* ticket for this job */
176 uint32_t VolFirstFile; /* First file index this Volume */
177 uint32_t start_block; /* Start write block */
178 uint32_t start_file; /* Start write file */
179 uint32_t end_block; /* Ending block written */
180 uint32_t end_file; /* End file written */
182 /* Parmaters for Open Read Session */
183 uint32_t read_VolSessionId;
184 uint32_t read_VolSessionTime;
185 uint32_t read_StartFile;
186 uint32_t read_EndFile;
187 uint32_t read_StartBlock;
188 uint32_t read_EndBlock;
190 #endif /* STORAGE_DAEMON */
195 * Structure for all daemons that keeps some summary
196 * info on the last job run.
203 uint32_t VolSessionId;
204 uint32_t VolSessionTime;
209 char Job[MAX_NAME_LENGTH];
212 extern struct s_last_job last_job;
215 typedef struct s_jcr JCR;
218 /* The following routines are found in lib/jcr.c */
219 extern JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr);
220 extern void free_jcr(JCR *jcr);
221 extern void free_locked_jcr(JCR *jcr);
222 extern JCR *get_jcr_by_id(uint32_t JobId);
223 extern JCR *get_jcr_by_partial_name(char *Job);
224 extern JCR *get_jcr_by_full_name(char *Job);
225 extern JCR *get_next_jcr(JCR *jcr);
226 extern void lock_jcr_chain();
227 extern void unlock_jcr_chain();
229 #endif /* __JCR_H_ */