From: Kern Sibbald Date: Thu, 17 Jul 2008 20:53:01 +0000 (+0000) Subject: Move setting JobLevel and JobType into a method, which should X-Git-Tag: Release-3.0.0~1137 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=ac13ec973256290f2ae56ad1c03457f8cdd1ed79;p=bacula%2Fbacula Move setting JobLevel and JobType into a method, which should allow completing Virtual Backups. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@7394 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/cats/sql_get.c b/bacula/src/cats/sql_get.c index ae306b6be4..2fe3d53cbe 100644 --- a/bacula/src/cats/sql_get.c +++ b/bacula/src/cats/sql_get.c @@ -105,8 +105,8 @@ int db_get_file_record(JCR *jcr, B_DB *mdb, JOB_DBR *jr, FILE_DBR *fdbr) int stat = 0; char ed1[50], ed2[50], ed3[50]; - if (jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { - Mmsg(mdb->cmd, + if (jcr->get_JobLevel() == L_VERIFY_DISK_TO_CATALOG) { + Mmsg(mdb->cmd, "SELECT FileId, LStat, MD5 FROM File,Job WHERE " "File.JobId=Job.JobId AND File.PathId=%s AND " "File.FilenameId=%s AND Job.Type='B' AND Job.JobSTATUS='T' AND " diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index a8651e73dd..1eaaeb10d4 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -61,7 +61,7 @@ void do_autoprune(JCR *jcr) if (jcr->job->PruneJobs || jcr->client->AutoPrune) { Jmsg(jcr, M_INFO, 0, _("Begin pruning Jobs.\n")); - prune_jobs(ua, client, jcr->JobType); + prune_jobs(ua, client, jcr->get_JobType()); pruned = true; } else { pruned = false; diff --git a/bacula/src/dird/backup.c b/bacula/src/dird/backup.c index 73cdf0fa06..ae3ee7e88e 100644 --- a/bacula/src/dird/backup.c +++ b/bacula/src/dird/backup.c @@ -65,7 +65,7 @@ static char OldEndJob[] = "2800 End Job TermCode=%d JobFiles=%u " bool do_backup_init(JCR *jcr) { - if (jcr->JobLevel == L_VIRTUAL_FULL) { + if (jcr->get_JobLevel() == L_VIRTUAL_FULL) { return do_vbackup_init(jcr); } free_rstorage(jcr); /* we don't read so release */ @@ -132,7 +132,7 @@ bool send_accurate_current_files(JCR *jcr) { POOL_MEM buf; - if (!jcr->accurate || job_canceled(jcr) || jcr->JobLevel==L_FULL) { + if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) { return true; } POOLMEM *jobids = get_pool_memory(PM_FNAME); @@ -178,7 +178,7 @@ bool do_backup(JCR *jcr) STORE *store; char ed1[100]; - if (jcr->JobLevel == L_VIRTUAL_FULL) { + if (jcr->get_JobLevel() == L_VIRTUAL_FULL) { return do_vbackup(jcr); } @@ -378,7 +378,7 @@ int wait_for_job_termination(JCR *jcr, int timeout) if (is_bnet_error(fd)) { Jmsg(jcr, M_FATAL, 0, _("Network error with FD during %s: ERR=%s\n"), - job_type_to_str(jcr->JobType), fd->bstrerror()); + job_type_to_str(jcr->get_JobType()), fd->bstrerror()); } fd->signal(BNET_TERMINATE); /* tell Client we are terminating */ } @@ -435,7 +435,7 @@ void backup_cleanup(JCR *jcr, int TermCode) double kbps, compression; utime_t RunTime; - if (jcr->JobLevel == L_VIRTUAL_FULL) { + if (jcr->get_JobLevel() == L_VIRTUAL_FULL) { vbackup_cleanup(jcr, TermCode); } @@ -573,7 +573,7 @@ void backup_cleanup(JCR *jcr, int TermCode) HOST_OS, DISTNAME, DISTVER, jcr->jr.JobId, jcr->jr.Job, - level_to_str(jcr->JobLevel), jcr->since, + level_to_str(jcr->get_JobLevel()), jcr->since, jcr->client->name(), cr.Uname, jcr->fileset->name(), jcr->FSCreateTime, jcr->pool->name(), jcr->pool_source, @@ -630,7 +630,7 @@ void update_bootstrap_file(JCR *jcr) fd = bpipe ? bpipe->wfd : NULL; } else { /* ***FIXME*** handle BASE */ - fd = fopen(fname, jcr->JobLevel==L_FULL?"w+b":"a+b"); + fd = fopen(fname, jcr->get_JobLevel()==L_FULL?"w+b":"a+b"); } if (fd) { VolCount = db_get_job_volume_parameters(jcr, jcr->db, jcr->JobId, @@ -646,7 +646,7 @@ void update_bootstrap_file(JCR *jcr) /* Start output with when and who wrote it */ bstrftimes(edt, sizeof(edt), time(NULL)); fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->jr.Job, - level_to_str(jcr->JobLevel), jcr->since); + level_to_str(jcr->get_JobLevel()), jcr->since); for (int i=0; i < VolCount; i++) { /* Write the record */ fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName); diff --git a/bacula/src/dird/dird.c b/bacula/src/dird/dird.c index 42f12216c6..959d33466c 100644 --- a/bacula/src/dird/dird.c +++ b/bacula/src/dird/dird.c @@ -507,7 +507,7 @@ void reload_config(int sig) * Hook all active jobs so that they release this table */ foreach_jcr(jcr) { - if (jcr->JobType != JT_SYSTEM) { + if (jcr->get_JobType() != JT_SYSTEM) { reload_table[table].job_count++; job_end_push(jcr, reload_job_end_cb, (void *)((long int)table)); njobs++; diff --git a/bacula/src/dird/expand.c b/bacula/src/dird/expand.c index bf1cb26ec6..85cee39a8c 100644 --- a/bacula/src/dird/expand.c +++ b/bacula/src/dird/expand.c @@ -93,10 +93,10 @@ static int job_item(JCR *jcr, int code, str = my_name; break; case 3: /* level */ - str = job_level_to_str(jcr->JobLevel); + str = job_level_to_str(jcr->get_JobLevel()); break; case 4: /* type */ - str = job_type_to_str(jcr->JobType); + str = job_type_to_str(jcr->get_JobType()); break; case 5: /* JobId */ bsnprintf(buf, sizeof(buf), "%d", jcr->JobId); diff --git a/bacula/src/dird/fd_cmds.c b/bacula/src/dird/fd_cmds.c index 7ccf327fe0..889b5d7b9f 100644 --- a/bacula/src/dird/fd_cmds.c +++ b/bacula/src/dird/fd_cmds.c @@ -184,7 +184,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) * Lookup the last FULL backup job to get the time/date for a * differential or incremental save. */ - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_DIFFERENTIAL: case L_INCREMENTAL: POOLMEM *stime = get_pool_memory(PM_MESSAGE); @@ -193,7 +193,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) jcr->jr.JobId = 0; /* flag to return since time */ have_full = db_find_job_start_time(jcr, jcr->db, &jcr->jr, &jcr->stime); /* If there was a successful job, make sure it is recent enough */ - if (jcr->JobLevel == L_INCREMENTAL && have_full && jcr->job->MaxDiffInterval > 0) { + if (jcr->get_JobLevel() == L_INCREMENTAL && have_full && jcr->job->MaxDiffInterval > 0) { /* Lookup last diff job */ if (db_find_last_job_start_time(jcr, jcr->db, &jcr->jr, &stime, L_DIFFERENTIAL)) { diff_time = str_to_utime(stime); @@ -212,22 +212,22 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) Jmsg(jcr, M_INFO, 0, "%s", db_strerror(jcr->db)); Jmsg(jcr, M_INFO, 0, _("No prior or suitable Full backup found in catalog. Doing FULL backup.\n")); bsnprintf(since, since_len, _(" (upgraded from %s)"), - level_to_str(jcr->JobLevel)); - jcr->JobLevel = jcr->jr.JobLevel = L_FULL; + level_to_str(jcr->get_JobLevel())); + jcr->set_JobLevel(jcr->jr.JobLevel = L_FULL); } else if (do_diff) { /* No recent diff job found, so upgrade this one to Full */ Jmsg(jcr, M_INFO, 0, _("No prior or suitable Differential backup found in catalog. Doing Differential backup.\n")); bsnprintf(since, since_len, _(" (upgraded from %s)"), - level_to_str(jcr->JobLevel)); - jcr->JobLevel = jcr->jr.JobLevel = L_DIFFERENTIAL; + level_to_str(jcr->get_JobLevel())); + jcr->set_JobLevel(jcr->jr.JobLevel = L_DIFFERENTIAL); } else { if (jcr->job->rerun_failed_levels) { if (db_find_failed_job_since(jcr, jcr->db, &jcr->jr, jcr->stime, JobLevel)) { Jmsg(jcr, M_INFO, 0, _("Prior failed job found in catalog. Upgrading to %s.\n"), level_to_str(JobLevel)); bsnprintf(since, since_len, _(" (upgraded from %s)"), - level_to_str(jcr->JobLevel)); - jcr->JobLevel = jcr->jr.JobLevel = JobLevel; + level_to_str(jcr->get_JobLevel())); + jcr->set_JobLevel(jcr->jr.JobLevel = JobLevel); jcr->jr.JobId = jcr->JobId; break; } @@ -238,7 +238,7 @@ void get_level_since_time(JCR *jcr, char *since, int since_len) jcr->jr.JobId = jcr->JobId; break; } - Dmsg2(100, "Level=%c last start time=%s\n", jcr->JobLevel, jcr->stime); + Dmsg2(100, "Level=%c last start time=%s\n", jcr->get_JobLevel(), jcr->stime); } static void send_since_time(JCR *jcr) @@ -266,7 +266,7 @@ bool send_level_command(JCR *jcr) /* * Send Level command to File daemon */ - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_BASE: fd->fsend(levelcmd, not_accurate, "base", " ", 0); break; @@ -286,7 +286,7 @@ bool send_level_command(JCR *jcr) case L_SINCE: default: Jmsg2(jcr, M_FATAL, 0, _("Unimplemented backup level %d %c\n"), - jcr->JobLevel, jcr->JobLevel); + jcr->get_JobLevel(), jcr->get_JobLevel()); return 0; } Dmsg1(120, ">filed: %s", fd->msg); @@ -588,7 +588,7 @@ int send_runscripts_commands(JCR *jcr) Dmsg0(120, "bdird: sending runscripts to fd\n"); foreach_alist(cmd, jcr->job->RunScripts) { - if (cmd->can_run_at_level(jcr->JobLevel) && cmd->target) { + if (cmd->can_run_at_level(jcr->get_JobLevel()) && cmd->target) { ehost = edit_job_codes(jcr, ehost, cmd->target, ""); Dmsg2(200, "bdird: runscript %s -> %s\n", cmd->target, ehost); diff --git a/bacula/src/dird/job.c b/bacula/src/dird/job.c index 1ade241b42..16a03b81ba 100644 --- a/bacula/src/dird/job.c +++ b/bacula/src/dird/job.c @@ -149,22 +149,7 @@ bool setup_job(JCR *jcr) pm_strcpy(jcr->pool_source, _("unknown source")); } - switch (jcr->JobType) { - case JT_VERIFY: - case JT_RESTORE: - case JT_COPY: - case JT_MIGRATE: - jcr->JobReads = true; - break; - case JT_BACKUP: - if (jcr->JobLevel == L_VIRTUAL_FULL) { - jcr->JobReads = true; - } - break; - default: - break; - } - if (jcr->JobReads) { + if (jcr->JobReads()) { if (!jcr->rpool_source) { jcr->rpool_source = get_pool_memory(PM_MESSAGE); pm_strcpy(jcr->rpool_source, _("unknown source")); @@ -198,7 +183,7 @@ bool setup_job(JCR *jcr) * this allows us to setup a proper job start record for restarting * in case of later errors. */ - switch (jcr->JobType) { + switch (jcr->get_JobType()) { case JT_BACKUP: if (!do_backup_init(jcr)) { backup_cleanup(jcr, JS_ErrorTerminated); @@ -226,7 +211,7 @@ bool setup_job(JCR *jcr) } break; default: - Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->JobType); + Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->get_JobType()); set_jcr_job_status(jcr, JS_ErrorTerminated); break; } @@ -309,7 +294,7 @@ static void *job_thread(void *arg) } generate_job_event(jcr, "JobRun"); - switch (jcr->JobType) { + switch (jcr->get_JobType()) { case JT_BACKUP: if (do_backup(jcr)) { do_autoprune(jcr); @@ -347,7 +332,7 @@ static void *job_thread(void *arg) } break; default: - Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->JobType); + Pmsg1(0, _("Unimplemented job type: %d\n"), jcr->get_JobType()); break; } } @@ -586,13 +571,13 @@ static bool job_check_maxruntime(JCR *jcr) watchdog_time, jcr->start_time, job->MaxRunTime, job->FullMaxRunTime, job->IncMaxRunTime, job->DiffMaxRunTime); - if (jcr->JobLevel == L_FULL && job->FullMaxRunTime != 0 && + if (jcr->get_JobLevel() == L_FULL && job->FullMaxRunTime != 0 && (watchdog_time - jcr->start_time) >= job->FullMaxRunTime) { cancel = true; - } else if (jcr->JobLevel == L_DIFFERENTIAL && job->DiffMaxRunTime != 0 && + } else if (jcr->get_JobLevel() == L_DIFFERENTIAL && job->DiffMaxRunTime != 0 && (watchdog_time - jcr->start_time) >= job->DiffMaxRunTime) { cancel = true; - } else if (jcr->JobLevel == L_INCREMENTAL && job->IncMaxRunTime != 0 && + } else if (jcr->get_JobLevel() == L_INCREMENTAL && job->IncMaxRunTime != 0 && (watchdog_time - jcr->start_time) >= job->IncMaxRunTime) { cancel = true; } else if ((watchdog_time - jcr->start_time) >= job->MaxRunTime) { @@ -718,7 +703,7 @@ void apply_pool_overrides(JCR *jcr) /* * Apply any level related Pool selections */ - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_FULL: if (jcr->full_pool) { jcr->pool = jcr->full_pool; @@ -836,8 +821,8 @@ void init_jcr_job_record(JCR *jcr) jcr->jr.SchedTime = jcr->sched_time; jcr->jr.StartTime = jcr->start_time; jcr->jr.EndTime = 0; /* perhaps rescheduled, clear it */ - jcr->jr.JobType = jcr->JobType; - jcr->jr.JobLevel = jcr->JobLevel; + jcr->jr.JobType = jcr->get_JobType(); + jcr->jr.JobLevel = jcr->get_JobLevel(); jcr->jr.JobStatus = jcr->JobStatus; jcr->jr.JobId = jcr->JobId; bstrncpy(jcr->jr.Name, jcr->job->name(), sizeof(jcr->jr.Name)); @@ -1062,15 +1047,15 @@ void get_job_storage(USTORE *store, JOB *job, RUN *run) void set_jcr_defaults(JCR *jcr, JOB *job) { jcr->job = job; - jcr->JobType = job->JobType; + jcr->set_JobType(job->JobType); jcr->JobStatus = JS_Created; - switch (jcr->JobType) { + switch (jcr->get_JobType()) { case JT_ADMIN: - jcr->JobLevel = L_NONE; + jcr->set_JobLevel(L_NONE); break; default: - jcr->JobLevel = job->JobLevel; + jcr->set_JobLevel(job->JobLevel); break; } @@ -1127,20 +1112,20 @@ void set_jcr_defaults(JCR *jcr, JOB *job) /* This can be overridden by Console program */ jcr->verify_job = job->verify_job; /* If no default level given, set one */ - if (jcr->JobLevel == 0) { - switch (jcr->JobType) { + if (jcr->get_JobLevel() == 0) { + switch (jcr->get_JobType()) { case JT_VERIFY: - jcr->JobLevel = L_VERIFY_CATALOG; + jcr->set_JobLevel(L_VERIFY_CATALOG); break; case JT_BACKUP: - jcr->JobLevel = L_INCREMENTAL; + jcr->set_JobLevel(L_INCREMENTAL); break; case JT_RESTORE: case JT_ADMIN: - jcr->JobLevel = L_NONE; + jcr->set_JobLevel(L_NONE); break; default: - jcr->JobLevel = L_FULL; + jcr->set_JobLevel(L_FULL); break; } } @@ -1151,7 +1136,7 @@ void set_jcr_defaults(JCR *jcr, JOB *job) */ void copy_rwstorage(JCR *jcr, alist *storage, const char *where) { - if (jcr->JobReads) { + if (jcr->JobReads()) { copy_rstorage(jcr, storage, where); } copy_wstorage(jcr, storage, where); @@ -1165,7 +1150,7 @@ void set_rwstorage(JCR *jcr, USTORE *store) Jmsg(jcr, M_FATAL, 0, _("No storage specified.\n")); return; } - if (jcr->JobReads) { + if (jcr->JobReads()) { set_rstorage(jcr, store); } set_wstorage(jcr, store); diff --git a/bacula/src/dird/jobq.c b/bacula/src/dird/jobq.c index 4f21b14612..bcbe85b030 100644 --- a/bacula/src/dird/jobq.c +++ b/bacula/src/dird/jobq.c @@ -612,7 +612,7 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) if (jcr->job->RescheduleOnError && jcr->JobStatus != JS_Terminated && jcr->JobStatus != JS_Canceled && - jcr->JobType == JT_BACKUP && + jcr->get_JobType() == JT_BACKUP && (jcr->job->RescheduleTimes == 0 || jcr->reschedule_count < jcr->job->RescheduleTimes)) { char dt[50], dt2[50]; @@ -656,7 +656,7 @@ static bool reschedule_job(JCR *jcr, jobq_t *jq, jobq_item_t *je) set_jcr_defaults(njcr, jcr->job); njcr->reschedule_count = jcr->reschedule_count; njcr->sched_time = jcr->sched_time; - njcr->JobLevel = jcr->JobLevel; + njcr->set_JobLevel(jcr->get_JobLevel()); njcr->pool = jcr->pool; njcr->run_pool_override = jcr->run_pool_override; njcr->full_pool = jcr->full_pool; diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index b8b8b53444..347c3840fe 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -282,7 +282,7 @@ bool do_migration(JCR *jcr) /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start %s JobId %s, Job=%s\n"), - jcr->JobType == JT_MIGRATE ? "Migration" : "Copy", + jcr->get_JobType() == JT_MIGRATE ? "Migration" : "Copy", edit_uint64(jcr->JobId, ed1), jcr->Job); @@ -392,7 +392,7 @@ bool do_migration(JCR *jcr) } migration_cleanup(jcr, jcr->JobStatus); - if (jcr->JobType == JT_MIGRATE && mig_jcr) { + if (jcr->get_JobType() == JT_MIGRATE && mig_jcr) { char jobid[50]; UAContext *ua = new_ua_context(jcr); edit_uint64(jcr->previous_jr.JobId, jobid); @@ -1075,7 +1075,7 @@ void migration_cleanup(JCR *jcr, int TermCode) db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL); /* Now mark the previous job as migrated if it terminated normally */ - if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) { + if (jcr->get_JobType() == JT_MIGRATE && jcr->JobStatus == JS_Terminated) { Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s", (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1)); db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL); @@ -1150,7 +1150,7 @@ void migration_cleanup(JCR *jcr, int TermCode) break; } } else { - if (jcr->JobType == JT_MIGRATE && jcr->previous_jr.JobId != 0) { + if (jcr->get_JobType() == JT_MIGRATE && jcr->previous_jr.JobId != 0) { /* Mark previous job as migrated */ Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s", (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1)); @@ -1206,7 +1206,7 @@ void migration_cleanup(JCR *jcr, int TermCode) mig_jcr ? edit_uint64(mig_jcr->jr.JobId, ec7) : "0", edit_uint64(jcr->jr.JobId, ec8), jcr->jr.Job, - level_to_str(jcr->JobLevel), jcr->since, + level_to_str(jcr->get_JobLevel()), jcr->since, jcr->client->name(), jcr->fileset->name(), jcr->FSCreateTime, jcr->rpool->name(), jcr->rpool_source, diff --git a/bacula/src/dird/msgchan.c b/bacula/src/dird/msgchan.c index a8199aae7a..5ab6a08125 100644 --- a/bacula/src/dird/msgchan.c +++ b/bacula/src/dird/msgchan.c @@ -184,7 +184,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore) } sd->fsend(jobcmd, edit_int64(jcr->JobId, ed1), jcr->Job, job_name.c_str(), client_name.c_str(), - jcr->JobType, jcr->JobLevel, + jcr->get_JobType(), jcr->get_JobLevel(), fileset_name.c_str(), !jcr->pool->catalog_files, jcr->job->SpoolAttributes, jcr->fileset->MD5, jcr->spool_data, jcr->write_part_after_job, jcr->job->PreferMountedVolumes, @@ -219,7 +219,7 @@ bool start_storage_daemon_job(JCR *jcr, alist *rstore, alist *wstore) /* Do read side of storage daemon */ if (ok && rstore) { /* For the moment, only migrate and copy have rpool */ - if (jcr->JobType == JT_MIGRATE || jcr->JobType == JT_COPY) { + if (jcr->get_JobType() == JT_MIGRATE || jcr->get_JobType() == JT_COPY) { pm_strcpy(pool_type, jcr->rpool->pool_type); pm_strcpy(pool_name, jcr->rpool->name()); } else { diff --git a/bacula/src/dird/pythondir.c b/bacula/src/dird/pythondir.c index 4d671968de..a6c5176629 100644 --- a/bacula/src/dird/pythondir.c +++ b/bacula/src/dird/pythondir.c @@ -140,9 +140,9 @@ PyObject *job_getattr(PyObject *self, char *attrname) case 0: /* Job */ return Py_BuildValue((char *)getvars[i].fmt, jcr->job->hdr.name); case 1: /* level */ - return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel)); + return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->get_JobLevel())); case 2: /* type */ - return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType)); + return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->get_JobType())); case 3: /* JobId */ return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId); case 4: /* Client */ @@ -296,9 +296,9 @@ int job_setattr(PyObject *self, char *attrname, PyObject *value) } for (i=0; joblevels[i].level_name; i++) { if (strcmp(strval, joblevels[i].level_name) == 0) { - if (joblevels[i].job_type == jcr->JobType) { - jcr->JobLevel = joblevels[i].level; - jcr->jr.JobLevel = jcr->JobLevel; + if (joblevels[i].job_type == jcr->get_JobType()) { + jcr->set_JobLevel(joblevels[i].level); + jcr->jr.JobLevel = jcr->get_JobLevel(); return 0; } } diff --git a/bacula/src/dird/scheduler.c b/bacula/src/dird/scheduler.c index 7f24fb5c99..bf2f857b13 100644 --- a/bacula/src/dird/scheduler.c +++ b/bacula/src/dird/scheduler.c @@ -200,7 +200,7 @@ again: ASSERT(job); set_jcr_defaults(jcr, job); if (run->level) { - jcr->JobLevel = run->level; /* override run level */ + jcr->set_JobLevel(run->level); /* override run level */ } if (run->pool) { jcr->pool = run->pool; /* override pool */ diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 5fbb09ab9e..84b2b90fbd 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1073,7 +1073,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) char since[MAXSTRING]; JCR *jcr = ua->jcr; - jcr->JobLevel = L_FULL; + jcr->set_JobLevel(L_FULL); for (int i=1; iargc; i++) { if (strcasecmp(ua->argk[i], NT_("client")) == 0 || strcasecmp(ua->argk[i], NT_("fd")) == 0) { @@ -1161,7 +1161,7 @@ static int estimate_cmd(UAContext *ua, const char *cmd) } jcr->job = job; - jcr->JobType = JT_BACKUP; + jcr->set_JobType(JT_BACKUP); init_jcr_job_record(jcr); if (!get_or_create_client_record(jcr)) { diff --git a/bacula/src/dird/ua_run.c b/bacula/src/dird/ua_run.c index 22d0683832..6112a6ea95 100644 --- a/bacula/src/dird/ua_run.c +++ b/bacula/src/dird/ua_run.c @@ -207,29 +207,29 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc) add_prompt(ua, _("Storage")); /* 1 */ add_prompt(ua, _("Job")); /* 2 */ add_prompt(ua, _("FileSet")); /* 3 */ - if (jcr->JobType == JT_RESTORE) { + if (jcr->get_JobType() == JT_RESTORE) { add_prompt(ua, _("Restore Client")); /* 4 */ } else { add_prompt(ua, _("Client")); /* 4 */ } add_prompt(ua, _("When")); /* 5 */ add_prompt(ua, _("Priority")); /* 6 */ - if (jcr->JobType == JT_BACKUP || - jcr->JobType == JT_COPY || - jcr->JobType == JT_MIGRATE || - jcr->JobType == JT_VERIFY) { + if (jcr->get_JobType() == JT_BACKUP || + jcr->get_JobType() == JT_COPY || + jcr->get_JobType() == JT_MIGRATE || + jcr->get_JobType() == JT_VERIFY) { add_prompt(ua, _("Pool")); /* 7 */ - if (jcr->JobType == JT_VERIFY) { + if (jcr->get_JobType() == JT_VERIFY) { add_prompt(ua, _("Verify Job")); /* 8 */ } - } else if (jcr->JobType == JT_RESTORE) { + } else if (jcr->get_JobType() == JT_RESTORE) { add_prompt(ua, _("Bootstrap")); /* 7 */ add_prompt(ua, _("Where")); /* 8 */ add_prompt(ua, _("File Relocation"));/* 9 */ add_prompt(ua, _("Replace")); /* 10 */ add_prompt(ua, _("JobId")); /* 11 */ } - if (jcr->JobType == JT_BACKUP || jcr->JobType == JT_RESTORE) { + if (jcr->get_JobType() == JT_BACKUP || jcr->get_JobType() == JT_RESTORE) { add_prompt(ua, _("Plugin Options")); /* 12 */ } switch (do_prompt(ua, "", _("Select parameter to modify"), NULL, 0)) { @@ -299,10 +299,10 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc) goto try_again; case 7: /* Pool or Bootstrap depending on JobType */ - if (jcr->JobType == JT_BACKUP || - jcr->JobType == JT_COPY || - jcr->JobType == JT_MIGRATE || - jcr->JobType == JT_VERIFY) { /* Pool */ + if (jcr->get_JobType() == JT_BACKUP || + jcr->get_JobType() == JT_COPY || + jcr->get_JobType() == JT_MIGRATE || + jcr->get_JobType() == JT_VERIFY) { /* Pool */ rc.pool = select_pool_resource(ua); if (rc.pool) { jcr->pool = rc.pool; @@ -336,7 +336,7 @@ int modify_job_parameters(UAContext *ua, JCR *jcr, run_ctx &rc) goto try_again; case 8: /* Verify Job */ - if (jcr->JobType == JT_VERIFY) { + if (jcr->get_JobType() == JT_VERIFY) { rc.verify_job = select_job_resource(ua); if (rc.verify_job) { jcr->verify_job = rc.verify_job; @@ -515,7 +515,8 @@ static bool reset_restore_context(UAContext *ua, JCR *jcr, run_ctx &rc) /* If pool changed, update migration write storage */ - if (jcr->JobType == JT_MIGRATE || jcr->JobType == JT_COPY) { + if (jcr->get_JobType() == JT_MIGRATE || jcr->get_JobType() == JT_COPY || + (jcr->get_JobType() == JT_BACKUP && jcr->get_JobLevel() == L_VIRTUAL_FULL)) { if (!set_migration_wstorage(jcr, rc.pool)) { return false; } @@ -676,7 +677,7 @@ bail_out_reg: static void select_job_level(UAContext *ua, JCR *jcr) { - if (jcr->JobType == JT_BACKUP) { + if (jcr->get_JobType() == JT_BACKUP) { start_prompt(ua, _("Levels:\n")); // add_prompt(ua, _("Base")); add_prompt(ua, _("Full")); @@ -689,24 +690,24 @@ static void select_job_level(UAContext *ua, JCR *jcr) // jcr->JobLevel = L_BASE; // break; case 0: - jcr->JobLevel = L_FULL; + jcr->set_JobLevel(L_FULL); break; case 1: - jcr->JobLevel = L_INCREMENTAL; + jcr->set_JobLevel(L_INCREMENTAL); break; case 2: - jcr->JobLevel = L_DIFFERENTIAL; + jcr->set_JobLevel(L_DIFFERENTIAL); break; case 3: - jcr->JobLevel = L_SINCE; + jcr->set_JobLevel(L_SINCE); break; case 4: - jcr->JobLevel = L_VIRTUAL_FULL; + jcr->set_JobLevel(L_VIRTUAL_FULL); break; default: break; } - } else if (jcr->JobType == JT_VERIFY) { + } else if (jcr->get_JobType() == JT_VERIFY) { start_prompt(ua, _("Levels:\n")); add_prompt(ua, _("Initialize Catalog")); add_prompt(ua, _("Verify Catalog")); @@ -715,19 +716,19 @@ static void select_job_level(UAContext *ua, JCR *jcr) add_prompt(ua, _("Verify Volume Data (not yet implemented)")); switch (do_prompt(ua, "", _("Select level"), NULL, 0)) { case 0: - jcr->JobLevel = L_VERIFY_INIT; + jcr->set_JobLevel(L_VERIFY_INIT); break; case 1: - jcr->JobLevel = L_VERIFY_CATALOG; + jcr->set_JobLevel(L_VERIFY_CATALOG); break; case 2: - jcr->JobLevel = L_VERIFY_VOLUME_TO_CATALOG; + jcr->set_JobLevel(L_VERIFY_VOLUME_TO_CATALOG); break; case 3: - jcr->JobLevel = L_VERIFY_DISK_TO_CATALOG; + jcr->set_JobLevel(L_VERIFY_DISK_TO_CATALOG); break; case 4: - jcr->JobLevel = L_VERIFY_DATA; + jcr->set_JobLevel(L_VERIFY_DATA); break; default: break; @@ -741,8 +742,8 @@ static void select_job_level(UAContext *ua, JCR *jcr) static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char *verify_list, char *jid, const char *replace, char *client_name) { - Dmsg1(800, "JobType=%c\n", jcr->JobType); - switch (jcr->JobType) { + Dmsg1(800, "JobType=%c\n", jcr->get_JobType()); + switch (jcr->get_JobType()) { char ec1[30]; char dt[MAX_TIME_LENGTH]; case JT_ADMIN: @@ -761,11 +762,11 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char jcr->wstore?jcr->wstore->name():"*None*", bstrutime(dt, sizeof(dt), jcr->sched_time), jcr->JobPriority); - jcr->JobLevel = L_FULL; + jcr->set_JobLevel(L_FULL); break; case JT_BACKUP: case JT_VERIFY: - if (jcr->JobType == JT_BACKUP) { + if (jcr->get_JobType() == JT_BACKUP) { if (ua->api) ua->signal(BNET_RUN_CMD); ua->send_msg(_("Run %s job\n" "JobName: %s\n" @@ -779,7 +780,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char "%s%s%s"), _("Backup"), job->name(), - level_to_str(jcr->JobLevel), + level_to_str(jcr->get_JobLevel()), jcr->client->name(), jcr->fileset->name(), NPRT(jcr->pool->name()), jcr->pool_source, @@ -816,7 +817,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char "Priority: %d\n"), _("Verify"), job->name(), - level_to_str(jcr->JobLevel), + level_to_str(jcr->get_JobLevel()), jcr->client->name(), jcr->fileset->name(), NPRT(jcr->pool->name()), jcr->pool_source, @@ -838,7 +839,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char jcr->RestoreJobId = ua->int64_val; } } - jcr->JobLevel = L_FULL; /* default level */ + jcr->set_JobLevel(L_FULL); /* default level */ Dmsg1(800, "JobId to restore=%d\n", jcr->RestoreJobId); if (jcr->RestoreJobId == 0) { if (ua->api) ua->signal(BNET_RUN_CMD); @@ -936,12 +937,12 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char case JT_COPY: case JT_MIGRATE: char *prt_type; - if (jcr->JobType == JT_COPY) { + if (jcr->get_JobType() == JT_COPY) { prt_type = _("Run Copy job\n"); } else { prt_type = _("Run Migration job\n"); } - jcr->JobLevel = L_FULL; /* default level */ + jcr->set_JobLevel(L_FULL); /* default level */ if (ua->api) ua->signal(BNET_RUN_CMD); ua->send_msg("%s" "JobName: %s\n" @@ -969,7 +970,7 @@ static bool display_job_parameters(UAContext *ua, JCR *jcr, JOB *job, const char jcr->JobPriority); break; default: - ua->error_msg(_("Unknown Job Type=%d\n"), jcr->JobType); + ua->error_msg(_("Unknown Job Type=%d\n"), jcr->get_JobType()); return false; } return true; diff --git a/bacula/src/dird/ua_select.c b/bacula/src/dird/ua_select.c index 22601ad675..749afd4c81 100644 --- a/bacula/src/dird/ua_select.c +++ b/bacula/src/dird/ua_select.c @@ -1,7 +1,7 @@ /* Bacula® - The Network Backup Solution - Copyright (C) 2001-2007 Free Software Foundation Europe e.V. + Copyright (C) 2001-2008 Free Software Foundation Europe e.V. The main author of Bacula is Kern Sibbald, with contributions from many others, a complete list can be found in the file AUTHORS. @@ -1013,7 +1013,7 @@ bool get_level_from_name(JCR *jcr, const char *level_name) bool found = false; for (int i=0; joblevels[i].level_name; i++) { if (strcasecmp(level_name, joblevels[i].level_name) == 0) { - jcr->JobLevel = joblevels[i].level; + jcr->set_JobLevel(joblevels[i].level); found = true; break; } diff --git a/bacula/src/dird/ua_server.c b/bacula/src/dird/ua_server.c index 23b8289181..34c4b89c61 100644 --- a/bacula/src/dird/ua_server.c +++ b/bacula/src/dird/ua_server.c @@ -102,8 +102,8 @@ JCR *new_control_jcr(const char *base_name, int job_type) jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */ create_unique_job_name(jcr, base_name); jcr->sched_time = jcr->start_time; - jcr->JobType = job_type; - jcr->JobLevel = L_NONE; + jcr->set_JobType(job_type); + jcr->set_JobLevel(L_NONE); set_jcr_job_status(jcr, JS_Running); jcr->JobId = 0; return jcr; diff --git a/bacula/src/dird/ua_status.c b/bacula/src/dird/ua_status.c index 94c2f518b4..473853b3b4 100644 --- a/bacula/src/dird/ua_status.c +++ b/bacula/src/dird/ua_status.c @@ -158,11 +158,11 @@ int status_cmd(UAContext *ua, const char *cmd) } else { store = get_storage_resource(ua, false/*no default*/); if (store) { - if (find_arg(ua, NT_("slots")) > 0) { - status_slots(ua, store); - } else { - do_storage_status(ua, store, NULL); - } + if (find_arg(ua, NT_("slots")) > 0) { + status_slots(ua, store); + } else { + do_storage_status(ua, store, NULL); + } } return 1; } @@ -439,7 +439,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) MEDIA_DBR mr; int orig_jobtype; - orig_jobtype = jcr->JobType; + orig_jobtype = jcr->get_JobType(); memset(&mr, 0, sizeof(mr)); if (sp->job->JobType == JT_BACKUP) { jcr->db = NULL; @@ -482,7 +482,7 @@ static void prt_runtime(UAContext *ua, sched_pkt *sp) db_close_database(jcr, jcr->db); } jcr->db = ua->db; /* restore ua db to jcr */ - jcr->JobType = orig_jobtype; + jcr->set_JobType(orig_jobtype); } /* @@ -594,7 +594,7 @@ static void list_running_jobs(UAContext *ua) /* this is a console or other control job. We only show console * jobs in the status output. */ - if (jcr->JobType == JT_CONSOLE && !ua->api) { + if (jcr->get_JobType() == JT_CONSOLE && !ua->api) { bstrftime_nc(dt, sizeof(dt), jcr->start_time); ua->send_msg(_("Console connected at %s\n"), dt); } @@ -752,13 +752,13 @@ static void list_running_jobs(UAContext *ua) msg = _("Dir inserting Attributes"); break; } - switch (jcr->JobType) { + switch (jcr->get_JobType()) { case JT_ADMIN: case JT_RESTORE: bstrncpy(level, " ", sizeof(level)); break; default: - bstrncpy(level, level_to_str(jcr->JobLevel), sizeof(level)); + bstrncpy(level, level_to_str(jcr->get_JobLevel()), sizeof(level)); level[7] = 0; break; } diff --git a/bacula/src/dird/vbackup.c b/bacula/src/dird/vbackup.c index 3c82b4fe6c..8f735ca1f9 100644 --- a/bacula/src/dird/vbackup.c +++ b/bacula/src/dird/vbackup.c @@ -258,7 +258,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode) memset(&mr, 0, sizeof(mr)); memset(&cr, 0, sizeof(cr)); - jcr->JobLevel = L_FULL; /* we want this to appear as a Full backup */ + jcr->set_JobLevel(L_FULL); /* we want this to appear as a Full backup */ jcr->jr.JobLevel = L_FULL; /* we want this to appear as a Full backup */ jcr->JobFiles = jcr->SDJobFiles; jcr->JobBytes = jcr->SDJobBytes; @@ -399,7 +399,7 @@ void vbackup_cleanup(JCR *jcr, int TermCode) HOST_OS, DISTNAME, DISTVER, jcr->jr.JobId, jcr->jr.Job, - level_to_str(jcr->JobLevel), jcr->since, + level_to_str(jcr->get_JobLevel()), jcr->since, jcr->client->name(), cr.Uname, jcr->fileset->name(), jcr->FSCreateTime, jcr->pool->name(), jcr->pool_source, diff --git a/bacula/src/dird/verify.c b/bacula/src/dird/verify.c index 50e4491e21..b05846d886 100644 --- a/bacula/src/dird/verify.c +++ b/bacula/src/dird/verify.c @@ -69,7 +69,7 @@ bool do_verify_init(JCR *jcr) if (!allow_duplicate_job(jcr)) { return false; } - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_VERIFY_INIT: case L_VERIFY_CATALOG: case L_VERIFY_DISK_TO_CATALOG: @@ -82,8 +82,8 @@ bool do_verify_init(JCR *jcr) case L_VERIFY_DATA: break; default: - Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->JobLevel, - jcr->JobLevel); + Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->get_JobLevel(), + jcr->get_JobLevel()); return false; } return true; @@ -122,20 +122,20 @@ bool do_verify(JCR *jcr) * For VERIFY_VOLUME_TO_CATALOG, we want the JobId of the * last backup Job. */ - if (jcr->JobLevel == L_VERIFY_CATALOG || - jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || - jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_CATALOG || + jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG || + jcr->get_JobLevel() == L_VERIFY_DISK_TO_CATALOG) { memcpy(&jr, &jcr->jr, sizeof(jr)); if (jcr->verify_job && - (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || - jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG)) { + (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG || + jcr->get_JobLevel() == L_VERIFY_DISK_TO_CATALOG)) { Name = jcr->verify_job->name(); } else { Name = NULL; } Dmsg1(100, "find last jobid for: %s\n", NPRT(Name)); if (!db_find_last_jobid(jcr, jcr->db, Name, &jr)) { - if (jcr->JobLevel == L_VERIFY_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_CATALOG) { Jmsg(jcr, M_FATAL, 0, _( "Unable to find JobId of previous InitCatalog Job.\n" "Please run a Verify with Level=InitCatalog before\n" @@ -153,9 +153,9 @@ bool do_verify(JCR *jcr) * Now get the job record for the previous backup that interests * us. We use the verify_jobid that we found above. */ - if (jcr->JobLevel == L_VERIFY_CATALOG || - jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG || - jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_CATALOG || + jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG || + jcr->get_JobLevel() == L_VERIFY_DISK_TO_CATALOG) { jcr->previous_jr.JobId = verify_jobid; if (!db_get_job_record(jcr, jcr->db, &jcr->previous_jr)) { Jmsg(jcr, M_FATAL, 0, _("Could not get job record for previous Job. ERR=%s"), @@ -177,7 +177,7 @@ bool do_verify(JCR *jcr) * create a dummy authorization key (passed to * File daemon but not used). */ - if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG) { if (!create_restore_bootstrap_file(jcr)) { return false; } @@ -185,10 +185,10 @@ bool do_verify(JCR *jcr) jcr->sd_auth_key = bstrdup("dummy"); /* dummy Storage daemon key */ } - if (jcr->JobLevel == L_VERIFY_DISK_TO_CATALOG && jcr->verify_job) { + if (jcr->get_JobLevel() == L_VERIFY_DISK_TO_CATALOG && jcr->verify_job) { jcr->fileset = jcr->verify_job->fileset; } - Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, jcr->JobLevel); + Dmsg2(100, "ClientId=%u JobLevel=%c\n", jcr->previous_jr.ClientId, jcr->get_JobLevel()); if (!db_update_job_start_record(jcr, jcr->db, &jcr->jr)) { Jmsg(jcr, M_FATAL, 0, "%s", db_strerror(jcr->db)); @@ -197,9 +197,9 @@ bool do_verify(JCR *jcr) /* Print Job Start message */ Jmsg(jcr, M_INFO, 0, _("Start Verify JobId=%s Level=%s Job=%s\n"), - edit_uint64(jcr->JobId, ed1), level_to_str(jcr->JobLevel), jcr->Job); + edit_uint64(jcr->JobId, ed1), level_to_str(jcr->get_JobLevel()), jcr->Job); - if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG) { /* * Start conversation with Storage daemon */ @@ -252,7 +252,7 @@ bool do_verify(JCR *jcr) * Send Level command to File daemon, as well * as the Storage address if appropriate. */ - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_VERIFY_INIT: level = "init"; break; @@ -293,8 +293,8 @@ bool do_verify(JCR *jcr) level="disk_to_catalog"; break; default: - Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->JobLevel, - jcr->JobLevel); + Jmsg2(jcr, M_FATAL, 0, _("Unimplemented Verify level %d(%c)\n"), jcr->get_JobLevel(), + jcr->get_JobLevel()); goto bail_out; } @@ -316,7 +316,7 @@ bool do_verify(JCR *jcr) * catalog depending on the run type. */ /* Compare to catalog */ - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_VERIFY_CATALOG: Dmsg0(10, "Verify level=catalog\n"); jcr->sd_msg_thread_done = true; /* no SD msg thread, so it is done */ @@ -347,7 +347,7 @@ bool do_verify(JCR *jcr) break; default: - Jmsg1(jcr, M_FATAL, 0, _("Unimplemented verify level %d\n"), jcr->JobLevel); + Jmsg1(jcr, M_FATAL, 0, _("Unimplemented verify level %d\n"), jcr->get_JobLevel()); goto bail_out; } @@ -376,15 +376,15 @@ void verify_cleanup(JCR *jcr, int TermCode) // Dmsg1(100, "Enter verify_cleanup() TermCod=%d\n", TermCode); - Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", jcr->JobLevel, + Dmsg3(900, "JobLevel=%c Expected=%u JobFiles=%u\n", jcr->get_JobLevel(), jcr->ExpectedFiles, jcr->JobFiles); - if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG && + if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG && jcr->ExpectedFiles != jcr->JobFiles) { TermCode = JS_ErrorTerminated; } /* If no files were expected, there can be no error */ - if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG && + if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG && jcr->ExpectedFiles == 0) { TermCode = JS_Terminated; } @@ -436,7 +436,7 @@ void verify_cleanup(JCR *jcr, int TermCode) } jobstatus_to_ascii(jcr->FDJobStatus, fd_term_msg, sizeof(fd_term_msg)); - if (jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG) { + if (jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG) { jobstatus_to_ascii(jcr->SDJobStatus, sd_term_msg, sizeof(sd_term_msg)); Jmsg(jcr, msg_type, 0, _("Bacula %s %s (%s): %s\n" " Build OS: %s %s %s\n" @@ -460,7 +460,7 @@ void verify_cleanup(JCR *jcr, int TermCode) jcr->jr.JobId, jcr->jr.Job, jcr->fileset->hdr.name, - level_to_str(jcr->JobLevel), + level_to_str(jcr->get_JobLevel()), jcr->client->hdr.name, jcr->previous_jr.JobId, Name, @@ -493,7 +493,7 @@ void verify_cleanup(JCR *jcr, int TermCode) jcr->jr.JobId, jcr->jr.Job, jcr->fileset->hdr.name, - level_to_str(jcr->JobLevel), + level_to_str(jcr->get_JobLevel()), jcr->client->name(), jcr->previous_jr.JobId, Name, @@ -788,7 +788,7 @@ static int missing_handler(void *ctx, int num_fields, char **row) } if (!jcr->fn_printed) { Qmsg(jcr, M_INFO, 0, _("\nThe following files are in the Catalog but not on %s:\n"), - jcr->JobLevel == L_VERIFY_VOLUME_TO_CATALOG ? "the Volume(s)" : "disk"); + jcr->get_JobLevel() == L_VERIFY_VOLUME_TO_CATALOG ? "the Volume(s)" : "disk"); jcr->fn_printed = true; } Qmsg(jcr, M_INFO, 0, " %s%s\n", row[0]?row[0]:"", row[1]?row[1]:""); diff --git a/bacula/src/filed/accurate.c b/bacula/src/filed/accurate.c index 8912805784..fd396c251e 100644 --- a/bacula/src/filed/accurate.c +++ b/bacula/src/filed/accurate.c @@ -39,14 +39,14 @@ typedef struct PrivateCurFile { #ifndef USE_TCADB hlink link; #endif - char *fname; /* not stored with tchdb mode */ + char *fname; /* not stored with tchdb mode */ time_t ctime; time_t mtime; bool seen; } CurFile; #ifdef USE_TCADB -static void realfree(void *p); /* used by tokyo code */ +static void realfree(void *p); /* used by tokyo code */ /* * Update hash element seen=1 @@ -57,8 +57,8 @@ static bool accurate_mark_file_as_seen(JCR *jcr, CurFile *elt) elt->seen = 1; if (!tcadbput(jcr->file_list, - elt->fname, strlen(elt->fname)+1, - elt, sizeof(CurFile))) + elt->fname, strlen(elt->fname)+1, + elt, sizeof(CurFile))) { /* TODO: disabling accurate mode ? */ Jmsg(jcr, M_ERROR, 1, _("Can't update accurate hash disk\n")); ret = false; @@ -75,7 +75,7 @@ static bool accurate_lookup(JCR *jcr, char *fname, CurFile *ret) CurFile *elt; elt = (CurFile*)tcadbget(jcr->file_list, - fname, strlen(fname)+1, &size); + fname, strlen(fname)+1, &size); if (elt) { /* TODO: don't malloc/free results */ @@ -97,10 +97,10 @@ static bool accurate_init(JCR *jcr, int nbfile) // // tchdbsetcache(jcr->file_list, 300000); // tchdbtune(jcr->file_list, -// nbfile, /* nb bucket 0.5n to 4n */ -// 6, /* size of element 2^x */ -// 16, -// 0); /* options like compression */ +// nbfile, /* nb bucket 0.5n to 4n */ +// 6, /* size of element 2^x */ +// 16, +// 0); /* options like compression */ // jcr->hash_name = get_pool_memory(PM_MESSAGE); POOLMEM *temp = get_pool_memory(PM_MESSAGE); @@ -109,7 +109,7 @@ static bool accurate_init(JCR *jcr, int nbfile) make_unique_filename(&jcr->hash_name, jcr->JobId, "accurate"); pm_strcat(jcr->hash_name, ".tcb"); Mmsg(temp, "%s#bnum=%i#mode=e#opts=l", - jcr->hash_name, nbfile*4); + jcr->hash_name, nbfile*4); Dmsg1(dbglvl, "Doing accurate hash on disk %s\n", jcr->hash_name); } else { Dmsg0(dbglvl, "Doing accurate hash on memory\n"); @@ -140,7 +140,7 @@ bool accurate_send_deleted_list(JCR *jcr) FF_PKT *ff_pkt; int stream = STREAM_UNIX_ATTRIBUTES; - if (!jcr->accurate || jcr->JobLevel == L_FULL) { + if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) { goto bail_out; } @@ -155,18 +155,18 @@ bool accurate_send_deleted_list(JCR *jcr) tcadbiterinit(jcr->file_list); while((key = tcadbiternext2(jcr->file_list)) != NULL) { elt = (CurFile *) tcadbget(jcr->file_list, - key, strlen(key)+1, &size); + key, strlen(key)+1, &size); if (elt) { - if (!elt->seen) { /* already seen */ - ff_pkt->fname = key; - ff_pkt->statp.st_mtime = elt->mtime; - ff_pkt->statp.st_ctime = elt->ctime; - encode_and_send_attributes(jcr, ff_pkt, stream); - } - realfree(elt); + if (!elt->seen) { /* already seen */ + ff_pkt->fname = key; + ff_pkt->statp.st_mtime = elt->mtime; + ff_pkt->statp.st_ctime = elt->ctime; + encode_and_send_attributes(jcr, ff_pkt, stream); + } + realfree(elt); } - realfree(key); /* tokyo cabinet have to use real free() */ + realfree(key); /* tokyo cabinet have to use real free() */ } term_find_files(ff_pkt); @@ -174,13 +174,13 @@ bail_out: /* TODO: clean htable when this function is not reached ? */ if (jcr->file_list) { if(!tcadbclose(jcr->file_list)){ - Jmsg(jcr, M_ERROR, 1, _("Can't close accurate hash disk\n")); + Jmsg(jcr, M_ERROR, 1, _("Can't close accurate hash disk\n")); } /* delete the object */ tcadbdel(jcr->file_list); if (!bstrcmp(jcr->hash_name, "*")) { - unlink(jcr->hash_name); + unlink(jcr->hash_name); } free_pool_memory(jcr->hash_name); @@ -195,7 +195,7 @@ bail_out: static bool accurate_mark_file_as_seen(JCR *jcr, CurFile *elt) { CurFile *temp = (CurFile *)jcr->file_list->lookup(elt->fname); - temp->seen = 1; /* records are in memory */ + temp->seen = 1; /* records are in memory */ return true; } @@ -232,7 +232,7 @@ bool accurate_send_deleted_list(JCR *jcr) FF_PKT *ff_pkt; int stream = STREAM_UNIX_ATTRIBUTES; - if (!jcr->accurate || jcr->JobLevel == L_FULL) { + if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) { goto bail_out; } @@ -280,8 +280,8 @@ static bool accurate_add_file(JCR *jcr, char *fname, char *lstat) #ifdef USE_TCADB if (!tcadbput(jcr->file_list, - fname, strlen(fname)+1, - &elt, sizeof(CurFile))) + fname, strlen(fname)+1, + &elt, sizeof(CurFile))) { Jmsg(jcr, M_ERROR, 1, _("Can't update accurate hash disk ERR=%s\n")); ret = false; @@ -312,7 +312,7 @@ bool accurate_check_file(JCR *jcr, FF_PKT *ff_pkt) char *fname; CurFile elt; - if (!jcr->accurate || jcr->JobLevel == L_FULL) { + if (!jcr->accurate || jcr->get_JobLevel() == L_FULL) { return true; } @@ -360,7 +360,7 @@ int accurate_cmd(JCR *jcr) int len; int32_t nb; - if (!jcr->accurate || job_canceled(jcr) || jcr->JobLevel==L_FULL) { + if (!jcr->accurate || job_canceled(jcr) || jcr->get_JobLevel()==L_FULL) { return true; } @@ -379,7 +379,7 @@ int accurate_cmd(JCR *jcr) while (dir->recv() >= 0) { len = strlen(dir->msg) + 1; if (len < dir->msglen) { - accurate_add_file(jcr, dir->msg, dir->msg + len); + accurate_add_file(jcr, dir->msg, dir->msg + len); } } diff --git a/bacula/src/filed/job.c b/bacula/src/filed/job.c index 5d6cb1d087..5025a9a32a 100644 --- a/bacula/src/filed/job.c +++ b/bacula/src/filed/job.c @@ -1235,16 +1235,16 @@ static int level_cmd(JCR *jcr) } /* Base backup requested? */ if (strcmp(level, "base") == 0) { - jcr->JobLevel = L_BASE; + jcr->set_JobLevel(L_BASE); /* Full backup requested? */ } else if (strcmp(level, "full") == 0) { - jcr->JobLevel = L_FULL; + jcr->set_JobLevel(L_FULL); } else if (strstr(level, "differential")) { - jcr->JobLevel = L_DIFFERENTIAL; + jcr->set_JobLevel(L_DIFFERENTIAL); free_memory(level); return 1; } else if (strstr(level, "incremental")) { - jcr->JobLevel = L_INCREMENTAL; + jcr->set_JobLevel(L_INCREMENTAL); free_memory(level); return 1; /* @@ -1255,8 +1255,8 @@ static int level_cmd(JCR *jcr) buf = get_memory(dir->msglen+1); utime_t since_time, adj; btime_t his_time, bt_start, rt=0, bt_adj=0; - if (jcr->JobLevel == L_NONE) { - jcr->JobLevel = L_SINCE; /* if no other job level set, do it now */ + if (jcr->get_JobLevel() == L_NONE) { + jcr->set_JobLevel(L_SINCE); /* if no other job level set, do it now */ } if (sscanf(dir->msg, "level = since_utime %s mtime_only=%d", buf, &mtime_only) != 2) { @@ -1318,7 +1318,7 @@ static int level_cmd(JCR *jcr) if (buf) { free_memory(buf); } - generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel); + generate_plugin_event(jcr, bEventLevel, (void *)jcr->get_JobLevel()); return dir->fsend(OKlevel); bail_out: @@ -1418,7 +1418,7 @@ static int backup_cmd(JCR *jcr) #endif set_jcr_job_status(jcr, JS_Blocked); - jcr->JobType = JT_BACKUP; + jcr->set_JobType(JT_BACKUP); Dmsg1(100, "begin backup ff=%p\n", jcr->ff); if (sd == NULL) { @@ -1592,22 +1592,22 @@ static int verify_cmd(JCR *jcr) BSOCK *sd = jcr->store_bsock; char level[100]; - jcr->JobType = JT_VERIFY; + jcr->set_JobType(JT_VERIFY); if (sscanf(dir->msg, verifycmd, level) != 1) { dir->fsend(_("2994 Bad verify command: %s\n"), dir->msg); return 0; } if (strcasecmp(level, "init") == 0) { - jcr->JobLevel = L_VERIFY_INIT; + jcr->set_JobLevel(L_VERIFY_INIT); } else if (strcasecmp(level, "catalog") == 0){ - jcr->JobLevel = L_VERIFY_CATALOG; + jcr->set_JobLevel(L_VERIFY_CATALOG); } else if (strcasecmp(level, "volume") == 0){ - jcr->JobLevel = L_VERIFY_VOLUME_TO_CATALOG; + jcr->set_JobLevel(L_VERIFY_VOLUME_TO_CATALOG); } else if (strcasecmp(level, "data") == 0){ - jcr->JobLevel = L_VERIFY_DATA; + jcr->set_JobLevel(L_VERIFY_DATA); } else if (strcasecmp(level, "disk_to_catalog") == 0) { - jcr->JobLevel = L_VERIFY_DISK_TO_CATALOG; + jcr->set_JobLevel(L_VERIFY_DISK_TO_CATALOG); } else { dir->fsend(_("2994 Bad verify level: %s\n"), dir->msg); return 0; @@ -1616,12 +1616,12 @@ static int verify_cmd(JCR *jcr) dir->fsend(OKverify); generate_daemon_event(jcr, "JobStart"); - generate_plugin_event(jcr, bEventLevel, (void *)jcr->JobLevel); + generate_plugin_event(jcr, bEventLevel, (void *)jcr->get_JobLevel()); generate_plugin_event(jcr, bEventStartVerifyJob); Dmsg1(110, "bfiled>dird: %s", dir->msg); - switch (jcr->JobLevel) { + switch (jcr->get_JobLevel()) { case L_VERIFY_INIT: case L_VERIFY_CATALOG: do_verify(jcr); @@ -1717,7 +1717,7 @@ static int restore_cmd(JCR *jcr) dir->fsend(OKrestore); Dmsg1(110, "bfiled>dird: %s", dir->msg); - jcr->JobType = JT_RESTORE; + jcr->set_JobType(JT_RESTORE); set_jcr_job_status(jcr, JS_Blocked); diff --git a/bacula/src/filed/pythonfd.c b/bacula/src/filed/pythonfd.c index e9e10808f9..d9c1841394 100644 --- a/bacula/src/filed/pythonfd.c +++ b/bacula/src/filed/pythonfd.c @@ -111,9 +111,9 @@ PyObject *job_getattr(PyObject *self, char *attrname) case 0: /* FD's name */ return Py_BuildValue((char *)getvars[i].fmt, my_name); case 1: /* level */ - return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel)); + return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->get_JobLevel())); case 2: /* type */ - return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType)); + return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->get_JobType())); case 3: /* JobId */ return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId); case 4: /* Client */ diff --git a/bacula/src/filed/status.c b/bacula/src/filed/status.c index 639be0f375..4461a66f57 100644 --- a/bacula/src/filed/status.c +++ b/bacula/src/filed/status.c @@ -177,7 +177,7 @@ static void list_running_jobs(STATUS_PKT *sp) njcr->JobId, njcr->Job); sendit(msg.c_str(), len, sp); len = Mmsg(msg, _(" %s%s Job started: %s\n"), - vss, job_type_to_str(njcr->JobType), dt); + vss, job_type_to_str(njcr->get_JobType()), dt); } sendit(msg.c_str(), len, sp); if (njcr->JobId == 0) { diff --git a/bacula/src/jcr.h b/bacula/src/jcr.h index 6abd924089..6e8ce94faf 100644 --- a/bacula/src/jcr.h +++ b/bacula/src/jcr.h @@ -166,6 +166,8 @@ class JCR { private: pthread_mutex_t mutex; /* jcr mutex */ volatile int32_t _use_count; /* use count */ + int32_t m_JobType; /* backup, restore, verify ... */ + int32_t m_JobLevel; /* Job level */ public: void lock() {P(mutex); }; void unlock() {V(mutex); }; @@ -175,6 +177,12 @@ public: void init_mutex(void) {pthread_mutex_init(&mutex, NULL); }; void destroy_mutex(void) {pthread_mutex_destroy(&mutex); }; bool is_job_canceled() {return job_canceled(this); }; + int32_t get_JobType() { return m_JobType; }; + int32_t get_JobLevel() { return m_JobLevel; }; + + void set_JobLevel(int32_t JobLevel); /* in lib/jcr.c */ + void set_JobType(int32_t JobType); /* in lib/jcr.c */ + bool JobReads(); /* in lib/jcr.c */ /* Global part of JCR common to all daemons */ dlink link; /* JCR chain link */ @@ -199,10 +207,7 @@ public: uint64_t ReadBytes; /* Bytes read -- before compression */ uint32_t Errors; /* Number of non-fatal errors */ volatile int32_t JobStatus; /* ready, running, blocked, terminated */ - int32_t JobType; /* backup, restore, verify ... */ - int32_t JobLevel; /* Job level */ int32_t JobPriority; /* Job priority */ - bool JobReads; /* Set if job reads Volumes */ time_t sched_time; /* job schedule time, i.e. when it should start */ time_t start_time; /* when job actually started */ time_t run_time; /* used for computing speed */ diff --git a/bacula/src/lib/jcr.c b/bacula/src/lib/jcr.c index 10c6b77dd2..c31ff6f11f 100644 --- a/bacula/src/lib/jcr.c +++ b/bacula/src/lib/jcr.c @@ -221,6 +221,37 @@ void unlock_last_jobs_list() V(last_jobs_mutex); } +/* Set Job type in JCR and also set appropriate read flag */ +void JCR::set_JobType(int32_t JobType) +{ + m_JobType = JobType; +} + +/* Set Job level in JCR and also set appropriate read flag */ +void JCR::set_JobLevel(int32_t JobLevel) +{ + m_JobLevel = JobLevel; +} + +bool JCR::JobReads() +{ + switch (m_JobType) { + case JT_VERIFY: + case JT_RESTORE: + case JT_COPY: + case JT_MIGRATE: + return true; + case JT_BACKUP: + if (m_JobLevel == L_VIRTUAL_FULL) { + return true; + } + break; + default: + break; + } + return false; +} + /* * Push a subroutine address into the job end callback stack */ @@ -287,8 +318,8 @@ JCR *new_jcr(int size, JCR_free_HANDLER *daemon_free_jcr) /* Setup some dummy values */ bstrncpy(jcr->Job, "*System*", sizeof(jcr->Job)); jcr->JobId = 0; - jcr->JobType = JT_SYSTEM; /* internal job until defined */ - jcr->JobLevel = L_NONE; + jcr->set_JobType(JT_SYSTEM); /* internal job until defined */ + jcr->set_JobLevel(L_NONE); set_jcr_job_status(jcr, JS_Created); /* ready to run */ set_jcr_in_tsd(jcr); sigtimer.sa_flags = 0; @@ -446,7 +477,7 @@ void free_jcr(JCR *jcr) Dmsg1(dbglvl, "End job=%d\n", jcr->JobId); /* Keep some statistics */ - switch (jcr->JobType) { + switch (jcr->get_JobType()) { case JT_BACKUP: case JT_VERIFY: case JT_RESTORE: @@ -459,7 +490,7 @@ void free_jcr(JCR *jcr) je = (struct s_last_job *)malloc(sizeof(struct s_last_job)); memset(je, 0, sizeof(struct s_last_job)); /* zero in case unset fields */ je->Errors = jcr->Errors; - je->JobType = jcr->JobType; + je->JobType = jcr->get_JobType(); je->JobId = jcr->JobId; je->VolSessionId = jcr->VolSessionId; je->VolSessionTime = jcr->VolSessionTime; @@ -467,7 +498,7 @@ void free_jcr(JCR *jcr) je->JobFiles = jcr->JobFiles; je->JobBytes = jcr->JobBytes; je->JobStatus = jcr->JobStatus; - je->JobLevel = jcr->JobLevel; + je->JobLevel = jcr->get_JobLevel(); je->start_time = jcr->start_time; je->end_time = time(NULL); diff --git a/bacula/src/lib/util.c b/bacula/src/lib/util.c index 3ffa4f40fd..a9ceedbc42 100644 --- a/bacula/src/lib/util.c +++ b/bacula/src/lib/util.c @@ -441,7 +441,7 @@ const char *volume_status_to_str(const char *status) if (status) { for (pos = 0 ; vs[pos] ; pos += 2) { if ( !strcmp(vs[pos],status) ) { - return vs[pos+1]; + return vs[pos+1]; } } } @@ -738,7 +738,7 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_co break; case 'l': if (jcr) { - str = job_level_to_str(jcr->JobLevel); + str = job_level_to_str(jcr->get_JobLevel()); } else { str = _("*none*"); } @@ -769,7 +769,7 @@ POOLMEM *edit_job_codes(JCR *jcr, char *omsg, char *imsg, const char *to, job_co break; case 't': if (jcr) { - str = job_type_to_str(jcr->JobType); + str = job_type_to_str(jcr->get_JobType()); } else { str = _("*none*"); } diff --git a/bacula/src/stored/acquire.c b/bacula/src/stored/acquire.c index 47a2a75eb8..471a9a8282 100644 --- a/bacula/src/stored/acquire.c +++ b/bacula/src/stored/acquire.c @@ -650,7 +650,7 @@ static void attach_dcr_to_dev(DCR *dcr) JCR *jcr = dcr->jcr; if (jcr) Dmsg1(500, "JobId=%u enter attach_dcr_to_dev\n", (uint32_t)jcr->JobId); - if (!dcr->attached_to_dev && dev->initiated && jcr && jcr->JobType != JT_SYSTEM) { + if (!dcr->attached_to_dev && dev->initiated && jcr && jcr->get_JobType() != JT_SYSTEM) { dev->attached_dcrs->append(dcr); /* attach dcr to device */ dcr->attached_to_dev = true; Dmsg1(500, "JobId=%u attach_dcr_to_dev\n", (uint32_t)jcr->JobId); diff --git a/bacula/src/stored/askdir.c b/bacula/src/stored/askdir.c index 685b74f43d..e5c0535894 100644 --- a/bacula/src/stored/askdir.c +++ b/bacula/src/stored/askdir.c @@ -330,7 +330,7 @@ bool dir_update_volume_info(DCR *dcr, bool label, bool update_LastWritten) POOL_MEM VolumeName; /* If system job, do not update catalog */ - if (jcr->JobType == JT_SYSTEM) { + if (jcr->get_JobType() == JT_SYSTEM) { return true; } @@ -394,7 +394,7 @@ bool dir_create_jobmedia_record(DCR *dcr) char ed1[50]; /* If system job, do not update catalog */ - if (jcr->JobType == JT_SYSTEM) { + if (jcr->get_JobType() == JT_SYSTEM) { return true; } diff --git a/bacula/src/stored/block.c b/bacula/src/stored/block.c index d3b72a9338..156b0fa834 100644 --- a/bacula/src/stored/block.c +++ b/bacula/src/stored/block.c @@ -380,7 +380,7 @@ bool write_block_to_device(DCR *dcr) } if (!write_block_to_dev(dcr)) { - if (job_canceled(jcr) || jcr->JobType == JT_SYSTEM) { + if (job_canceled(jcr) || jcr->get_JobType() == JT_SYSTEM) { stat = false; } else { stat = fixup_device_block_write_error(dcr); diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index a42d66203e..5817a2ac46 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -539,7 +539,7 @@ static bool record_cb(DCR *dcr, DEV_RECORD *rec) jr.PoolId = pr.PoolId; mjcr->start_time = jr.StartTime; - mjcr->JobLevel = jr.JobLevel; + mjcr->set_JobLevel(jr.JobLevel); mjcr->client_name = get_pool_memory(PM_FNAME); pm_strcpy(mjcr->client_name, label.ClientName); @@ -1132,7 +1132,7 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel, } if (verbose) { Pmsg3(000, _("Updated Job termination record for JobId=%u Level=%s TermStat=%c\n"), - jr->JobId, job_level_to_str(mjcr->JobLevel), jr->JobStatus); + jr->JobId, job_level_to_str(mjcr->get_JobLevel()), jr->JobStatus); } if (verbose > 1) { const char *term_msg; @@ -1176,7 +1176,7 @@ static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel, mjcr->JobId, mjcr->Job, mjcr->fileset_name, - job_level_to_str(mjcr->JobLevel), + job_level_to_str(mjcr->get_JobLevel()), mjcr->client_name, sdt, edt, @@ -1273,8 +1273,8 @@ static JCR *create_jcr(JOB_DBR *jr, DEV_RECORD *rec, uint32_t JobId) * the JobId and the ClientId. */ jobjcr = new_jcr(sizeof(JCR), bscan_free_jcr); - jobjcr->JobType = jr->JobType; - jobjcr->JobLevel = jr->JobLevel; + jobjcr->set_JobType(jr->JobType); + jobjcr->set_JobLevel(jr->JobLevel); jobjcr->JobStatus = jr->JobStatus; bstrncpy(jobjcr->Job, jr->Job, sizeof(jobjcr->Job)); jobjcr->JobId = JobId; /* this is JobId on tape */ diff --git a/bacula/src/stored/butil.c b/bacula/src/stored/butil.c index b7356da107..034a4c100e 100644 --- a/bacula/src/stored/butil.c +++ b/bacula/src/stored/butil.c @@ -92,8 +92,8 @@ JCR *setup_jcr(const char *name, char *dev_name, BSR *bsr, jcr->NumReadVolumes = 0; jcr->NumWriteVolumes = 0; jcr->JobId = 0; - jcr->JobType = JT_CONSOLE; - jcr->JobLevel = L_FULL; + jcr->set_JobType(JT_CONSOLE); + jcr->set_JobLevel(L_FULL); jcr->JobStatus = JS_Terminated; jcr->where = bstrdup(""); jcr->job_name = get_pool_memory(PM_FNAME); diff --git a/bacula/src/stored/fd_cmds.c b/bacula/src/stored/fd_cmds.c index 413b35d559..7cd070e6c5 100644 --- a/bacula/src/stored/fd_cmds.c +++ b/bacula/src/stored/fd_cmds.c @@ -190,7 +190,7 @@ static bool append_data_cmd(JCR *jcr) Dmsg1(120, "Append data: %s", fd->msg); if (jcr->session_opened) { Dmsg1(110, "msg); - jcr->JobType = JT_BACKUP; + jcr->set_JobType(JT_BACKUP); if (do_append_data(jcr)) { return true; } else { @@ -316,7 +316,7 @@ static bool read_open_session(JCR *jcr) } jcr->session_opened = true; - jcr->JobType = JT_RESTORE; + jcr->set_JobType(JT_RESTORE); /* Send "Ticket" to File Daemon */ fd->fsend(OK_open, jcr->VolSessionId); diff --git a/bacula/src/stored/job.c b/bacula/src/stored/job.c index 187f4639ec..431071c582 100644 --- a/bacula/src/stored/job.c +++ b/bacula/src/stored/job.c @@ -134,8 +134,8 @@ bool job_cmd(JCR *jcr) unbash_spaces(fileset_name); jcr->fileset_name = get_pool_memory(PM_NAME); pm_strcpy(jcr->fileset_name, fileset_name); - jcr->JobType = JobType; - jcr->JobLevel = level; + jcr->set_JobType(JobType); + jcr->set_JobLevel(level); jcr->no_attributes = no_attributes; jcr->spool_attributes = spool_attributes; jcr->spool_data = spool_data; diff --git a/bacula/src/stored/label.c b/bacula/src/stored/label.c index 43b2cf2cfe..8df3339a46 100644 --- a/bacula/src/stored/label.c +++ b/bacula/src/stored/label.c @@ -667,8 +667,8 @@ void create_session_label(DCR *dcr, DEV_RECORD *rec, int label) /* Added in VerNum 10 */ ser_string(jcr->Job); /* Unique name of this Job */ ser_string(jcr->fileset_name); - ser_uint32(jcr->JobType); - ser_uint32(jcr->JobLevel); + ser_uint32(jcr->get_JobType()); + ser_uint32(jcr->get_JobLevel()); /* Added in VerNum 11 */ ser_string(jcr->fileset_md5); diff --git a/bacula/src/stored/mac.c b/bacula/src/stored/mac.c index 1d6cde5e06..f2435e7838 100644 --- a/bacula/src/stored/mac.c +++ b/bacula/src/stored/mac.c @@ -57,7 +57,7 @@ bool do_mac(JCR *jcr) char ec1[50]; DEVICE *dev; - switch(jcr->JobType) { + switch(jcr->get_JobType()) { case JT_MIGRATE: Type = "Migration"; break; diff --git a/bacula/src/stored/pythonsd.c b/bacula/src/stored/pythonsd.c index c4ab8f9ca7..4a9b83048a 100644 --- a/bacula/src/stored/pythonsd.c +++ b/bacula/src/stored/pythonsd.c @@ -120,9 +120,9 @@ PyObject *job_getattr(PyObject *self, char *attrname) case 1: /* SD's name */ return Py_BuildValue((char *)getvars[i].fmt, my_name); case 2: /* level */ - return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->JobLevel)); + return Py_BuildValue((char *)getvars[i].fmt, job_level_to_str(jcr->get_JobLevel())); case 3: /* type */ - return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->JobType)); + return Py_BuildValue((char *)getvars[i].fmt, job_type_to_str(jcr->get_JobType())); case 4: /* JobId */ return Py_BuildValue((char *)getvars[i].fmt, jcr->JobId); case 5: /* Client */ diff --git a/bacula/src/stored/status.c b/bacula/src/stored/status.c index 87d3417541..8812810c64 100644 --- a/bacula/src/stored/status.c +++ b/bacula/src/stored/status.c @@ -400,7 +400,7 @@ static void list_running_jobs(STATUS_PKT *sp) foreach_jcr(jcr) { if (jcr->JobStatus == JS_WaitFD) { len = Mmsg(msg, _("%s Job %s waiting for Client connection.\n"), - job_type_to_str(jcr->JobType), jcr->Job); + job_type_to_str(jcr->get_JobType()), jcr->Job); sendit(msg, len, sp); } dcr = jcr->dcr; @@ -417,8 +417,8 @@ static void list_running_jobs(STATUS_PKT *sp) if (rdcr && rdcr->device) { len = Mmsg(msg, _("Reading: %s %s job %s JobId=%d Volume=\"%s\"\n" " pool=\"%s\" device=%s\n"), - job_level_to_str(jcr->JobLevel), - job_type_to_str(jcr->JobType), + job_level_to_str(jcr->get_JobLevel()), + job_type_to_str(jcr->get_JobType()), JobName, jcr->JobId, rdcr->VolumeName, @@ -430,8 +430,8 @@ static void list_running_jobs(STATUS_PKT *sp) if (dcr && dcr->device) { len = Mmsg(msg, _("Writing: %s %s job %s JobId=%d Volume=\"%s\"\n" " pool=\"%s\" device=%s\n"), - job_level_to_str(jcr->JobLevel), - job_type_to_str(jcr->JobType), + job_level_to_str(jcr->get_JobLevel()), + job_type_to_str(jcr->get_JobType()), JobName, jcr->JobId, dcr->VolumeName, diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 35424d72a8..71d635ed75 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -482,7 +482,7 @@ void *device_initialization(void *arg) pthread_detach(pthread_self()); jcr = new_jcr(sizeof(JCR), stored_free_jcr); - jcr->JobType = JT_SYSTEM; + jcr->set_JobType(JT_SYSTEM); /* Initialize FD start condition variable */ int errstat = pthread_cond_init(&jcr->job_start_wait, NULL); if (errstat != 0) { diff --git a/bacula/src/tools/bbatch.c b/bacula/src/tools/bbatch.c index 62bae17820..286b908596 100644 --- a/bacula/src/tools/bbatch.c +++ b/bacula/src/tools/bbatch.c @@ -149,9 +149,9 @@ int main (int argc, char *argv[]) break; case 'f': - if (nb < 10 ) { - files[nb++] = optarg; - } + if (nb < 10 ) { + files[nb++] = optarg; + } break; case '?': @@ -183,8 +183,8 @@ int main (int argc, char *argv[]) bjcr->NumReadVolumes = 0; bjcr->NumWriteVolumes = 0; bjcr->JobId = getpid(); - bjcr->JobType = JT_CONSOLE; - bjcr->JobLevel = L_FULL; + bjcr->set_JobType(JT_CONSOLE); + bjcr->set_JobLevel(L_FULL); bjcr->JobStatus = JS_Running; bjcr->where = bstrdup(files[i]); bjcr->job_name = get_pool_memory(PM_FNAME); @@ -198,15 +198,15 @@ int main (int argc, char *argv[]) pm_strcpy(bjcr->fileset_md5, "Dummy.fileset.md5"); if ((db=db_init_database(NULL, db_name, db_user, db_password, - db_host, 0, NULL, 0)) == NULL) { - Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n")); + db_host, 0, NULL, 0)) == NULL) { + Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n")); } if (!db_open_database(NULL, db)) { - Emsg0(M_ERROR_TERM, 0, db_strerror(db)); + Emsg0(M_ERROR_TERM, 0, db_strerror(db)); } Dmsg0(200, "Database opened\n"); if (verbose) { - Pmsg2(000, _("Using Database: %s, User: %s\n"), db_name, db_user); + Pmsg2(000, _("Using Database: %s, User: %s\n"), db_name, db_user); } bjcr->db = db; @@ -231,23 +231,23 @@ static void fill_attr(ATTR_DBR *ar, char *data) for(p = b = data; *p; p++) { if (*p == ';') { - *p = '\0'; - switch (index) { - case 0: - ar->FileIndex = str_to_int64(b); - break; - case 1: - ar->fname = b; - break; - case 2: - ar->attr = b; - break; - case 3: - ar->Digest = b; - break; - } - index++; - b = ++p; + *p = '\0'; + switch (index) { + case 0: + ar->FileIndex = str_to_int64(b); + break; + case 1: + ar->fname = b; + break; + case 2: + ar->attr = b; + break; + case 3: + ar->Digest = b; + break; + } + index++; + b = ++p; } } } @@ -270,11 +270,11 @@ static void *do_batch(void *jcr) strip_trailing_newline(data); lineno++; if (verbose && ((lineno % 5000) == 1)) { - printf("\r%i", lineno); + printf("\r%i", lineno); } fill_attr(&ar, data); if (!db_create_file_attributes_record(bjcr, bjcr->db, &ar)) { - Emsg0(M_ERROR_TERM, 0, _("Error while inserting file\n")); + Emsg0(M_ERROR_TERM, 0, _("Error while inserting file\n")); } } fclose(fd); @@ -286,7 +286,7 @@ static void *do_batch(void *jcr) printf("\rbegin = %s, end = %s\n", edit_int64(begin, ed1),edit_int64(end, ed2)); printf("Insert time = %sms\n", edit_int64((end - begin) / 10000, ed1)); printf("Create %u files at %.2f/s\n", lineno, - (lineno / ((float)((end - begin) / 1000000)))); + (lineno / ((float)((end - begin) / 1000000)))); nb--; V(mutex); pthread_exit(NULL); diff --git a/bacula/src/version.h b/bacula/src/version.h index 957e99062c..2e9c198d85 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -4,8 +4,8 @@ #undef VERSION #define VERSION "2.5.2" -#define BDATE "15 July 2008" -#define LSMDATE "15Jul08" +#define BDATE "175 July 2008" +#define LSMDATE "175Jul08" #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n" #define BYEAR "2008" /* year for copyright messages in progs */ diff --git a/bacula/technotes-2.5 b/bacula/technotes-2.5 index ba68bbcfdd..44cb58c225 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -31,6 +31,8 @@ vtape driver General: 17Jul08 +kes Move setting JobLevel and JobType into a method, which should + allow completing Virtual Backups. kes Fix verify jobs to work again. 16Jul08 kes Virtual Backup tweaks -- it is close to working.