2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
6 The original author of Bacula is Kern Sibbald, with contributions
7 from many 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 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Bacula JCR Structure definition for Daemons and the Library
21 * This definition consists of a "Global" definition common
22 * to all daemons and used by the library routines, and a
23 * daemon specific part that is enabled with #defines.
25 * Written by Kern Sibbald, Nov MM
32 /* Backup/Verify level code. These are stored in the DB */
33 #define L_FULL 'F' /* Full backup */
34 #define L_INCREMENTAL 'I' /* since last backup */
35 #define L_DIFFERENTIAL 'D' /* since last full backup */
37 #define L_VERIFY_CATALOG 'C' /* verify from catalog */
38 #define L_VERIFY_INIT 'V' /* verify save (init DB) */
39 #define L_VERIFY_VOLUME_TO_CATALOG 'O' /* verify Volume to catalog entries */
40 #define L_VERIFY_DISK_TO_CATALOG 'd' /* verify Disk attributes to catalog */
41 #define L_VERIFY_DATA 'A' /* verify data on volume */
42 #define L_BASE 'B' /* Base level job */
43 #define L_NONE ' ' /* None, for Restore and Admin */
44 #define L_VIRTUAL_FULL 'f' /* Virtual full backup */
47 /* Job Types. These are stored in the DB */
48 #define JT_BACKUP 'B' /* Backup Job */
49 #define JT_MIGRATED_JOB 'M' /* A previous backup job that was migrated */
50 #define JT_VERIFY 'V' /* Verify Job */
51 #define JT_RESTORE 'R' /* Restore Job */
52 #define JT_CONSOLE 'U' /* console program */
53 #define JT_SYSTEM 'I' /* internal system "job" */
54 #define JT_ADMIN 'D' /* admin job */
55 #define JT_ARCHIVE 'A' /* Archive Job */
56 #define JT_JOB_COPY 'C' /* Copy of a Job */
57 #define JT_COPY 'c' /* Copy Job */
58 #define JT_MIGRATE 'g' /* Migration Job */
59 #define JT_SCAN 'S' /* Scan Job */
61 /* Used to handle ClientAcl in various commands, not stored in the DB */
62 #define JT_BACKUP_RESTORE '*' /* Backup or Restore Job */
64 /* Job Status. Some of these are stored in the DB */
65 #define JS_Canceled 'A' /* canceled by user */
66 #define JS_Blocked 'B' /* blocked */
67 #define JS_Created 'C' /* created but not yet running */
68 #define JS_Differences 'D' /* Verify differences */
69 #define JS_ErrorTerminated 'E' /* Job terminated in error */
70 #define JS_WaitFD 'F' /* waiting on File daemon */
71 #define JS_Incomplete 'I' /* Incomplete Job */
72 #define JS_DataCommitting 'L' /* Committing data (last despool) */
73 #define JS_WaitMount 'M' /* waiting for Mount */
74 #define JS_Running 'R' /* running */
75 #define JS_WaitSD 'S' /* waiting on the Storage daemon */
76 #define JS_Terminated 'T' /* terminated normally */
77 #define JS_Warnings 'W' /* Terminated normally with warnings */
79 #define JS_AttrDespooling 'a' /* SD despooling attributes */
80 #define JS_WaitClientRes 'c' /* Waiting for Client resource */
81 #define JS_WaitMaxJobs 'd' /* Waiting for maximum jobs */
82 #define JS_Error 'e' /* Non-fatal error */
83 #define JS_FatalError 'f' /* Fatal error */
84 #define JS_AttrInserting 'i' /* Doing batch insert file records */
85 #define JS_WaitJobRes 'j' /* Waiting for job resource */
86 #define JS_DataDespooling 'l' /* Doing data despooling */
87 #define JS_WaitMedia 'm' /* waiting for new media */
88 #define JS_WaitPriority 'p' /* Waiting for higher priority jobs to finish */
89 #define JS_WaitDevice 'q' /* Queued waiting for device */
90 #define JS_WaitStoreRes 's' /* Waiting for storage resource */
91 #define JS_WaitStartTime 't' /* Waiting for start time */
92 #define JS_CloudUpload 'u' /* Cloud upload */
93 #define JS_CloudDownload 'w' /* Cloud download */
95 /* Migration selection types. Do not change the order. */
101 MT_POOL_UNCOPIED_JOBS,
108 #define job_canceled(jcr) \
109 (jcr->JobStatus == JS_Canceled || \
110 jcr->JobStatus == JS_ErrorTerminated || \
111 jcr->JobStatus == JS_FatalError \
114 #define job_waiting(jcr) \
115 (jcr->job_started && \
116 (jcr->JobStatus == JS_WaitFD || \
117 jcr->JobStatus == JS_WaitSD || \
118 jcr->JobStatus == JS_WaitMedia || \
119 jcr->JobStatus == JS_WaitMount || \
120 jcr->JobStatus == JS_WaitStoreRes || \
121 jcr->JobStatus == JS_WaitJobRes || \
122 jcr->JobStatus == JS_WaitClientRes || \
123 jcr->JobStatus == JS_WaitMaxJobs || \
124 jcr->JobStatus == JS_WaitPriority || \
125 jcr->SDJobStatus == JS_WaitMedia || \
126 jcr->SDJobStatus == JS_WaitMount || \
127 jcr->SDJobStatus == JS_WaitDevice || \
128 jcr->SDJobStatus == JS_CloudUpload || \
129 jcr->SDJobStatus == JS_CloudDownload || \
130 jcr->SDJobStatus == JS_WaitMaxJobs))
134 #define foreach_jcr(jcr) \
135 for (jcr=jcr_walk_start(); jcr; (jcr=jcr_walk_next(jcr)) )
137 #define endeach_jcr(jcr) jcr_walk_end(jcr)
139 #define SD_APPEND true
140 #define SD_READ false
142 /* Forward referenced structures */
158 class snapshot_manager;
161 bool pki_sign; /* Enable PKI Signatures? */
162 bool pki_encrypt; /* Enable PKI Encryption? */
163 DIGEST *digest; /* Last file's digest context */
164 X509_KEYPAIR *pki_keypair; /* Encryption key pair */
165 alist *pki_signers; /* Trusted Signers */
166 alist *pki_recipients; /* Trusted Recipients */
167 CRYPTO_SESSION *pki_session; /* PKE Public Keys + Symmetric Session Keys */
168 POOLMEM *pki_session_encoded; /* Cached DER-encoded copy of pki_session */
169 int32_t pki_session_encoded_size; /* Size of DER-encoded pki_session */
170 POOLMEM *crypto_buf; /* Encryption/Decryption buffer */
174 typedef void (JCR_free_HANDLER)(JCR *jcr);
176 /* Job Control Record (JCR) */
179 pthread_mutex_t mutex; /* jcr mutex */
180 pthread_mutex_t mutex_auth; /* used during authentication */
181 volatile int32_t _use_count; /* use count */
182 int32_t m_JobType; /* backup, restore, verify ... */
183 int32_t m_JobLevel; /* Job level */
184 bool my_thread_killable; /* can we kill the thread? */
186 void lock() {P(mutex); };
187 void unlock() {V(mutex); };
188 void lock_auth() {P(mutex_auth);};
189 void unlock_auth() {V(mutex_auth);};
190 void inc_use_count(void) {lock(); _use_count++; unlock(); };
191 void dec_use_count(void) {lock(); _use_count--; unlock(); };
192 int32_t use_count() const { return _use_count; };
193 void init_mutex(void) {
194 pthread_mutex_init(&mutex, NULL);
195 pthread_mutex_init(&mutex_auth, NULL);
197 void destroy_mutex(void) {
198 pthread_mutex_destroy(&mutex_auth);
199 pthread_mutex_destroy(&mutex);
201 bool is_internal_job() {return (JobId == 0 || m_JobType == JT_SYSTEM || m_JobType == JT_CONSOLE); };
202 bool is_job_canceled() {return job_canceled(this); };
203 bool is_canceled() {return job_canceled(this); };
204 bool is_incomplete() { return JobStatus == JS_Incomplete; };
205 bool is_JobLevel(int32_t JobLevel) { return JobLevel == m_JobLevel; };
206 bool is_JobType(int32_t JobType) { return JobType == m_JobType; };
207 bool is_JobStatus(int32_t aJobStatus) { return aJobStatus == JobStatus; };
208 void setJobLevel(int32_t JobLevel) { m_JobLevel = JobLevel; };
209 void setJobType(int32_t JobType) { m_JobType = JobType; };
210 void forceJobStatus(int32_t aJobStatus) { JobStatus = aJobStatus; };
211 void setJobStarted();
212 int32_t getJobType() const { return m_JobType; };
213 int32_t getJobLevel() const { return m_JobLevel; };
214 int32_t getJobStatus() const { return JobStatus; };
215 bool no_client_used() const {
216 return (m_JobLevel == L_VIRTUAL_FULL);
218 bool can_be_stopped(); /* in lib/jcr.c */
219 const char *get_OperationName(); /* in lib/jcr.c */
220 const char *get_ActionName(bool past); /* in lib/jcr.c */
221 void setJobStatus(int JobStatus); /* in lib/jcr.c */
222 bool sendJobStatus(); /* in lib/jcr.c */
223 bool sendJobStatus(int JobStatus); /* in lib/jcr.c */
224 bool JobReads(); /* in lib/jcr.c */
225 void my_thread_send_signal(int sig); /* in lib/jcr.c */
226 void set_killable(bool killable); /* in lib/jcr.c */
227 bool is_killable() const { return my_thread_killable; };
229 /* Global part of JCR common to all daemons */
230 dlink link; /* JCR chain link */
231 pthread_t my_thread_id; /* id of thread controlling jcr */
232 BSOCK *dir_bsock; /* Director bsock or NULL if we are him */
233 BSOCK *store_bsock; /* Storage connection socket */
234 BSOCK *file_bsock; /* File daemon connection socket */
235 JCR_free_HANDLER *daemon_free_jcr; /* Local free routine */
236 dlist *msg_queue; /* Queued messages */
237 pthread_mutex_t msg_queue_mutex; /* message queue mutex */
238 bool dequeuing_msgs; /* Set when dequeuing messages */
239 alist job_end_push; /* Job end pushed calls */
240 POOLMEM *VolumeName; /* Volume name desired -- pool_memory */
241 POOLMEM *errmsg; /* edited error message */
242 char Job[MAX_NAME_LENGTH]; /* Unique name of this Job */
243 char event[MAX_NAME_LENGTH]; /* Current event (python) */
244 uint32_t eventType; /* Current event type (plugin) */
246 uint32_t JobId; /* Director's JobId */
247 uint32_t VolSessionId;
248 uint32_t VolSessionTime;
249 uint32_t JobFiles; /* Number of files written, this job */
250 uint32_t JobErrors; /* Number of non-fatal errors this job */
251 uint32_t SDErrors; /* Number of non-fatal SD errors */
252 uint32_t JobWarnings; /* Number of warning messages */
253 uint32_t LastRate; /* Last sample bytes/sec */
254 uint64_t JobBytes; /* Number of bytes processed this job */
255 uint64_t LastJobBytes; /* Last sample number bytes */
256 uint64_t ReadBytes; /* Bytes read -- before compression */
257 uint64_t CommBytes; /* FD comm line bytes sent to SD */
258 uint64_t CommCompressedBytes; /* FD comm line compressed bytes sent to SD */
259 FileId_t FileId; /* Last FileId used */
260 volatile int32_t JobStatus; /* ready, running, blocked, terminated */
261 int32_t JobPriority; /* Job priority */
262 time_t sched_time; /* job schedule time, i.e. when it should start */
263 time_t initial_sched_time; /* original sched time before any reschedules are done */
264 time_t start_time; /* when job actually started */
265 time_t run_time; /* used for computing speed */
266 time_t last_time; /* Last sample time */
267 time_t end_time; /* job end time */
268 time_t wait_time_sum; /* cumulative wait time since job start */
269 time_t wait_time; /* timestamp when job have started to wait */
270 time_t job_started_time; /* Time when the MaxRunTime start to count */
271 POOLMEM *client_name; /* client name */
272 POOLMEM *JobIds; /* User entered string of JobIds */
273 POOLMEM *RestoreBootstrap; /* Bootstrap file to restore */
274 POOLMEM *stime; /* start time for incremental/differential */
275 char *sd_auth_key; /* SD auth key */
276 MSGS *jcr_msgs; /* Copy of message resource -- actually used */
277 uint32_t ClientId; /* Client associated with Job */
278 char *where; /* prefix to restore files to */
279 char *RegexWhere; /* file relocation in restore */
280 alist *where_bregexp; /* BREGEXP alist for path manipulation */
281 int32_t cached_pnl; /* cached path length */
282 POOLMEM *cached_path; /* cached path */
283 bool prefix_links; /* Prefix links with Where path */
284 bool gui; /* set if gui using console */
285 bool authenticated; /* set when client authenticated */
286 bool cached_attribute; /* set if attribute is cached */
287 bool batch_started; /* is batch mode already started ? */
288 bool cmd_plugin; /* Set when processing a command Plugin = */
289 bool opt_plugin; /* Set when processing an option Plugin = */
290 bool keep_path_list; /* Keep newly created path in a hash */
291 bool accurate; /* true if job is accurate */
292 bool HasBase; /* True if job use base jobs */
293 bool rerunning; /* rerunning an incomplete job */
294 bool job_started; /* Set when the job is actually started */
295 bool sd_calls_client; /* Set for SD to call client (FD/SD) */
296 bool exiting; /* Set when exiting */
298 void *Python_job; /* Python Job Object */
299 void *Python_events; /* Python Events Object */
300 POOLMEM *attr; /* Attribute string from SD */
301 BDB *db; /* database pointer */
302 BDB *db_batch; /* database pointer for batch and accurate */
303 uint64_t nb_base_files; /* Number of base files */
304 uint64_t nb_base_files_used; /* Number of useful files in base */
306 ATTR_DBR *ar; /* DB attribute record */
307 guid_list *id_list; /* User/group id to name list */
309 bpContext *plugin_ctx_list; /* list of contexts for plugins */
310 bpContext *plugin_ctx; /* current plugin context */
311 Plugin *plugin; /* plugin instance */
312 save_pkt *plugin_sp; /* plugin save packet */
313 char *plugin_options; /* user set options for plugin */
314 POOLMEM *comment; /* Comment for this Job */
315 int64_t max_bandwidth; /* Bandwidth limit for this Job */
316 htable *path_list; /* Directory list (used by findlib) */
317 int job_uid; /* UID used during job session */
318 char *job_user; /* Specific permission for a job */
319 char *job_group; /* Specific permission for a job */
320 POOLMEM *StatusErrMsg; /* Error message displayed in the job report */
321 uint32_t getErrors() { return JobErrors + SDErrors; }; /* Get error count */
323 /* Daemon specific part of JCR */
324 /* This should be empty in the library */
326 #ifdef DIRECTOR_DAEMON
327 /* Director Daemon specific data part of JCR */
328 bool SD_msg_chan_started; /* True if the msg thread is started */
329 pthread_t SD_msg_chan; /* Message channel thread id */
330 pthread_cond_t term_wait; /* Wait for job termination */
331 workq_ele_t *work_item; /* Work queue item if scheduled */
332 BSOCK *ua; /* User agent */
333 JOB *job; /* Job resource */
334 JOB *verify_job; /* Job resource of verify previous job */
335 alist *plugin_config; /* List of ConfigFile needed for restore */
336 alist *rstorage; /* Read storage possibilities */
337 STORE *rstore; /* Selected read storage */
338 alist *wstorage; /* Write storage possibilities */
339 STORE *wstore; /* Selected write storage */
340 CLIENT *client; /* Client resource */
341 POOL *pool; /* Pool resource = write for migration */
342 POOL *next_pool; /* Next pool override */
343 POOL *rpool; /* Read pool. Used only in migration */
344 POOL *full_pool; /* Full backup pool resource */
345 POOL *vfull_pool; /* Virtual Full backup pool resource */
346 POOL *inc_pool; /* Incremental backup pool resource */
347 POOL *diff_pool; /* Differential backup pool resource */
348 FILESET *fileset; /* FileSet resource */
349 CAT *catalog; /* Catalog resource */
350 MSGS *messages; /* Default message handler */
351 uint32_t SDJobFiles; /* Number of files written, this job */
352 uint64_t SDJobBytes; /* Number of bytes processed this job */
353 volatile int32_t SDJobStatus; /* Storage Job Status */
354 volatile int32_t FDJobStatus; /* File daemon Job Status */
355 uint32_t ExpectedFiles; /* Expected restore files */
356 uint32_t MediaId; /* DB record IDs associated with this job */
357 uint32_t FileIndex; /* Last FileIndex processed */
358 utime_t MaxRunSchedTime; /* max run time in seconds from Initial Scheduled time */
359 POOLMEM *fname; /* name to put into catalog */
360 POOLMEM *component_fname; /* Component info file name */
361 POOLMEM *media_type; /* Set if user supplied Storage */
362 FILE *component_fd; /* Component info file desc */
363 JOB_DBR jr; /* Job DB record for current job */
364 JOB_DBR previous_jr; /* previous job database record */
365 JOB *previous_job; /* Job resource of migration previous job */
366 JCR *wjcr; /* JCR for migration/copy write job */
367 char FSCreateTime[MAX_TIME_LENGTH]; /* FileSet CreateTime as returned from DB */
368 char since[MAX_TIME_LENGTH]; /* since time */
369 char PrevJob[MAX_NAME_LENGTH]; /* Previous job name assiciated with since time */
371 JobId_t RestoreJobId; /* Id specified by UA */
372 JobId_t MigrateJobId;
374 POOLMEM *client_uname; /* client uname */
375 POOLMEM *pool_source; /* Where pool came from */
376 POOLMEM *next_pool_source; /* Where next pool came from */
377 POOLMEM *rpool_source; /* Where migrate read pool came from */
378 POOLMEM *rstore_source; /* Where read storage came from */
379 POOLMEM *wstore_source; /* Where write storage came from */
380 POOLMEM *catalog_source; /* Where catalog came from */
381 POOLMEM *next_vol_list; /* Volumes previously requested */
382 int32_t replace; /* Replace option */
383 int32_t NumVols; /* Number of Volume used in pool */
384 int32_t reschedule_count; /* Number of times rescheduled */
385 int32_t FDVersion; /* File daemon version number */
386 int32_t SDVersion; /* Storage daemon version number */
387 int64_t spool_size; /* Spool size for this job */
388 utime_t snapshot_retention; /* Snapshot retention (from Client/Job resource) */
389 volatile bool sd_msg_thread_done; /* Set when Storage message thread done */
390 bool wasVirtualFull; /* set if job was VirtualFull */
391 bool IgnoreDuplicateJobChecking; /* set in migration jobs */
392 bool spool_data; /* Spool data in SD */
393 bool acquired_resource_locks; /* set if resource locks acquired */
394 bool term_wait_inited; /* Set when cond var inited */
395 bool fn_printed; /* printed filename */
396 bool write_part_after_job; /* Write part after job in SD */
397 bool needs_sd; /* set if SD needed by Job */
398 bool cloned; /* set if cloned */
399 bool unlink_bsr; /* Unlink bsr file created */
400 bool Snapshot; /* Snapshot used by FD (VSS on Windows) */
401 bool Encrypt; /* Encryption used by FD */
402 bool stats_enabled; /* Keep all job records in a table for long term statistics */
403 bool no_maxtime; /* Don't check Max*Time for this JCR */
404 bool keep_sd_auth_key; /* Clear or not the SD auth key after connection*/
405 bool use_accurate_chksum; /* Use or not checksum option in accurate code */
406 bool run_pool_override;
407 bool cmdline_next_pool_override; /* Next pool is overridden */
408 bool run_next_pool_override; /* Next pool is overridden */
409 bool run_full_pool_override;
410 bool run_vfull_pool_override;
411 bool run_inc_pool_override;
412 bool run_diff_pool_override;
413 bool sd_canceled; /* set if SD canceled */
414 bool RescheduleIncompleteJobs; /* set if incomplete can be rescheduled */
415 bool use_all_JobIds; /* Use all jobids present in command line */
416 bool sd_client; /* This job runs as SD client */
417 bool dummy_jobmedia; /* Dummy JobMedia written */
418 #endif /* DIRECTOR_DAEMON */
422 /* File Daemon specific part of JCR */
423 BSOCK *sd_calls_client_bsock; /* Socket used by SDCallsClient feature */
424 uint32_t num_files_examined; /* files examined this job */
425 POOLMEM *last_fname; /* last file saved/verified */
426 POOLMEM *job_metadata; /* VSS job metadata */
427 pthread_cond_t job_start_wait; /* Wait for SD to start Job */
428 BACL *bacl; /* ACLs for backup/restore */
429 BXATTR *bxattr; /* Extended Attributes for backup/restore */
430 int32_t last_type; /* type of last file saved/verified */
431 int incremental; /* set if incremental for SINCE */
432 time_t last_stat_time; /* Last time stats sent to Dir */
433 time_t stat_interval; /* Stats send interval */
434 utime_t mtime; /* begin time for SINCE */
435 int listing; /* job listing in estimate */
436 long Ticket; /* Ticket */
437 char *big_buf; /* I/O buffer */
438 POOLMEM *compress_buf; /* Compression buffer */
439 int32_t compress_buf_size; /* Length of compression buffer */
440 void *pZLIB_compress_workset; /* zlib compression session data */
441 void *LZO_compress_workset; /* lzo compression session data */
442 int32_t replace; /* Replace options */
443 int32_t buf_size; /* length of buffer */
444 FF_PKT *ff; /* Find Files packet */
445 char stored_addr[MAX_NAME_LENGTH]; /* storage daemon address */
446 char PrevJob[MAX_NAME_LENGTH]; /* Previous job name assiciated with since time */
447 uint32_t ExpectedFiles; /* Expected restore files */
452 pthread_t heartbeat_id; /* id of heartbeat thread */
453 volatile bool hb_started; /* heartbeat running */
454 BSOCK *hb_bsock; /* duped SD socket */
455 BSOCK *hb_dir_bsock; /* duped DIR socket */
456 alist *RunScripts; /* Commands to run before and after job */
457 CRYPTO_CTX crypto; /* Crypto ctx */
458 DIRRES* director; /* Director resource */
459 bool Snapshot; /* Snapshot used by FD (or VSS) */
460 bool got_metadata; /* set when found job_metatdata */
461 bool multi_restore; /* Dir can do multiple storage restore */
462 bool interactive_session; /* Use interactive session with the SD */
463 htable *file_list; /* Previous file list (accurate mode) */
464 uint64_t base_size; /* compute space saved with base job */
465 utime_t snapshot_retention; /* Snapshot retention (from director) */
466 snapshot_manager *snap_mgr; /* Snapshot manager */
467 VSSClient *pVSSClient; /* VSS handler */
468 #endif /* FILE_DAEMON */
471 #ifdef STORAGE_DAEMON
472 /* Storage Daemon specific part of JCR */
473 JCR *next_dev; /* next JCR attached to device */
474 JCR *prev_dev; /* previous JCR attached to device */
475 dlist *jobmedia_queue; /* JobMedia queue */
476 char *dir_auth_key; /* Dir auth key */
477 pthread_cond_t job_start_wait; /* Wait for FD to start Job */
479 DCR *read_dcr; /* device context for reading */
480 DCR *dcr; /* device context record */
481 alist *dcrs; /* list of dcrs open */
482 POOLMEM *job_name; /* base Job name (not unique) */
483 POOLMEM *fileset_name; /* FileSet */
484 POOLMEM *fileset_md5; /* MD5 for FileSet */
485 char stored_addr[MAX_NAME_LENGTH]; /* storage daemon address */
486 char client_addr[MAX_NAME_LENGTH]; /* client daemon address */
487 VOL_LIST *VolList; /* list to read, freed at the end of the job */
488 int32_t NumWriteVolumes; /* number of volumes written */
489 int32_t NumReadVolumes; /* total number of volumes to read */
490 int32_t CurReadVolume; /* current read volume number */
491 int32_t label_errors; /* count of label errors */
492 int32_t DIRVersion; /* Director version number */
493 int32_t FDVersion; /* File daemon version number */
494 int32_t SDVersion; /* Storage daemon version number */
496 bool interactive_session; /* Interactive session with the FD */
497 bool is_ok_data_sent; /* the "3000 OK data" has been sent */
498 long Ticket; /* ticket for this job */
499 bool ignore_label_errors; /* ignore Volume label errors */
500 bool spool_attributes; /* set if spooling attributes */
501 bool no_attributes; /* set if no attributes wanted */
502 int64_t spool_size; /* Spool size for this job */
503 bool spool_data; /* set to spool data */
504 int32_t CurVol; /* Current Volume count */
505 DIRRES* director; /* Director resource */
506 alist *write_store; /* list of write storage devices sent by DIR */
507 alist *read_store; /* list of read devices sent by DIR */
508 alist *reserve_msgs; /* reserve fail messages */
509 bool write_part_after_job; /* Set to write part after job */
510 bool PreferMountedVols; /* Prefer mounted vols rather than new */
511 bool Resched; /* Job may be rescheduled */
512 bool bscan_insert_jobmedia_records; /*Bscan: needs to insert job media records */
513 bool sd_client; /* Set if acting as client */
514 bool use_new_match_all; /* TODO: Remove when the match_bsr() will be well tested */
516 /* Parmaters for Open Read Session */
517 BSR *bsr; /* Bootstrap record -- has everything */
518 bool mount_next_volume; /* set to cause next volume mount */
519 uint32_t read_VolSessionId;
520 uint32_t read_VolSessionTime;
521 uint32_t read_StartFile;
522 uint32_t read_EndFile;
523 uint32_t read_StartBlock;
524 uint32_t read_EndBlock;
525 /* Device wait times */
528 int32_t max_num_wait;
530 int32_t rem_wait_sec;
532 #endif /* STORAGE_DAEMON */
537 * Setting a NULL in tsd doesn't clear the tsd but instead tells
538 * pthreads not to call the tsd destructor. Consequently, we
539 * define this *invalid* jcr address and stuff it in the tsd
540 * when the jcr is not valid.
542 #define INVALID_JCR ((JCR *)(-1))
546 * Structure for all daemons that keeps some summary
547 * info on the last job run.
551 int32_t Errors; /* FD/SD errors */
556 uint32_t VolSessionId;
557 uint32_t VolSessionTime;
562 char Job[MAX_NAME_LENGTH];
565 extern struct s_last_job last_job;
566 extern DLL_IMP_EXP dlist *last_jobs;
569 /* The following routines are found in lib/jcr.c */
570 extern int get_next_jobid_from_list(char **p, uint32_t *JobId);
571 extern bool init_jcr_subsystem(void);
572 extern JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr);
573 extern JCR *get_jcr_by_id(uint32_t JobId);
574 extern JCR *get_jcr_by_session(uint32_t SessionId, uint32_t SessionTime);
575 extern JCR *get_jcr_by_partial_name(char *Job);
576 extern JCR *get_jcr_by_full_name(char *Job);
577 extern JCR *get_next_jcr(JCR *jcr);
578 extern void set_jcr_job_status(JCR *jcr, int JobStatus);
579 extern int DLL_IMP_EXP num_jobs_run;
582 extern void b_free_jcr(const char *file, int line, JCR *jcr);
583 #define free_jcr(jcr) b_free_jcr(__FILE__, __LINE__, (jcr))
585 extern void free_jcr(JCR *jcr);
588 /* Used to display specific job information after a fatal signal */
589 typedef void (dbg_jcr_hook_t)(JCR *jcr, FILE *fp);
590 extern void dbg_jcr_add_hook(dbg_jcr_hook_t *fct);
592 #endif /* __JCR_H_ */