2 * Match Bootstrap Records (used for restores) against
5 * Kern Sibbald, June MMII
11 Copyright (C) 2002 Kern Sibbald and John Walker
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of
16 the License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public
24 License along with this program; if not, write to the Free
25 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
35 /* Forward references */
36 static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec);
37 static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec);
38 static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec);
39 static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec);
40 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec);
41 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec);
42 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec);
43 static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec);
44 static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec);
45 static int match_stream(BSR_STREAM *stream, DEV_RECORD *rec);
46 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec);
48 /*********************************************************************
50 * Match Bootstrap records
53 int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
58 if (match_one_bsr(bsr, rec, volrec, sessrec)) {
61 return match_bsr(bsr->next, rec, volrec, sessrec);
64 static int match_one_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
66 if (strcmp(bsr->VolumeName, volrec->VolName) != 0) {
69 if (!match_volfile(bsr->volfile, rec)) {
72 if (!match_sesstime(bsr->sesstime, rec)) {
75 if (!match_sessid(bsr->sessid, rec)) {
78 if (!match_jobid(bsr->JobId, sessrec)) {
81 if (!match_job(bsr->job, sessrec)) {
84 if (!match_client(bsr->client, sessrec)) {
87 if (!match_findex(bsr->FileIndex, rec)) {
90 if (!match_job_type(bsr->JobType, sessrec)) {
93 if (!match_job_level(bsr->JobLevel, sessrec)) {
96 if (!match_stream(bsr->stream, rec)) {
102 static int match_client(BSR_CLIENT *client, SESSION_LABEL *sessrec)
105 return 1; /* no specification matches all */
107 if (fnmatch(client->ClientName, sessrec->ClientName, 0) == 0) {
111 return match_client(client->next, sessrec);
116 static int match_job(BSR_JOB *job, SESSION_LABEL *sessrec)
119 return 1; /* no specification matches all */
121 if (fnmatch(job->Job, sessrec->Job, 0) == 0) {
126 return match_job(job->next, sessrec);
132 static int match_job_type(BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec)
135 return 1; /* no specification matches all */
137 if (job_type->JobType == sessrec->JobType) {
140 if (job_type->next) {
141 return match_job_type(job_type->next, sessrec);
146 static int match_job_level(BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec)
149 return 1; /* no specification matches all */
151 if (job_level->JobLevel == sessrec->JobLevel) {
154 if (job_level->next) {
155 return match_job_level(job_level->next, sessrec);
160 static int match_jobid(BSR_JOBID *jobid, SESSION_LABEL *sessrec)
163 return 1; /* no specification matches all */
165 if (jobid->JobId <= sessrec->JobId && jobid->JobId2 >= sessrec->JobId) {
170 return match_jobid(jobid->next, sessrec);
176 static int match_volfile(BSR_VOLFILE *volfile, DEV_RECORD *rec)
179 return 1; /* no specification matches all */
181 if (volfile->sfile <= rec->File && volfile->efile >= rec->File) {
186 return match_volfile(volfile->next, rec);
191 static int match_stream(BSR_STREAM *stream, DEV_RECORD *rec)
194 return 1; /* no specification matches all */
196 if (stream->stream == rec->Stream) {
200 return match_stream(stream->next, rec);
205 static int match_findex(BSR_FINDEX *findex, DEV_RECORD *rec)
208 return 1; /* no specification matches all */
210 if (findex->findex <= rec->FileIndex && findex->findex2 >= rec->FileIndex) {
215 return match_findex(findex->next, rec);
221 static int match_sessid(BSR_SESSID *sessid, DEV_RECORD *rec)
224 return 1; /* no specification matches all */
226 if (sessid->sessid <= rec->VolSessionId && sessid->sessid2 >= rec->VolSessionId) {
231 return match_sessid(sessid->next, rec);
236 static int match_sesstime(BSR_SESSTIME *sesstime, DEV_RECORD *rec)
239 return 1; /* no specification matches all */
241 if (sesstime->sesstime == rec->VolSessionTime) {
245 if (sesstime->next) {
246 return match_sesstime(sesstime->next, rec);