+ }
+ /* Create Client record if not already there */
+ bstrncpy(cr.Name, label.ClientName, sizeof(cr.Name));
+ create_client_record(db, &cr);
+ jr.ClientId = cr.ClientId;
+
+ /* process label, if Job record exists don't update db */
+ mjcr = create_job_record(db, &jr, &label, rec);
+ dcr = mjcr->dcr;
+ update_db = save_update_db;
+
+ jr.PoolId = pr.PoolId;
+ /* Set start positions into JCR */
+ if (dev->state & ST_TAPE) {
+ /*
+ * Note, we have already advanced past current block,
+ * so the correct number is block_num - 1
+ */
+ dcr->StartBlock = dev->block_num - 1;
+ dcr->StartFile = dev->file;
+ } else {
+ dcr->StartBlock = (uint32_t)dev->file_addr;
+ dcr->StartFile = (uint32_t)(dev->file_addr >> 32);
+ }
+ mjcr->start_time = jr.StartTime;
+ mjcr->JobLevel = jr.JobLevel;
+
+ mjcr->client_name = get_pool_memory(PM_FNAME);
+ pm_strcpy(&mjcr->client_name, label.ClientName);
+ mjcr->pool_type = get_pool_memory(PM_FNAME);
+ pm_strcpy(&mjcr->pool_type, label.PoolType);
+ mjcr->fileset_name = get_pool_memory(PM_FNAME);
+ pm_strcpy(&mjcr->fileset_name, label.FileSetName);
+ mjcr->pool_name = get_pool_memory(PM_FNAME);
+ pm_strcpy(&mjcr->pool_name, label.PoolName);
+
+ if (rec->VolSessionId != jr.VolSessionId) {
+ Pmsg3(000, _("SOS_LABEL: VolSessId mismatch for JobId=%u. DB=%d Vol=%d\n"),
+ jr.JobId,
+ jr.VolSessionId, rec->VolSessionId);
+ return true; /* ignore error */
+ }
+ if (rec->VolSessionTime != jr.VolSessionTime) {
+ Pmsg3(000, _("SOS_LABEL: VolSessTime mismatch for JobId=%u. DB=%d Vol=%d\n"),
+ jr.JobId,
+ jr.VolSessionTime, rec->VolSessionTime);
+ return true; /* ignore error */
+ }
+ if (jr.PoolId != pr.PoolId) {
+ Pmsg3(000, _("SOS_LABEL: PoolId mismatch for JobId=%u. DB=%d Vol=%d\n"),
+ jr.JobId,
+ jr.PoolId, pr.PoolId);
+ return true; /* ignore error */
+ }
+ break;
+
+ case EOS_LABEL:
+ unser_session_label(&elabel, rec);
+
+ /* Create FileSet record */
+ bstrncpy(fsr.FileSet, label.FileSetName, sizeof(fsr.FileSet));
+ bstrncpy(fsr.MD5, label.FileSetMD5, sizeof(fsr.MD5));
+ create_fileset_record(db, &fsr);
+ jr.FileSetId = fsr.FileSetId;
+
+ mjcr = get_jcr_by_session(rec->VolSessionId, rec->VolSessionTime);
+ if (!mjcr) {
+ Pmsg2(000, _("Could not find SessId=%d SessTime=%d for EOS record.\n"),
+ rec->VolSessionId, rec->VolSessionTime);