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 */
49 #define JT_ADMIN 'D' /* admin job */
50 #define JT_ARCHIVE 'A'
53 #define JS_Created 'C'
54 #define JS_Running 'R'
55 #define JS_Blocked 'B'
56 #define JS_Terminated 'T' /* terminated normally */
57 #define JS_ErrorTerminated 'E'
58 #define JS_Errored 'E'
59 #define JS_Differences 'D' /* Verify differences */
60 #define JS_Cancelled 'A' /* cancelled by user */
61 #define JS_WaitFD 'F' /* waiting on File daemon */
62 #define JS_WaitSD 'S' /* waiting on the Storage daemon */
63 #define JS_WaitMedia 'm' /* waiting for new media */
64 #define JS_WaitMount 'M' /* waiting for Mount */
66 #define job_cancelled(jcr) \
67 (jcr->JobStatus == JS_Cancelled || jcr->JobStatus == JS_ErrorTerminated)
69 typedef void (JCR_free_HANDLER)(struct s_jcr *jcr);
71 /* Job Control Record (JCR) */
73 /* Global part of JCR common to all daemons */
76 pthread_t my_thread_id; /* id of thread controlling jcr */
77 pthread_mutex_t mutex; /* jcr mutex */
78 BSOCK *dir_bsock; /* Director bsock or NULL if we are him */
79 BSOCK *store_bsock; /* Storage connection socket */
80 BSOCK *file_bsock; /* File daemon connection socket */
81 JCR_free_HANDLER *daemon_free_jcr; /* Local free routine */
82 int use_count; /* use count */
83 char *errmsg; /* edited error message */
84 char Job[MAX_NAME_LENGTH]; /* Job name */
85 uint32_t JobId; /* Director's JobId */
86 uint32_t VolSessionId;
87 uint32_t VolSessionTime;
88 uint32_t JobFiles; /* Number of files written, this job */
90 uint64_t JobBytes; /* Number of bytes processed this job */
91 int JobStatus; /* ready, running, blocked, terminated */
92 int JobTermCode; /* termination code */
93 int JobType; /* backup, restore, verify ... */
95 int authenticated; /* set when client authenticated */
96 time_t sched_time; /* job schedule time, i.e. when it should start */
97 time_t start_time; /* when job actually started */
98 time_t run_time; /* used for computing speed */
99 time_t end_time; /* job end time */
100 POOLMEM *VolumeName; /* Volume name desired -- pool_memory */
101 char *client_name; /* client name */
102 char *sd_auth_key; /* SD auth key */
103 MSGS *msgs; /* Message resource */
105 /* Daemon specific part of JCR */
106 /* This should be empty in the library */
108 #ifdef DIRECTOR_DAEMON
109 /* Director Daemon specific part of JCR */
110 pthread_t SD_msg_chan; /* Message channel thread id */
111 pthread_cond_t term_wait; /* Wait for job termination */
112 int msg_thread_done; /* Set when Storage message thread terms */
113 BSOCK *ua; /* User agent */
114 JOB *job; /* Job resource */
115 STORE *store; /* Storage resource */
116 CLIENT *client; /* Client resource */
117 POOL *pool; /* Pool resource */
118 FILESET *fileset; /* FileSet resource */
119 CAT *catalog; /* Catalog resource */
120 int SDJobStatus; /* Storage Job Status */
121 int mode; /* manual/auto run */
122 B_DB *db; /* database pointer */
123 int MediaId; /* DB record IDs associated with this job */
124 int ClientId; /* Client associated with file */
125 uint32_t PoolId; /* Pool record id */
126 FileId_t FileId; /* Last file id inserted */
127 uint32_t FileIndex; /* Last FileIndex processed */
128 char *fname; /* name to put into catalog */
129 int fn_printed; /* printed filename */
130 char *stime; /* start time for incremental/differential */
131 JOB_DBR jr; /* Job record in Database */
132 int RestoreJobId; /* Id specified by UA */
133 char *RestoreWhere; /* Where to restore the files */
134 #endif /* DIRECTOR_DAEMON */
137 /* File Daemon specific part of JCR */
138 uint32_t num_files_examined; /* files examined this job */
139 char *last_fname; /* last file saved */
140 /*********FIXME********* add missing files and files to be retried */
141 int incremental; /* set if incremental for SINCE */
142 time_t mtime; /* begin time for SINCE */
143 int mode; /* manual/auto run */
144 int status; /* job status */
145 long Ticket; /* Ticket */
146 int save_level; /* save level */
147 char *big_buf; /* I/O buffer */
148 char *compress_buf; /* Compression buffer */
149 char *where; /* Root where to restore */
150 int buf_size; /* length of buffer */
151 FF_PKT *ff; /* Find Files packet */
152 char stored_addr[MAX_NAME_LENGTH]; /* storage daemon address */
157 #endif /* FILE_DAEMON */
159 #ifdef STORAGE_DAEMON
160 /* Storage Daemon specific part of JCR */
161 pthread_cond_t job_start_wait; /* Wait for FD to start Job */
163 DEVRES *device; /* device to use */
164 VOLUME_CAT_INFO VolCatInfo; /* Catalog info for desired volume */
165 char *pool_name; /* pool to use */
166 char *pool_type; /* pool type to use */
167 char *job_name; /* job name */
168 char *media_type; /* media type */
169 char *dev_name; /* device name */
170 long NumVolumes; /* number of volumes used */
171 long CurVolume; /* current volume number */
172 int mode; /* manual/auto run */
173 int label_status; /* device volume label status */
175 DEV_RECORD rec; /* Read/Write record */
176 long Ticket; /* ticket for this job */
177 uint32_t VolFirstFile; /* First file index this Volume */
178 uint32_t start_block; /* Start write block */
179 uint32_t start_file; /* Start write file */
180 uint32_t end_block; /* Ending block written */
181 uint32_t end_file; /* End file written */
183 /* Parmaters for Open Read Session */
184 uint32_t read_VolSessionId;
185 uint32_t read_VolSessionTime;
186 uint32_t read_StartFile;
187 uint32_t read_EndFile;
188 uint32_t read_StartBlock;
189 uint32_t read_EndBlock;
191 #endif /* STORAGE_DAEMON */
196 * Structure for all daemons that keeps some summary
197 * info on the last job run.
204 uint32_t VolSessionId;
205 uint32_t VolSessionTime;
210 char Job[MAX_NAME_LENGTH];
213 extern struct s_last_job last_job;
216 typedef struct s_jcr JCR;
219 /* The following routines are found in lib/jcr.c */
220 extern JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr);
221 extern void free_jcr(JCR *jcr);
222 extern void free_locked_jcr(JCR *jcr);
223 extern JCR *get_jcr_by_id(uint32_t JobId);
224 extern JCR *get_jcr_by_partial_name(char *Job);
225 extern JCR *get_jcr_by_full_name(char *Job);
226 extern JCR *get_next_jcr(JCR *jcr);
227 extern void lock_jcr_chain();
228 extern void unlock_jcr_chain();
230 #endif /* __JCR_H_ */