Kern's ToDo List
- 11 March 2005
+ 09 April 2005
Major development:
Project Developer
1.37 Major Projects:
#3 Migration (Move, Copy, Archive Jobs)
-#4 Embedded Python Scripting
- (Implemented in Dir/SD)
#7 Single Job Writing to Multiple Storage Devices
+ (probably not)
## Integrate web-bacula into a new Bacula project with
bimagemgr.
## Consider moving docs to their own project.
+## Move rescue to its own project.
Autochangers:
- 3. Prevent two drives requesting the same Volume in any given
in an Autochanger.
- 7. Implement new Console commands to allow offlining/reserving drives,
and possibly manipulating the autochanger (much asked for).
+- Make "update slots" when pointing to Autochanger, remove
+ all Volumes from other drives. "update slots all-drives"?
For 1.37:
-- Add disk seeking on restore.
-- If the user puts "Purge Oldest Volume = yes" or "Recycle Oldest Volume = yes"
- and there is only one volume in the pool, refuse to do it -- otherwise
- he fills the Volume, then immediately starts reusing it.
+- Add disk seeking on restore; turn off seek on tapes.
+ stored/match_bsr.c
- Implement "NewVolumeEachJob = yes|no" in Dir.
-- Make "update slots" when pointing to Autochanger, remove
- all Volumes from other drives. "update slots all-drives"?
-- Add Python writable variable for changing the Priority,
- Client, Storage, JobStatus (error), ...
-- SD Python
- - Solicit Events
- FD Python
- Python script to save with Python, not save, save with Bacula.
- Python script to do backup.
- Look at adding full Volume and Pool information to a Volume
label so that bscan can get *all* the info.
- Implement Maximum Job Spool Size
-- 28-Mar 23:19 rufus-sd: acquire.c:379 Device "DDS-4" (/dev/nst0)
- is busy reading. Job 6 canceled.
- Remove all old Device resource code in Dir and code to pass it
- back in SD.
-- Fix code to either handle updating NumVol or to calculate it in
- Dir next_vol.c
+ back in SD -- better, rework it to pass back device statistics.
- Finish implementation of passing all Storage and Device needs to
the SD.
- Check locking of resources -- be sure to lock devices where previously
resources were locked.
- Add global lock on all devices when creating a device structure.
-- Remove separate thread for opening devices in SD. On the other
- hand, don't block waiting for open() for devices.
- Make sure that Python has access to Client address/port so that
it can check if Clients are alive.
-- Implement copies and stripes.
-- Add history file to console.
+- Cleanup and complete Python scripting.
+ - What events?
+ - Change the Priority, Client, Storage, JobStatus (error)
+ at the start of a job.
Maybe in 1.37:
-- Ensure that you cannot exclude a directory or a file explicitly
- Included with File.
+- If the user puts "Purge Oldest Volume = yes" or "Recycle Oldest Volume = yes"
+ and there is only one volume in the pool, refuse to do it -- otherwise
+ he fills the Volume, then immediately starts reusing it.
+- Implement copies and stripes.
+- Add history file to console.
- Each file on tape creates a JobMedia record. Peter has 4 million
files spread over 10000 tape files and four tapes. A restore takes
16 hours to build the restore list.
- A HOLD command to stop all jobs from starting.
- A PAUSE command to pause all running jobs ==> release the
drive.
+- Media Type = LTO,LTO-2,LTO-3
+ Media Type Read = LTO,LTO2,LTO3
+ Media Type Write = LTO2, LTO3
+
=== From Carsten Menke <bootsy52@gmx.net>
Following is a list of what I think in the situations where I'm faced with,
recycled and no label created. This happens when using
autolabeling -- even when Python doesn't generate the name.
- Scratch Pool where the volumes can be re-assigned to any Pool.
+- 28-Mar 23:19 rufus-sd: acquire.c:379 Device "DDS-4" (/dev/nst0)
+ is busy reading. Job 6 canceled.
+- Remove separate thread for opening devices in SD. On the other
+ hand, don't block waiting for open() for devices.
+- Fix code to either handle updating NumVol or to calculate it in
+ Dir next_vol.c
+- Ensure that you cannot exclude a directory or a file explicitly
+ Included with File.
+#4 Embedded Python Scripting
+ (Implemented in Dir/SD/FD)
+- Add Python writable variable for changing the Priority,
+ Client, Storage, JobStatus (error), ...
+- SD Python
+ - Solicit Events
}
}
jcr->jr.FileSetId = fsr->FileSetId;
+#ifdef needed
if (fsr->created && jcr != NULL) {
Jmsg(jcr, M_INFO, 0, _("Created new FileSet record \"%s\" %s\n"),
fsr->FileSet, fsr->cCreateTime);
}
+#endif
Dmsg2(119, "Created FileSet %s record %u\n", jcr->fileset->hdr.name,
jcr->jr.FileSetId);
return true;
dev->block(BST_DOING_ACQUIRE);
}
- Dmsg1(190, "reserve_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
+ Dmsg1(190, "reserve_append device is %s\n", dev->is_tape()?"tape":"disk");
for ( ;; ) {
switch (can_reserve_drive(dcr)) {
init_device_wait_timers(dcr);
dev->block(BST_DOING_ACQUIRE);
- Dmsg1(190, "acquire_append device is %s\n", dev_is_tape(dev)?"tape":"disk");
+ Dmsg1(190, "acquire_append device is %s\n", dev->is_tape()?"tape":"disk");
if (dcr->reserved_device) {
dev->reserved_device--;
bool ok = true;
lock_device(dev);
- Dmsg1(100, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk");
+ Dmsg1(100, "release_device device is %s\n", dev->is_tape()?"tape":"disk");
/* if device is reserved, job never started, so release the reserve here */
if (dcr->reserved_device) {
static void do_scan(void);
static bool record_cb(DCR *dcr, DEV_RECORD *rec);
static int create_file_attributes_record(B_DB *db, JCR *mjcr,
- char *fname, char *lname, int type,
- char *ap, DEV_RECORD *rec);
+ char *fname, char *lname, int type,
+ char *ap, DEV_RECORD *rec);
static int create_media_record(B_DB *db, MEDIA_DBR *mr, VOLUME_LABEL *vl);
static bool update_media_record(B_DB *db, MEDIA_DBR *mr);
static int create_pool_record(B_DB *db, POOL_DBR *pr);
static JCR *create_job_record(B_DB *db, JOB_DBR *mr, SESSION_LABEL *label, DEV_RECORD *rec);
static int update_job_record(B_DB *db, JOB_DBR *mr, SESSION_LABEL *elabel,
- DEV_RECORD *rec);
+ DEV_RECORD *rec);
static int create_client_record(B_DB *db, CLIENT_DBR *cr);
static int create_fileset_record(B_DB *db, FILESET_DBR *fsr);
static int create_jobmedia_record(B_DB *db, JCR *jcr);
/* Local variables */
static DEVICE *dev = NULL;
static B_DB *db;
-static JCR *bjcr; /* jcr for bscan */
+static JCR *bjcr; /* jcr for bscan */
static BSR *bsr = NULL;
static MEDIA_DBR mr;
static POOL_DBR pr;
#define CONFIG_FILE "bacula-sd.conf"
char *configfile;
-STORES *me = NULL; /* our Global resource */
-bool forge_on = false; /* proceed inspite of I/O errors */
+STORES *me = NULL; /* our Global resource */
+bool forge_on = false; /* proceed inspite of I/O errors */
pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER;
while ((ch = getopt(argc, argv, "b:c:d:h:mn:pP:rsSu:vV:w:?")) != -1) {
switch (ch) {
case 'S' :
- showProgress = true;
- break;
+ showProgress = true;
+ break;
case 'b':
- bsr = parse_bsr(NULL, optarg);
- break;
+ bsr = parse_bsr(NULL, optarg);
+ break;
case 'c': /* specify config file */
- if (configfile != NULL) {
- free(configfile);
- }
- configfile = bstrdup(optarg);
- break;
+ if (configfile != NULL) {
+ free(configfile);
+ }
+ configfile = bstrdup(optarg);
+ break;
case 'd': /* debug level */
- debug_level = atoi(optarg);
- if (debug_level <= 0)
- debug_level = 1;
- break;
+ debug_level = atoi(optarg);
+ if (debug_level <= 0)
+ debug_level = 1;
+ break;
case 'h':
- db_host = optarg;
- break;
+ db_host = optarg;
+ break;
case 'm':
- update_vol_info = true;
- break;
+ update_vol_info = true;
+ break;
case 'n':
- db_name = optarg;
- break;
+ db_name = optarg;
+ break;
case 'u':
- db_user = optarg;
- break;
+ db_user = optarg;
+ break;
case 'P':
- db_password = optarg;
- break;
+ db_password = optarg;
+ break;
case 'p':
- forge_on = true;
- break;
+ forge_on = true;
+ break;
case 'r':
- list_records = true;
- break;
+ list_records = true;
+ break;
case 's':
- update_db = true;
- break;
+ update_db = true;
+ break;
case 'v':
- verbose++;
- break;
+ verbose++;
+ break;
case 'V': /* Volume name */
- VolumeName = optarg;
- break;
+ VolumeName = optarg;
+ break;
case 'w':
- wd = optarg;
- break;
+ wd = optarg;
+ break;
case '?':
default:
- usage();
+ usage();
}
}
if (!me) {
UnlockRes();
Emsg1(M_ERROR_TERM, 0, _("No Storage resource defined in %s. Cannot continue.\n"),
- configfile);
+ configfile);
}
UnlockRes();
/* Check if -w option given, otherwise use resource for working directory */
working_directory = wd;
} else if (!me->working_directory) {
Emsg1(M_ERROR_TERM, 0, _("No Working Directory defined in %s. Cannot continue.\n"),
- configfile);
+ configfile);
} else {
working_directory = me->working_directory;
}
/* Check that working directory is good */
if (stat(working_directory, &stat_buf) != 0) {
Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s not found. Cannot continue.\n"),
- working_directory);
+ working_directory);
}
if (!S_ISDIR(stat_buf.st_mode)) {
Emsg1(M_ERROR_TERM, 0, _("Working Directory: %s is not a directory. Cannot continue.\n"),
- working_directory);
+ working_directory);
}
bjcr = setup_jcr("bscan", argv[0], bsr, VolumeName, 1); /* read device */
fstat(dev->fd, &sb);
currentVolumeSize = sb.st_size;
Pmsg1(000, _("First Volume Size = %sn"),
- edit_uint64(currentVolumeSize, ed1));
+ edit_uint64(currentVolumeSize, ed1));
}
if ((db=db_init_database(NULL, db_name, db_user, db_password,
- db_host, 0, NULL, 0)) == NULL) {
+ db_host, 0, NULL, 0)) == NULL) {
Emsg0(M_ERROR_TERM, 0, _("Could not init Bacula database\n"));
}
if (!db_open_database(NULL, db)) {
foreach_dlist(mdcr, dev->attached_dcrs) {
JCR *mjcr = mdcr->jcr;
if (mjcr->JobId == 0) {
- continue;
+ continue;
}
if (verbose) {
Pmsg1(000, _("Create JobMedia for Job %s\n"), mjcr->Job);
}
- if (dev->state & ST_TAPE) {
- mdcr->EndBlock = dev->EndBlock;
- mdcr->EndFile = dev->EndFile;
- } else {
- mdcr->EndBlock = (uint32_t)dev->file_addr;
- mdcr->EndFile = (uint32_t)(dev->file_addr >> 32);
+ if (dev->is_tape()) {
+ mdcr->EndBlock = dcr->EndBlock;
+ mdcr->EndFile = dcr->EndFile;
+// } else {
+// mdcr->EndBlock = (uint32_t)dcr->file_addr;
+// mdcr->EndFile = (uint32_t)(dcr->file_addr >> 32);
}
if (!create_jobmedia_record(db, mjcr)) {
Pmsg2(000, _("Could not create JobMedia record for Volume=%s Job=%s\n"),
- dev->VolCatInfo.VolCatName, mjcr->Job);
+ dev->VolCatInfo.VolCatName, mjcr->Job);
}
}
/* Now let common read routine get up next tape. Note,
fstat(dev->fd, &sb);
currentVolumeSize = sb.st_size;
Pmsg1(000, _("First Volume Size = %sn"),
- edit_uint64(currentVolumeSize, ed1));
+ edit_uint64(currentVolumeSize, ed1));
}
return stat;
}
/*
* Returns: true if OK
- * false if error
+ * false if error
*/
static bool record_cb(DCR *dcr, DEV_RECORD *rec)
{
if (rec->data_len > 0) {
mr.VolBytes += rec->data_len + WRITE_RECHDR_LENGTH; /* Accumulate Volume bytes */
if (showProgress) {
- int pct = (mr.VolBytes * 100) / currentVolumeSize;
- if (pct != last_pct) {
+ int pct = (mr.VolBytes * 100) / currentVolumeSize;
+ if (pct != last_pct) {
fprintf(stdout, "done: %d%%\n", pct);
- fflush(stdout);
- last_pct = pct;
- }
+ fflush(stdout);
+ last_pct = pct;
+ }
}
}
if (list_records) {
Pmsg5(000, _("Record: SessId=%u SessTim=%u FileIndex=%d Stream=%d len=%u\n"),
- rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
- rec->Stream, rec->data_len);
+ rec->VolSessionId, rec->VolSessionTime, rec->FileIndex,
+ rec->Stream, rec->data_len);
}
/*
* Check for Start or End of Session Record
bool save_update_db = update_db;
if (verbose > 1) {
- dump_label_record(dev, rec, 1);
+ dump_label_record(dev, rec, 1);
}
switch (rec->FileIndex) {
case PRE_LABEL:
Pmsg0(000, _("Volume is prelabeled. This tape cannot be scanned.\n"));
- return false;
- break;
+ return false;
+ break;
case VOL_LABEL:
- unser_volume_label(dev, rec);
- /* Check Pool info */
- bstrncpy(pr.Name, dev->VolHdr.PoolName, sizeof(pr.Name));
- bstrncpy(pr.PoolType, dev->VolHdr.PoolType, sizeof(pr.PoolType));
- num_pools++;
- if (db_get_pool_record(bjcr, db, &pr)) {
- if (verbose) {
+ unser_volume_label(dev, rec);
+ /* Check Pool info */
+ bstrncpy(pr.Name, dev->VolHdr.PoolName, sizeof(pr.Name));
+ bstrncpy(pr.PoolType, dev->VolHdr.PoolType, sizeof(pr.PoolType));
+ num_pools++;
+ if (db_get_pool_record(bjcr, db, &pr)) {
+ if (verbose) {
Pmsg1(000, _("Pool record for %s found in DB.\n"), pr.Name);
- }
- } else {
- if (!update_db) {
+ }
+ } else {
+ if (!update_db) {
Pmsg1(000, _("VOL_LABEL: Pool record not found for Pool: %s\n"),
- pr.Name);
- }
- create_pool_record(db, &pr);
- }
- if (strcmp(pr.PoolType, dev->VolHdr.PoolType) != 0) {
+ pr.Name);
+ }
+ create_pool_record(db, &pr);
+ }
+ if (strcmp(pr.PoolType, dev->VolHdr.PoolType) != 0) {
Pmsg2(000, _("VOL_LABEL: PoolType mismatch. DB=%s Vol=%s\n"),
- pr.PoolType, dev->VolHdr.PoolType);
- return true;
- } else if (verbose) {
+ pr.PoolType, dev->VolHdr.PoolType);
+ return true;
+ } else if (verbose) {
Pmsg1(000, _("Pool type \"%s\" is OK.\n"), pr.PoolType);
- }
-
- /* Check Media Info */
- memset(&mr, 0, sizeof(mr));
- bstrncpy(mr.VolumeName, dev->VolHdr.VolName, sizeof(mr.VolumeName));
- mr.PoolId = pr.PoolId;
- num_media++;
- if (db_get_media_record(bjcr, db, &mr)) {
- if (verbose) {
+ }
+
+ /* Check Media Info */
+ memset(&mr, 0, sizeof(mr));
+ bstrncpy(mr.VolumeName, dev->VolHdr.VolName, sizeof(mr.VolumeName));
+ mr.PoolId = pr.PoolId;
+ num_media++;
+ if (db_get_media_record(bjcr, db, &mr)) {
+ if (verbose) {
Pmsg1(000, _("Media record for %s found in DB.\n"), mr.VolumeName);
- }
- /* Clear out some volume statistics that will be updated */
- mr.VolJobs = mr.VolFiles = mr.VolBlocks = 0;
- mr.VolBytes = rec->data_len + 20;
- } else {
- if (!update_db) {
+ }
+ /* Clear out some volume statistics that will be updated */
+ mr.VolJobs = mr.VolFiles = mr.VolBlocks = 0;
+ mr.VolBytes = rec->data_len + 20;
+ } else {
+ if (!update_db) {
Pmsg1(000, _("VOL_LABEL: Media record not found for Volume: %s\n"),
- mr.VolumeName);
- }
- bstrncpy(mr.MediaType, dev->VolHdr.MediaType, sizeof(mr.MediaType));
- create_media_record(db, &mr, &dev->VolHdr);
- }
- if (strcmp(mr.MediaType, dev->VolHdr.MediaType) != 0) {
+ mr.VolumeName);
+ }
+ bstrncpy(mr.MediaType, dev->VolHdr.MediaType, sizeof(mr.MediaType));
+ create_media_record(db, &mr, &dev->VolHdr);
+ }
+ if (strcmp(mr.MediaType, dev->VolHdr.MediaType) != 0) {
Pmsg2(000, _("VOL_LABEL: MediaType mismatch. DB=%s Vol=%s\n"),
- mr.MediaType, dev->VolHdr.MediaType);
- return true; /* ignore error */
- } else if (verbose) {
+ mr.MediaType, dev->VolHdr.MediaType);
+ return true; /* ignore error */
+ } else if (verbose) {
Pmsg1(000, _("Media type \"%s\" is OK.\n"), mr.MediaType);
- }
- /* Reset some DCR variables */
- foreach_dlist(dcr, dev->attached_dcrs) {
- dcr->VolFirstIndex = dcr->FileIndex = 0;
- dcr->StartBlock = dcr->EndBlock = 0;
- dcr->StartFile = dcr->EndFile = 0;
- }
+ }
+ /* Reset some DCR variables */
+ foreach_dlist(dcr, dev->attached_dcrs) {
+ dcr->VolFirstIndex = dcr->FileIndex = 0;
+ dcr->StartBlock = dcr->EndBlock = 0;
+ dcr->StartFile = dcr->EndFile = 0;
+ }
Pmsg1(000, _("VOL_LABEL: OK for Volume: %s\n"), mr.VolumeName);
- break;
+ break;
case SOS_LABEL:
- mr.VolJobs++;
- num_jobs++;
- if (ignored_msgs > 0) {
+ mr.VolJobs++;
+ num_jobs++;
+ if (ignored_msgs > 0) {
Pmsg1(000, _("%d \"errors\" ignored before first Start of Session record.\n"),
- ignored_msgs);
- ignored_msgs = 0;
- }
- unser_session_label(&label, rec);
- memset(&jr, 0, sizeof(jr));
- bstrncpy(jr.Job, label.Job, sizeof(jr.Job));
- if (db_get_job_record(bjcr, db, &jr)) {
- /* Job record already exists in DB */
+ ignored_msgs);
+ ignored_msgs = 0;
+ }
+ unser_session_label(&label, rec);
+ memset(&jr, 0, sizeof(jr));
+ bstrncpy(jr.Job, label.Job, sizeof(jr.Job));
+ if (db_get_job_record(bjcr, db, &jr)) {
+ /* Job record already exists in DB */
update_db = false; /* don't change db in create_job_record */
- if (verbose) {
+ if (verbose) {
Pmsg1(000, _("SOS_LABEL: Found Job record for JobId: %d\n"), jr.JobId);
- }
- } else {
- /* Must create a Job record in DB */
- if (!update_db) {
+ }
+ } else {
+ /* Must create a Job record in DB */
+ if (!update_db) {
Pmsg1(000, _("SOS_LABEL: Job record not found for JobId: %d\n"),
- jr.JobId);
- }
- }
- /* Create Client record if not already there */
- bstrncpy(cr.Name, label.ClientName, sizeof(cr.Name));
- create_client_record(db, &cr);
- jr.ClientId = cr.ClientId;
+ jr.JobId);
+ }
+ }
+ /* 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->fileset_name = get_pool_memory(PM_FNAME);
- pm_strcpy(mjcr->fileset_name, label.FileSetName);
- bstrncpy(dcr->pool_type, label.PoolType, sizeof(dcr->pool_type));
- bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name));
-
- if (rec->VolSessionId != jr.VolSessionId) {
+ 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->is_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->fileset_name = get_pool_memory(PM_FNAME);
+ pm_strcpy(mjcr->fileset_name, label.FileSetName);
+ bstrncpy(dcr->pool_type, label.PoolType, sizeof(dcr->pool_type));
+ bstrncpy(dcr->pool_name, label.PoolName, sizeof(dcr->pool_name));
+
+ 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) {
+ 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) {
+ 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;
+ jr.JobId,
+ jr.PoolId, pr.PoolId);
+ return true; /* ignore error */
+ }
+ break;
case EOS_LABEL:
- unser_session_label(&elabel, rec);
+ 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;
+ /* 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) {
+ 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);
- break;
- }
+ rec->VolSessionId, rec->VolSessionTime);
+ break;
+ }
- /* Do the final update to the Job record */
- update_job_record(db, &jr, &elabel, rec);
+ /* Do the final update to the Job record */
+ update_job_record(db, &jr, &elabel, rec);
- mjcr->end_time = jr.EndTime;
- mjcr->JobStatus = JS_Terminated;
+ mjcr->end_time = jr.EndTime;
+ mjcr->JobStatus = JS_Terminated;
- /* Create JobMedia record */
- create_jobmedia_record(db, mjcr);
- dev->attached_dcrs->remove(mjcr->dcr);
- free_jcr(mjcr);
+ /* Create JobMedia record */
+ create_jobmedia_record(db, mjcr);
+ dev->attached_dcrs->remove(mjcr->dcr);
+ free_jcr(mjcr);
- break;
+ break;
case EOM_LABEL:
- break;
-
- case EOT_LABEL: /* end of all tapes */
- /*
- * Wiffle through all jobs still open and close
- * them.
- */
- if (update_db) {
- DCR *mdcr;
- foreach_dlist(mdcr, dev->attached_dcrs) {
- JCR *mjcr = mdcr->jcr;
- if (!mjcr || mjcr->JobId == 0) {
- continue;
- }
- jr.JobId = mjcr->JobId;
- /* Mark Job as Error Terimined */
- jr.JobStatus = JS_ErrorTerminated;
- jr.JobFiles = mjcr->JobFiles;
- jr.JobBytes = mjcr->JobBytes;
- jr.VolSessionId = mjcr->VolSessionId;
- jr.VolSessionTime = mjcr->VolSessionTime;
- jr.JobTDate = (utime_t)mjcr->start_time;
- jr.ClientId = mjcr->ClientId;
- if (!db_update_job_end_record(bjcr, db, &jr)) {
+ break;
+
+ case EOT_LABEL: /* end of all tapes */
+ /*
+ * Wiffle through all jobs still open and close
+ * them.
+ */
+ if (update_db) {
+ DCR *mdcr;
+ foreach_dlist(mdcr, dev->attached_dcrs) {
+ JCR *mjcr = mdcr->jcr;
+ if (!mjcr || mjcr->JobId == 0) {
+ continue;
+ }
+ jr.JobId = mjcr->JobId;
+ /* Mark Job as Error Terimined */
+ jr.JobStatus = JS_ErrorTerminated;
+ jr.JobFiles = mjcr->JobFiles;
+ jr.JobBytes = mjcr->JobBytes;
+ jr.VolSessionId = mjcr->VolSessionId;
+ jr.VolSessionTime = mjcr->VolSessionTime;
+ jr.JobTDate = (utime_t)mjcr->start_time;
+ jr.ClientId = mjcr->ClientId;
+ if (!db_update_job_end_record(bjcr, db, &jr)) {
Pmsg1(0, _("Could not update job record. ERR=%s\n"), db_strerror(db));
- }
- mjcr->dcr = NULL;
- free_jcr(mjcr);
- }
- }
- mr.VolFiles = rec->File;
- mr.VolBlocks = rec->Block;
- mr.VolBytes += mr.VolBlocks * WRITE_BLKHDR_LENGTH; /* approx. */
- mr.VolMounts++;
- update_media_record(db, &mr);
+ }
+ mjcr->dcr = NULL;
+ free_jcr(mjcr);
+ }
+ }
+ mr.VolFiles = rec->File;
+ mr.VolBlocks = rec->Block;
+ mr.VolBytes += mr.VolBlocks * WRITE_BLKHDR_LENGTH; /* approx. */
+ mr.VolMounts++;
+ update_media_record(db, &mr);
Pmsg3(0, _("End of all Volumes. VolFiles=%u VolBlocks=%u VolBytes=%s\n"), mr.VolFiles,
- mr.VolBlocks, edit_uint64_with_commas(mr.VolBytes, ec1));
- break;
+ mr.VolBlocks, edit_uint64_with_commas(mr.VolBytes, ec1));
+ break;
default:
- break;
+ break;
} /* end switch */
return true;
}
if (!mjcr) {
if (mr.VolJobs > 0) {
Pmsg2(000, _("Could not find Job for SessId=%d SessTime=%d record.\n"),
- rec->VolSessionId, rec->VolSessionTime);
+ rec->VolSessionId, rec->VolSessionTime);
} else {
- ignored_msgs++;
+ ignored_msgs++;
}
return true;
}
if (attr->file_index != rec->FileIndex) {
Emsg2(M_ERROR_TERM, 0, _("Record header file index %ld not equal record index %ld\n"),
- rec->FileIndex, attr->file_index);
+ rec->FileIndex, attr->file_index);
}
if (verbose > 1) {
- decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
- build_attr_output_fnames(bjcr, attr);
- print_ls_output(bjcr, attr);
+ decode_stat(attr->attr, &attr->statp, &attr->LinkFI);
+ build_attr_output_fnames(bjcr, attr);
+ print_ls_output(bjcr, attr);
}
fr.JobId = mjcr->JobId;
fr.FileId = 0;
num_files++;
if (verbose && (num_files & 0x7FFF) == 0) {
- char ed1[30], ed2[30], ed3[30], ed4[30];
+ char ed1[30], ed2[30], ed3[30], ed4[30];
Pmsg4(000, _("%s file records. At file:blk=%s:%s bytes=%s\n"),
- edit_uint64_with_commas(num_files, ed1),
- edit_uint64_with_commas(rec->File, ed2),
- edit_uint64_with_commas(rec->Block, ed3),
- edit_uint64_with_commas(mr.VolBytes, ed4));
+ edit_uint64_with_commas(num_files, ed1),
+ edit_uint64_with_commas(rec->File, ed2),
+ edit_uint64_with_commas(rec->Block, ed3),
+ edit_uint64_with_commas(mr.VolBytes, ed4));
}
create_file_attributes_record(db, mjcr, attr->fname, attr->lname,
- attr->type, attr->attr, rec);
+ attr->type, attr->attr, rec);
free_jcr(mjcr);
break;
case STREAM_SPARSE_DATA:
mjcr->JobBytes += rec->data_len;
if (rec->Stream == STREAM_SPARSE_DATA) {
- mjcr->JobBytes -= sizeof(uint64_t);
+ mjcr->JobBytes -= sizeof(uint64_t);
}
- free_jcr(mjcr); /* done using JCR */
+ free_jcr(mjcr); /* done using JCR */
break;
case STREAM_GZIP_DATA:
mjcr->JobBytes += rec->data_len; /* No correct, we should expand it */
- free_jcr(mjcr); /* done using JCR */
+ free_jcr(mjcr); /* done using JCR */
break;
case STREAM_SPARSE_GZIP_DATA:
mjcr->JobBytes += rec->data_len - sizeof(uint64_t); /* No correct, we should expand it */
- free_jcr(mjcr); /* done using JCR */
+ free_jcr(mjcr); /* done using JCR */
break;
/* Win32 GZIP stream */
case STREAM_WIN32_GZIP_DATA:
mjcr->JobBytes += rec->data_len;
- free_jcr(mjcr); /* done using JCR */
+ free_jcr(mjcr); /* done using JCR */
break;
case STREAM_MD5_SIGNATURE:
* record, and then create the attributes record.
*/
static int create_file_attributes_record(B_DB *db, JCR *mjcr,
- char *fname, char *lname, int type,
- char *ap, DEV_RECORD *rec)
+ char *fname, char *lname, int type,
+ char *ap, DEV_RECORD *rec)
{
DCR *dcr = mjcr->dcr;
ar.fname = fname;
} else {
if (!db_create_fileset_record(bjcr, db, fsr)) {
Pmsg2(0, _("Could not create FileSet record \"%s\". ERR=%s\n"),
- fsr->FileSet, db_strerror(db));
- return 0;
+ fsr->FileSet, db_strerror(db));
+ return 0;
}
if (verbose) {
Pmsg1(000, _("Created FileSet record \"%s\"\n"), fsr->FileSet);
* begins running.
*/
static JCR *create_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *label,
- DEV_RECORD *rec)
+ DEV_RECORD *rec)
{
JCR *mjcr;
struct date_time dt;
return mjcr;
}
Pmsg2(000, _("Created new JobId=%u record for original JobId=%u\n"), jr->JobId,
- label->JobId);
- mjcr->JobId = jr->JobId; /* set new JobId */
+ label->JobId);
+ mjcr->JobId = jr->JobId; /* set new JobId */
return mjcr;
}
* at Job termination time.
*/
static int update_job_record(B_DB *db, JOB_DBR *jr, SESSION_LABEL *elabel,
- DEV_RECORD *rec)
+ DEV_RECORD *rec)
{
struct date_time dt;
struct tm tm;
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);
+ rec->VolSessionId, rec->VolSessionTime);
return 0;
}
if (elabel->VerNum >= 11) {
}
if (verbose) {
Pmsg2(000, _("Updated Job termination record for JobId=%u TermStat=%c\n"), jr->JobId,
- jr->JobStatus);
+ jr->JobStatus);
}
if (verbose > 1) {
const char *term_msg;
switch (mjcr->JobStatus) {
case JS_Terminated:
term_msg = _("Backup OK");
- break;
+ break;
case JS_FatalError:
case JS_ErrorTerminated:
term_msg = _("*** Backup Error ***");
- break;
+ break;
case JS_Canceled:
term_msg = _("Backup Canceled");
- break;
+ break;
default:
- term_msg = term_code;
+ term_msg = term_code;
sprintf(term_code, _("Job Termination code: %d"), mjcr->JobStatus);
- break;
+ break;
}
bstrftime(sdt, sizeof(sdt), mjcr->start_time);
bstrftime(edt, sizeof(edt), mjcr->end_time);
"Volume Session Time: %d\n"
"Last Volume Bytes: %s\n"
"Termination: %s\n\n"),
- edt,
- mjcr->JobId,
- mjcr->Job,
- mjcr->fileset_name,
- job_level_to_str(mjcr->JobLevel),
- mjcr->client_name,
- sdt,
- edt,
- edit_uint64_with_commas(mjcr->JobFiles, ec1),
- edit_uint64_with_commas(mjcr->JobBytes, ec2),
- mjcr->VolSessionId,
- mjcr->VolSessionTime,
- edit_uint64_with_commas(mr.VolBytes, ec3),
- term_msg);
+ edt,
+ mjcr->JobId,
+ mjcr->Job,
+ mjcr->fileset_name,
+ job_level_to_str(mjcr->JobLevel),
+ mjcr->client_name,
+ sdt,
+ edt,
+ edit_uint64_with_commas(mjcr->JobFiles, ec1),
+ edit_uint64_with_commas(mjcr->JobBytes, ec2),
+ mjcr->VolSessionId,
+ mjcr->VolSessionTime,
+ edit_uint64_with_commas(mr.VolBytes, ec3),
+ term_msg);
}
free_jcr(mjcr);
return 1;
JOBMEDIA_DBR jmr;
DCR *dcr = mjcr->dcr;
- if (dev->state & ST_TAPE) {
+ if (dev->is_tape()) {
dcr->EndBlock = dev->EndBlock;
dcr->EndFile = dev->EndFile;
+#ifdef needed
} else {
dcr->EndBlock = (uint32_t)dev->file_addr;
dcr->EndFile = (uint32_t)(dev->file_addr >> 32);
- }
+#endif
+ }
memset(&jmr, 0, sizeof(jmr));
jmr.JobId = mjcr->JobId;
}
if (verbose) {
Pmsg2(000, _("Created JobMedia record JobId %d, MediaId %d\n"),
- jmr.JobId, jmr.MediaId);
+ jmr.JobId, jmr.MediaId);
}
return 1;
}
if (!mjcr) {
if (mr.VolJobs > 0) {
Pmsg2(000, _("Could not find SessId=%d SessTime=%d for MD5/SHA1 record.\n"),
- rec->VolSessionId, rec->VolSessionTime);
+ rec->VolSessionId, rec->VolSessionTime);
} else {
- ignored_msgs++;
+ ignored_msgs++;
}
return 0;
}
JCR *jobjcr;
/*
* Transfer as much as possible to the Job JCR. Most important is
- * the JobId and the ClientId.
+ * the JobId and the ClientId.
*/
jobjcr = new_jcr(sizeof(JCR), bscan_free_jcr);
jobjcr->JobType = jr->JobType;
}
/* Dummies to replace askdir.c */
-bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) { return 1;}
-bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
-bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
-bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
-bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
-bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
-bool dir_send_job_status(JCR *jcr) {return 1;}
+bool dir_get_volume_info(DCR *dcr, enum get_vol_info_rw writing) { return 1;}
+bool dir_find_next_appendable_volume(DCR *dcr) { return 1;}
+bool dir_update_volume_info(DCR *dcr, bool relabel) { return 1; }
+bool dir_create_jobmedia_record(DCR *dcr) { return 1; }
+bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr) { return 1; }
+bool dir_update_file_attributes(DCR *dcr, DEV_RECORD *rec) { return 1;}
+bool dir_send_job_status(JCR *jcr) {return 1;}
bool dir_ask_sysop_to_mount_volume(DCR *dcr)
}
force_close_dev(dev);
fprintf(stderr, "Mount Volume \"%s\" on device %s and press return when ready: ",
- dcr->VolumeName, dev->print_name());
+ dcr->VolumeName, dev->print_name());
getchar();
return true;
}
*
* dev.c -- low level operations on device (storage device)
*
- * Kern Sibbald, MM
+ * Kern Sibbald, MM
*
* NOTE!!!! None of these routines are reentrant. You must
- * use lock_device() and unlock_device() at a higher level,
- * or use the xxx_device() equivalents. By moving the
- * thread synchronization to a higher level, we permit
+ * use lock_device() and unlock_device() at a higher level,
+ * or use the xxx_device() equivalents. By moving the
+ * thread synchronization to a higher level, we permit
* the higher level routines to "seize" the device and
- * to carry out operations without worrying about who
- * set what lock (i.e. race conditions).
+ * to carry out operations without worrying about who
+ * set what lock (i.e. race conditions).
*
* Note, this is the device dependent code, and my have
- * to be modified for each system, but is meant to
+ * to be modified for each system, but is meant to
* be as "generic" as possible.
*
* The purpose of this code is to develop a SIMPLE Storage
if (stat(device->device_name, &statp) < 0) {
berrno be;
if (dev) {
- dev->dev_errno = errno;
+ dev->dev_errno = errno;
}
Jmsg2(jcr, M_ERROR, 0, _("Unable to stat device %s: ERR=%s\n"),
- device->device_name, be.strerror());
+ device->device_name, be.strerror());
return NULL;
}
fifo = true;
} else if (!(device->cap_bits & CAP_REQMOUNT)) {
if (dev) {
- dev->dev_errno = ENODEV;
+ dev->dev_errno = ENODEV;
}
Jmsg2(jcr, M_ERROR, 0, _("%s is an unknown device type. Must be tape or directory. st_mode=%x\n"),
- device->device_name, statp.st_mode);
+ device->device_name, statp.st_mode);
return NULL;
}
if (!dev) {
*/
if (dev->is_file() && device->cap_bits & CAP_REQMOUNT) {
if (stat(device->mount_point, &statp) < 0) {
- berrno be;
- dev->dev_errno = errno;
+ berrno be;
+ dev->dev_errno = errno;
Jmsg2(jcr, M_ERROR, 0, _("Unable to stat mount point %s: ERR=%s\n"),
- device->mount_point, be.strerror());
- return NULL;
+ device->mount_point, be.strerror());
+ return NULL;
}
if (!device->mount_command || !device->unmount_command) {
Jmsg0(jcr, M_ERROR_TERM, 0, _("Mount and unmount commands must defined for a device which requires mount.\n"));
if (dev->max_block_size > 1000000) {
Jmsg3(jcr, M_ERROR, 0, _("Block size %u on device %s is too large, using default %u\n"),
- dev->max_block_size, dev->print_name(), DEFAULT_BLOCK_SIZE);
+ dev->max_block_size, dev->print_name(), DEFAULT_BLOCK_SIZE);
dev->max_block_size = 0;
}
if (dev->max_block_size % TAPE_BSIZE != 0) {
Jmsg2(jcr, M_WARNING, 0, _("Max block size %u not multiple of device %s block size.\n"),
- dev->max_block_size, dev->print_name());
+ dev->max_block_size, dev->print_name());
}
dev->errmsg = get_pool_memory(PM_EMSG);
dev->fd = -1;
dev->attached_dcrs = New(dlist(dcr, &dcr->dev_link));
- Dmsg2(29, "init_dev: tape=%d dev_name=%s\n", dev_is_tape(dev), dev->dev_name);
+ Dmsg2(29, "init_dev: tape=%d dev_name=%s\n", dev->is_tape(), dev->dev_name);
return dev;
}
* initialize buffer pointers.
*
* Returns: -1 on error
- * fd on success
+ * fd on success
*
* Note, for a tape, the VolName is the name we give to the
* volume (not really used here), but for a file, the
* starts and snatches up the device.
*/
if (VolName && strcmp(dev->VolCatInfo.VolCatName, VolName) != 0) {
- return -1;
+ return -1;
}
dev->use_count++;
- Mmsg2(&dev->errmsg, _("WARNING!!!! device %s opened %d times!!!\n"),
- dev->print_name(), dev->use_count);
+ Mmsg2(dev->errmsg, _("WARNING!!!! device %s opened %d times!!!\n"),
+ dev->print_name(), dev->use_count);
Emsg1(M_WARNING, 0, "%s", dev->errmsg);
return dev->fd;
}
dev->VolCatInfo.VolCatName[0] = 0;
}
- Dmsg3(29, "open_dev: tape=%d dev_name=%s vol=%s\n", dev_is_tape(dev),
- dev->dev_name, dev->VolCatInfo.VolCatName);
+ Dmsg3(29, "open_dev: tape=%d dev_name=%s vol=%s\n", dev->is_tape(),
+ dev->dev_name, dev->VolCatInfo.VolCatName);
dev->state &= ~(ST_LABEL|ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
dev->label_type = B_BACULA_LABEL;
if (dev->is_tape() || dev->is_fifo()) {
Dmsg2(500, "Open error errno=%d ERR=%s\n", errno, be.strerror());
if (errno == EINTR || errno == EAGAIN) {
Dmsg0(500, "Continue open\n");
- continue;
+ continue;
}
/* Busy wait for specified time (default = 5 mins) */
if (errno == EBUSY && timeout-- > 0) {
Dmsg2(100, "Device %s busy. ERR=%s\n", dev->print_name(), be.strerror());
- bmicrosleep(1, 0);
- continue;
+ bmicrosleep(1, 0);
+ continue;
}
/* IO error (no volume) try 10 times every 6 seconds */
if (errno == EIO && ioerrcnt-- > 0) {
- bmicrosleep(5, 0);
+ bmicrosleep(5, 0);
Dmsg0(500, "Continue open\n");
- continue;
+ continue;
}
dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("Unable to open device %s: ERR=%s\n"),
- dev->print_name(), be.strerror(dev->dev_errno));
+ Mmsg2(dev->errmsg, _("Unable to open device %s: ERR=%s\n"),
+ dev->print_name(), be.strerror(dev->dev_errno));
/* Stop any open timer we set */
if (dev->tid) {
- stop_thread_timer(dev->tid);
- dev->tid = 0;
+ stop_thread_timer(dev->tid);
+ dev->tid = 0;
}
Emsg0(M_FATAL, 0, dev->errmsg);
break;
}
if (dev->fd >= 0) {
if (mode != 0) {
- /* If opened in non-block mode, close it an open it normally */
- mode = 0;
- close(dev->fd);
- goto open_again;
+ /* If opened in non-block mode, close it an open it normally */
+ mode = 0;
+ close(dev->fd);
+ goto open_again;
}
dev->dev_errno = 0;
dev->state |= ST_OPENED;
dev->use_count = 1;
- update_pos_dev(dev); /* update position */
- set_os_device_parameters(dev); /* do system dependent stuff */
+ update_pos_dev(dev); /* update position */
+ set_os_device_parameters(dev); /* do system dependent stuff */
Dmsg0(500, "Open OK\n");
}
/* Stop any open() timer we started */
struct stat filestat;
/*
* Handle opening of File Archive (not a tape)
- */
+ */
if (dev->part == 0) {
dev->file_size = 0;
}
if (dev->VolCatInfo.VolCatName[0] == 0) {
Mmsg(dev->errmsg, _("Could not open file device %s. No Volume name given.\n"),
- dev->print_name());
+ dev->print_name());
dev->fd = -1;
return;
}
if (mount_dev(dev, 1) < 0) {
Mmsg(dev->errmsg, _("Could not mount device %s.\n"),
- dev->print_name());
+ dev->print_name());
Emsg0(M_FATAL, 0, dev->errmsg);
dev->fd = -1;
return;
}
-
+
Dmsg2(29, "open_dev: device is disk %s (mode:%d)\n", archive_name.c_str(), mode);
dev->openmode = mode;
/*
* If we are not trying to access the last part, set mode to
- * OPEN_READ_ONLY as writing would be an error.
+ * OPEN_READ_ONLY as writing would be an error.
*/
if (dev->part < dev->num_parts) {
mode = OPEN_READ_ONLY;
if ((dev->fd = open(archive_name.c_str(), dev->mode, 0640)) < 0) {
berrno be;
dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(),
- be.strerror());
+ Mmsg2(dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name.c_str(),
+ be.strerror());
Emsg0(M_FATAL, 0, dev->errmsg);
} else {
dev->dev_errno = 0;
dev->state |= ST_OPENED;
dev->use_count = 1;
- update_pos_dev(dev); /* update position */
+ update_pos_dev(dev); /* update position */
if (fstat(dev->fd, &filestat) < 0) {
- berrno be;
- dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("Could not fstat: %s, ERR=%s\n"), archive_name.c_str(),
- be.strerror());
- Emsg0(M_FATAL, 0, dev->errmsg);
+ berrno be;
+ dev->dev_errno = errno;
+ Mmsg2(dev->errmsg, _("Could not fstat: %s, ERR=%s\n"), archive_name.c_str(),
+ be.strerror());
+ Emsg0(M_FATAL, 0, dev->errmsg);
} else {
- dev->part_size = filestat.st_size;
+ dev->part_size = filestat.st_size;
}
}
Dmsg4(29, "open_dev: disk fd=%d opened, part=%d/%d, part_size=%u\n", dev->fd, dev->part, dev->num_parts, dev->part_size);
/*
* Rewind the device.
* Returns: true on success
- * false on failure
+ * false on failure
*/
bool rewind_dev(DEVICE *dev)
{
Dmsg1(29, "rewind_dev %s\n", dev->print_name());
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg1(&dev->errmsg, _("Bad call to rewind_dev. Device %s not open\n"),
- dev->print_name());
+ Mmsg1(dev->errmsg, _("Bad call to rewind_dev. Device %s not open\n"),
+ dev->print_name());
Emsg0(M_ABORT, 0, dev->errmsg);
return false;
}
* retrying every 5 seconds.
*/
for (i=dev->max_rewind_wait; ; i -= 5) {
- if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- berrno be;
- clrerror_dev(dev, MTREW);
- if (i == dev->max_rewind_wait) {
+ if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
+ berrno be;
+ clrerror_dev(dev, MTREW);
+ if (i == dev->max_rewind_wait) {
Dmsg1(200, "Rewind error, %s. retrying ...\n", be.strerror());
- }
- if (dev->dev_errno == EIO && i > 0) {
+ }
+ if (dev->dev_errno == EIO && i > 0) {
Dmsg0(200, "Sleeping 5 seconds.\n");
- bmicrosleep(5, 0);
- continue;
- }
- Mmsg2(&dev->errmsg, _("Rewind error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return false;
- }
- break;
+ bmicrosleep(5, 0);
+ continue;
+ }
+ Mmsg2(dev->errmsg, _("Rewind error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ return false;
+ }
+ break;
}
} else if (dev->is_file()) {
if (lseek_dev(dev, (off_t)0, SEEK_SET) < 0) {
- berrno be;
- dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return false;
+ berrno be;
+ dev->dev_errno = errno;
+ Mmsg2(dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ return false;
}
}
return true;
void DEVICE::set_eot()
{
state |= (ST_EOF|ST_EOT|ST_WEOT);
- state &= ~ST_APPEND; /* make tape read-only */
+ state &= ~ST_APPEND; /* make tape read-only */
}
/*
* Position device to end of medium (end of data)
* Returns: true on succes
- * false on error
+ * false on error
*/
bool
eod_dev(DEVICE *dev)
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg1(&dev->errmsg, _("Bad call to eod_dev. Device %s not open\n"),
- dev->print_name());
+ Mmsg1(dev->errmsg, _("Bad call to eod_dev. Device %s not open\n"),
+ dev->print_name());
return false;
}
Dmsg0(29, "eod_dev\n");
pos = lseek_dev(dev, (off_t)0, SEEK_END);
// Dmsg1(100, "====== Seek to %lld\n", pos);
if (pos >= 0) {
- update_pos_dev(dev);
- dev->state |= ST_EOT;
- return true;
+ update_pos_dev(dev);
+ dev->state |= ST_EOT;
+ return true;
}
dev->dev_errno = errno;
berrno be;
- Mmsg2(&dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ Mmsg2(dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
return false;
}
#ifdef MTEOM
Dmsg0(100,"Using FAST FSF for EOM\n");
/* If unknown position, rewind */
if (!dev_get_os_pos(dev, &mt_stat)) {
- if (!rewind_dev(dev)) {
- return false;
- }
+ if (!rewind_dev(dev)) {
+ return false;
+ }
}
mt_com.mt_op = MTFSF;
/*
*/
mt_com.mt_count = INT16_MAX; /* use big positive number */
if (mt_com.mt_count < 0) {
- mt_com.mt_count = INT16_MAX; /* brain damaged system */
+ mt_com.mt_count = INT16_MAX; /* brain damaged system */
}
}
if (dev_cap(dev, CAP_MTIOCGET) && (dev_cap(dev, CAP_FASTFSF) || dev_cap(dev, CAP_EOM))) {
if (dev_cap(dev, CAP_EOM)) {
Dmsg0(100,"Using EOM for EOM\n");
- mt_com.mt_op = MTEOM;
- mt_com.mt_count = 1;
+ mt_com.mt_op = MTEOM;
+ mt_com.mt_count = 1;
}
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- berrno be;
- clrerror_dev(dev, mt_com.mt_op);
+ berrno be;
+ clrerror_dev(dev, mt_com.mt_op);
Dmsg1(50, "ioctl error: %s\n", be.strerror());
- update_pos_dev(dev);
- Mmsg2(&dev->errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return false;
+ update_pos_dev(dev);
+ Mmsg2(dev->errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ return false;
}
if (!dev_get_os_pos(dev, &mt_stat)) {
- berrno be;
- clrerror_dev(dev, -1);
- Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return false;
+ berrno be;
+ clrerror_dev(dev, -1);
+ Mmsg2(dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ return false;
}
Dmsg2(100, "EOD file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
dev->set_eof();
* Rewind then use FSF until EOT reached
*/
if (!rewind_dev(dev)) {
- return false;
+ return false;
}
/*
* Move file by file to the end of the tape
int file_num;
for (file_num=dev->file; !dev->at_eot(); file_num++) {
Dmsg0(200, "eod_dev: doing fsf 1\n");
- if (!fsf_dev(dev, 1)) {
+ if (!fsf_dev(dev, 1)) {
Dmsg0(200, "fsf_dev error.\n");
- return false;
- }
- /*
- * Avoid infinite loop. ***FIXME*** possibly add code
- * to set EOD or to turn off CAP_FASTFSF if on.
- */
- if (file_num == (int)dev->file) {
- struct mtget mt_stat;
+ return false;
+ }
+ /*
+ * Avoid infinite loop. ***FIXME*** possibly add code
+ * to set EOD or to turn off CAP_FASTFSF if on.
+ */
+ if (file_num == (int)dev->file) {
+ struct mtget mt_stat;
Dmsg1(100, "fsf_dev did not advance from file %d\n", file_num);
- if (dev_get_os_pos(dev, &mt_stat)) {
+ if (dev_get_os_pos(dev, &mt_stat)) {
Dmsg2(100, "Adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
- dev->set_eof();
- dev->file = mt_stat.mt_fileno;
- }
- return false;
- }
+ dev->set_eof();
+ dev->file = mt_stat.mt_fileno;
+ }
+ return false;
+ }
}
}
/*
/* If BSF worked and fileno is known (not -1), set file */
if (dev_get_os_pos(dev, &mt_stat)) {
Dmsg2(100, "BSFATEOF adjust file from %d to %d\n", dev->file , mt_stat.mt_fileno);
- dev->file = mt_stat.mt_fileno;
+ dev->file = mt_stat.mt_fileno;
} else {
- dev->file++; /* wing it -- not correct on all OSes */
+ dev->file++; /* wing it -- not correct on all OSes */
}
} else {
- update_pos_dev(dev); /* update position */
+ update_pos_dev(dev); /* update position */
}
Dmsg1(200, "EOD dev->file=%d\n", dev->file);
return ok;
* Set the position of the device -- only for files
* For other devices, there is no generic way to do it.
* Returns: true on succes
- * false on error
+ * false on error
*/
bool update_pos_dev(DEVICE *dev)
{
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg0(&dev->errmsg, _("Bad device call. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad device call. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return false;
}
dev->file_addr = 0;
pos = lseek_dev(dev, (off_t)0, SEEK_CUR);
if (pos < 0) {
- berrno be;
- dev->dev_errno = errno;
+ berrno be;
+ dev->dev_errno = errno;
Pmsg1(000, "Seek error: ERR=%s\n", be.strerror());
- Mmsg2(&dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- ok = false;
+ Mmsg2(dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ ok = false;
} else {
- dev->file_addr = pos;
+ dev->file_addr = pos;
}
}
return ok;
Dmsg0(-20," Bacula status:");
Dmsg2(-20," file=%d block=%d\n", dev->file, dev->block_num);
if (ioctl(dev->fd, MTIOCGET, (char *)&mt_stat) < 0) {
- berrno be;
- dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return 0;
+ berrno be;
+ dev->dev_errno = errno;
+ Mmsg2(dev->errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
+ return 0;
}
Dmsg0(-20, " Device status:");
#if defined(HAVE_LINUX_OS)
if (GMT_EOF(mt_stat.mt_gstat)) {
- stat |= BMT_EOF;
+ stat |= BMT_EOF;
Dmsg0(-20, " EOF");
}
if (GMT_BOT(mt_stat.mt_gstat)) {
- stat |= BMT_BOT;
+ stat |= BMT_BOT;
Dmsg0(-20, " BOT");
}
if (GMT_EOT(mt_stat.mt_gstat)) {
- stat |= BMT_EOT;
+ stat |= BMT_EOT;
Dmsg0(-20, " EOT");
}
if (GMT_SM(mt_stat.mt_gstat)) {
- stat |= BMT_SM;
+ stat |= BMT_SM;
Dmsg0(-20, " SM");
}
if (GMT_EOD(mt_stat.mt_gstat)) {
- stat |= BMT_EOD;
+ stat |= BMT_EOD;
Dmsg0(-20, " EOD");
}
if (GMT_WR_PROT(mt_stat.mt_gstat)) {
- stat |= BMT_WR_PROT;
+ stat |= BMT_WR_PROT;
Dmsg0(-20, " WR_PROT");
}
if (GMT_ONLINE(mt_stat.mt_gstat)) {
- stat |= BMT_ONLINE;
+ stat |= BMT_ONLINE;
Dmsg0(-20, " ONLINE");
}
if (GMT_DR_OPEN(mt_stat.mt_gstat)) {
- stat |= BMT_DR_OPEN;
+ stat |= BMT_DR_OPEN;
Dmsg0(-20, " DR_OPEN");
}
if (GMT_IM_REP_EN(mt_stat.mt_gstat)) {
- stat |= BMT_IM_REP_EN;
+ stat |= BMT_IM_REP_EN;
Dmsg0(-20, " IM_REP_EN");
}
#endif /* !SunOS && !OSF */
/*
* Load medium in device
* Returns: true on success
- * false on failure
+ * false on failure
*/
bool load_dev(DEVICE *dev)
{
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg0(&dev->errmsg, _("Bad call to load_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to load_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return false;
}
#ifndef MTLOAD
Dmsg0(200, "stored: MTLOAD command not available\n");
berrno be;
- dev->dev_errno = ENOTTY; /* function not available */
- Mmsg2(&dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->dev_errno = ENOTTY; /* function not available */
+ Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
return false;
#else
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
berrno be;
dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ Mmsg2(dev->errmsg, _("ioctl MTLOAD error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
return false;
}
return true;
/*
* Rewind device and put it offline
* Returns: true on success
- * false on failure
+ * false on failure
*/
bool offline_dev(DEVICE *dev)
{
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg0(&dev->errmsg, _("Bad call to offline_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to offline_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return false;
}
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
berrno be;
dev->dev_errno = errno;
- Mmsg2(&dev->errmsg, _("ioctl MTOFFL error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ Mmsg2(dev->errmsg, _("ioctl MTOFFL error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
return false;
}
Dmsg1(100, "Offlined device %s\n", dev->print_name());
/*
* Foward space a file
* Returns: true on success
- * false on failure
+ * false on failure
*/
bool
fsf_dev(DEVICE *dev, int num)
if (dev->fd < 0) {
dev->dev_errno = EBADF;
- Mmsg0(&dev->errmsg, _("Bad call to fsf_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to fsf_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return false;
}
mt_com.mt_count = num;
stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
if (stat < 0 || !dev_get_os_pos(dev, &mt_stat)) {
- berrno be;
- dev->state |= ST_EOT;
+ berrno be;
+ dev->state |= ST_EOT;
Dmsg0(200, "Set ST_EOT\n");
- clrerror_dev(dev, MTFSF);
+ clrerror_dev(dev, MTFSF);
Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
Dmsg1(200, "%s", dev->errmsg);
- return false;
+ return false;
}
Dmsg2(200, "fsf file=%d block=%d\n", mt_stat.mt_fileno, mt_stat.mt_blkno);
dev->set_eof();
int rbuf_len;
Dmsg0(200, "FSF has cap_fsf\n");
if (dev->max_block_size == 0) {
- rbuf_len = DEFAULT_BLOCK_SIZE;
+ rbuf_len = DEFAULT_BLOCK_SIZE;
} else {
- rbuf_len = dev->max_block_size;
+ rbuf_len = dev->max_block_size;
}
rbuf = get_memory(rbuf_len);
mt_com.mt_op = MTFSF;
mt_com.mt_count = 1;
while (num-- && !(dev->state & ST_EOT)) {
Dmsg0(100, "Doing read before fsf\n");
- if ((stat = read(dev->fd, (char *)rbuf, rbuf_len)) < 0) {
- if (errno == ENOMEM) { /* tape record exceeds buf len */
- stat = rbuf_len; /* This is OK */
- } else {
- berrno be;
- dev->state |= ST_EOT;
- clrerror_dev(dev, -1);
+ if ((stat = read(dev->fd, (char *)rbuf, rbuf_len)) < 0) {
+ if (errno == ENOMEM) { /* tape record exceeds buf len */
+ stat = rbuf_len; /* This is OK */
+ } else {
+ berrno be;
+ dev->state |= ST_EOT;
+ clrerror_dev(dev, -1);
Dmsg2(100, "Set ST_EOT read errno=%d. ERR=%s\n", dev->dev_errno,
- be.strerror());
+ be.strerror());
Mmsg2(dev->errmsg, _("read error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
Dmsg1(100, "%s", dev->errmsg);
- break;
- }
- }
- if (stat == 0) { /* EOF */
- update_pos_dev(dev);
+ break;
+ }
+ }
+ if (stat == 0) { /* EOF */
+ update_pos_dev(dev);
Dmsg1(100, "End of File mark from read. File=%d\n", dev->file+1);
- /* Two reads of zero means end of tape */
- if (dev->state & ST_EOF) {
- dev->state |= ST_EOT;
+ /* Two reads of zero means end of tape */
+ if (dev->state & ST_EOF) {
+ dev->state |= ST_EOT;
Dmsg0(100, "Set ST_EOT\n");
- break;
- } else {
- dev->set_eof();
- continue;
- }
- } else { /* Got data */
- dev->state &= ~(ST_EOF|ST_EOT);
- }
+ break;
+ } else {
+ dev->set_eof();
+ continue;
+ }
+ } else { /* Got data */
+ dev->state &= ~(ST_EOF|ST_EOT);
+ }
Dmsg0(100, "Doing MTFSF\n");
- stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
- if (stat < 0) { /* error => EOT */
- berrno be;
- dev->state |= ST_EOT;
+ stat = ioctl(dev->fd, MTIOCTOP, (char *)&mt_com);
+ if (stat < 0) { /* error => EOT */
+ berrno be;
+ dev->state |= ST_EOT;
Dmsg0(100, "Set ST_EOT\n");
- clrerror_dev(dev, MTFSF);
- Mmsg2(&dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ clrerror_dev(dev, MTFSF);
+ Mmsg2(dev->errmsg, _("ioctl MTFSF error on %s. ERR=%s.\n"),
+ dev->print_name(), be.strerror());
Dmsg0(100, "Got < 0 for MTFSF\n");
Dmsg1(100, "%s", dev->errmsg);
- } else {
- dev->set_eof();
- }
+ } else {
+ dev->set_eof();
+ }
}
free_memory(rbuf);
} else {
Dmsg0(200, "Doing FSR for FSF\n");
while (num-- && !(dev->state & ST_EOT)) {
- fsr_dev(dev, INT32_MAX); /* returns -1 on EOF or EOT */
+ fsr_dev(dev, INT32_MAX); /* returns -1 on EOF or EOT */
}
if (dev->state & ST_EOT) {
- dev->dev_errno = 0;
+ dev->dev_errno = 0;
Mmsg1(dev->errmsg, _("Device %s at End of Tape.\n"), dev->print_name());
- stat = -1;
+ stat = -1;
} else {
- stat = 0;
+ stat = 0;
}
}
update_pos_dev(dev);
/*
* Backward space a file
* Returns: false on failure
- * true on success
+ * true on success
*/
bool
bsf_dev(DEVICE *dev, int num)
if (!dev->is_tape()) {
Mmsg1(dev->errmsg, _("Device %s cannot BSF because it is not a tape.\n"),
- dev->print_name());
+ dev->print_name());
return false;
}
Dmsg0(29, "bsf_dev\n");
berrno be;
clrerror_dev(dev, MTBSF);
Mmsg2(dev->errmsg, _("ioctl MTBSF error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
}
update_pos_dev(dev);
return stat == 0;
/*
* Foward space a record
* Returns: false on failure
- * true on success
+ * true on success
*/
bool
fsr_dev(DEVICE *dev, int num)
Dmsg1(100, "FSF fail: ERR=%s\n", be.strerror());
if (dev_get_os_pos(dev, &mt_stat)) {
Dmsg4(100, "Adjust from %d:%d to %d:%d\n", dev->file,
- dev->block_num, mt_stat.mt_fileno, mt_stat.mt_blkno);
- dev->file = mt_stat.mt_fileno;
- dev->block_num = mt_stat.mt_blkno;
+ dev->block_num, mt_stat.mt_fileno, mt_stat.mt_blkno);
+ dev->file = mt_stat.mt_fileno;
+ dev->block_num = mt_stat.mt_blkno;
} else {
- if (dev->state & ST_EOF) {
- dev->state |= ST_EOT;
- } else {
- dev->set_eof();
- }
+ if (dev->state & ST_EOF) {
+ dev->state |= ST_EOT;
+ } else {
+ dev->set_eof();
+ }
}
Mmsg2(dev->errmsg, _("ioctl MTFSR error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
}
update_pos_dev(dev);
return stat == 0;
/*
* Backward space a record
* Returns: false on failure
- * true on success
+ * true on success
*/
bool
bsr_dev(DEVICE *dev, int num)
berrno be;
clrerror_dev(dev, MTBSR);
Mmsg2(dev->errmsg, _("ioctl MTBSR error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
}
update_pos_dev(dev);
return stat == 0;
/*
* Reposition the device to file, block
* Returns: false on failure
- * true on success
+ * true on success
*/
bool
reposition_dev(DEVICE *dev, uint32_t file, uint32_t block)
off_t pos = (((off_t)file)<<32) + block;
Dmsg1(100, "===== lseek_dev to %d\n", (int)pos);
if (lseek_dev(dev, pos, SEEK_SET) == (off_t)-1) {
- berrno be;
- dev->dev_errno = errno;
+ berrno be;
+ dev->dev_errno = errno;
Mmsg2(dev->errmsg, _("lseek_dev error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
- return false;
+ dev->print_name(), be.strerror());
+ return false;
}
dev->file = file;
dev->block_num = block;
if (file < dev->file) {
Dmsg0(100, "Rewind_dev\n");
if (!rewind_dev(dev)) {
- return false;
+ return false;
}
}
if (file > dev->file) {
Dmsg1(100, "fsf %d\n", file-dev->file);
if (!fsf_dev(dev, file-dev->file)) {
Dmsg1(100, "fsf failed! ERR=%s\n", strerror_dev(dev));
- return false;
+ return false;
}
Dmsg2(100, "wanted_file=%d at_file=%d\n", file, dev->file);
}
/*
* Write an end of file on the device
* Returns: 0 on success
- * non-zero on failure
+ * non-zero on failure
*/
int
weof_dev(DEVICE *dev, int num)
clrerror_dev(dev, MTWEOF);
if (stat == -1) {
Mmsg2(dev->errmsg, _("ioctl MTWEOF error on %s. ERR=%s.\n"),
- dev->print_name(), be.strerror());
+ dev->print_name(), be.strerror());
}
}
return stat;
struct mtget mt_stat;
char buf[100];
- dev->dev_errno = errno; /* save errno */
+ dev->dev_errno = errno; /* save errno */
if (errno == EIO) {
dev->VolCatInfo.VolCatErrors++;
}
switch (func) {
case -1:
Emsg0(M_ABORT, 0, "Got ENOTTY on read/write!\n");
- break;
+ break;
case MTWEOF:
msg = "WTWEOF";
- dev->capabilities &= ~CAP_EOF; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_EOF; /* turn off feature */
+ break;
#ifdef MTEOM
case MTEOM:
msg = "WTEOM";
- dev->capabilities &= ~CAP_EOM; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_EOM; /* turn off feature */
+ break;
#endif
case MTFSF:
msg = "MTFSF";
- dev->capabilities &= ~CAP_FSF; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_FSF; /* turn off feature */
+ break;
case MTBSF:
msg = "MTBSF";
- dev->capabilities &= ~CAP_BSF; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_BSF; /* turn off feature */
+ break;
case MTFSR:
msg = "MTFSR";
- dev->capabilities &= ~CAP_FSR; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_FSR; /* turn off feature */
+ break;
case MTBSR:
msg = "MTBSR";
- dev->capabilities &= ~CAP_BSR; /* turn off feature */
- break;
+ dev->capabilities &= ~CAP_BSR; /* turn off feature */
+ break;
case MTREW:
msg = "MTREW";
- break;
+ break;
#ifdef MTSETBLK
case MTSETBLK:
msg = "MTSETBLK";
- break;
+ break;
#endif
#ifdef MTSETBSIZ
case MTSETBSIZ:
msg = "MTSETBSIZ";
- break;
+ break;
#endif
#ifdef MTSRSZ
case MTSRSZ:
msg = "MTSRSZ";
- break;
+ break;
#endif
default:
bsnprintf(buf, sizeof(buf), "unknown func code %d", func);
- msg = buf;
- break;
+ msg = buf;
+ break;
}
if (msg != NULL) {
- dev->dev_errno = ENOSYS;
+ dev->dev_errno = ENOSYS;
Mmsg1(dev->errmsg, _("I/O function \"%s\" not supported on this device.\n"), msg);
- Emsg0(M_ERROR, 0, dev->errmsg);
+ Emsg0(M_ERROR, 0, dev->errmsg);
}
}
/* On some systems such as NetBSD, this clears all errors */
get_filename(dev, dev->VolCatInfo.VolCatName, archive_name);
/* Check that the part file is empty */
if ((stat(archive_name.c_str(), &statp) == 0) && (statp.st_size == 0)) {
- unlink(archive_name.c_str());
+ unlink(archive_name.c_str());
}
}
close_dev(DEVICE *dev)
{
if (!dev) {
- Mmsg0(&dev->errmsg, _("Bad call to close_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to close_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return;
}
void force_close_dev(DEVICE *dev)
{
if (!dev) {
- Mmsg0(&dev->errmsg, _("Bad call to force_close_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to force_close_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return;
}
dev->num_parts = 0;
dev->VolCatInfo.VolCatParts = 0;
if (open_first_part(dev) < 0) {
- berrno be;
- Mmsg1(&dev->errmsg, "Unable to truncate device, because I'm unable to open the first part. ERR=%s\n", be.strerror());
+ berrno be;
+ Mmsg1(dev->errmsg, "Unable to truncate device, because I'm unable to open the first part. ERR=%s\n", be.strerror());
}
}
if (ftruncate(dev->fd, 0) != 0) {
berrno be;
- Mmsg1(&dev->errmsg, _("Unable to truncate device. ERR=%s\n"), be.strerror());
+ Mmsg1(dev->errmsg, _("Unable to truncate device. ERR=%s\n"), be.strerror());
return false;
}
return true;
}
-bool
-dev_is_tape(DEVICE *dev)
-{
- return dev->is_tape() ? true : false;
-}
-
-
/*
* return 1 if the device is read for write, and 0 otherwise
* This is meant for checking at the end of a job to see
{
if (!dev) {
dev->dev_errno = EBADF;
- Mmsg0(&dev->errmsg, _("Bad call to term_dev. Device not open\n"));
+ Mmsg0(dev->errmsg, _("Bad call to term_dev. Device not open\n"));
Emsg0(M_FATAL, 0, dev->errmsg);
return;
}
/* ******FIXME******* put these on config variables */
dev->min_wait = 60 * 60;
dev->max_wait = 24 * 60 * 60;
- dev->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */
+ dev->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */
dev->wait_sec = dev->min_wait;
dev->rem_wait_sec = dev->wait_sec;
dev->num_wait = 0;
jcr->min_wait = 60 * 60;
jcr->max_wait = 24 * 60 * 60;
- jcr->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */
+ jcr->max_num_wait = 9; /* 5 waits =~ 1 day, then 1 day at a time */
jcr->wait_sec = jcr->min_wait;
jcr->rem_wait_sec = jcr->wait_sec;
jcr->num_wait = 0;
* The dev timers are used for waiting on a particular device
*
* Returns: true if time doubled
- * false if max time expired
+ * false if max time expired
*/
bool double_dev_wait_time(DEVICE *dev)
{
- dev->wait_sec *= 2; /* double wait time */
+ dev->wait_sec *= 2; /* double wait time */
if (dev->wait_sec > dev->max_wait) { /* but not longer than maxtime */
dev->wait_sec = dev->max_wait;
}
mt_com.mt_op = MTSETBLK;
mt_com.mt_count = 0;
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTSETBLK);
+ clrerror_dev(dev, MTSETBLK);
}
mt_com.mt_op = MTSETDRVBUFFER;
mt_com.mt_count = MT_ST_CLEARBOOLEANS;
if (!dev_cap(dev, CAP_TWOEOF)) {
- mt_com.mt_count |= MT_ST_TWO_FM;
+ mt_com.mt_count |= MT_ST_TWO_FM;
}
if (dev_cap(dev, CAP_EOM)) {
- mt_com.mt_count |= MT_ST_FAST_MTEOM;
+ mt_com.mt_count |= MT_ST_FAST_MTEOM;
}
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTSETBLK);
+ clrerror_dev(dev, MTSETBLK);
}
}
return;
mt_com.mt_op = MTSETBSIZ;
mt_com.mt_count = 0;
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTSETBSIZ);
+ clrerror_dev(dev, MTSETBSIZ);
}
/* Get notified at logical end of tape */
mt_com.mt_op = MTEWARN;
mt_com.mt_count = 1;
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTEWARN);
+ clrerror_dev(dev, MTEWARN);
}
}
return;
mt_com.mt_op = MTSETBSIZ;
mt_com.mt_count = 0;
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTSETBSIZ);
+ clrerror_dev(dev, MTSETBSIZ);
}
}
return;
mt_com.mt_op = MTSRSZ;
mt_com.mt_count = 0;
if (ioctl(dev->fd, MTIOCTOP, (char *)&mt_com) < 0) {
- clrerror_dev(dev, MTSRSZ);
+ clrerror_dev(dev, MTSRSZ);
}
}
return;
static bool dev_get_os_pos(DEVICE *dev, struct mtget *mt_stat)
{
return dev_cap(dev, CAP_MTIOCGET) &&
- ioctl(dev->fd, MTIOCGET, (char *)mt_stat) == 0 &&
- mt_stat->mt_fileno >= 0;
+ ioctl(dev->fd, MTIOCGET, (char *)mt_stat) == 0 &&
+ mt_stat->mt_fileno >= 0;
}
* NOTE! In general, subroutines that have the word
* "device" in the name do locking. Subroutines
* that have the word "dev" in the name do not
- * do locking. Thus if xxx_device() calls
- * yyy_dev(), all is OK, but if xxx_device()
- * calls yyy_device(), everything will hang.
- * Obviously, no zzz_dev() is allowed to call
- * a www_device() or everything falls apart.
+ * do locking. Thus if xxx_device() calls
+ * yyy_dev(), all is OK, but if xxx_device()
+ * calls yyy_device(), everything will hang.
+ * Obviously, no zzz_dev() is allowed to call
+ * a www_device() or everything falls apart.
*
* Concerning the routines lock_device() and block_device()
* see the end of this module for details. In general,
* Note, we are called only from one place in block.c
*
* Returns: true on success
- * false on failure
+ * false on failure
*/
bool fixup_device_block_write_error(DCR *dcr)
{
/* Inform User about end of medium */
Jmsg(jcr, M_INFO, 0, _("End of medium on Volume \"%s\" Bytes=%s Blocks=%s at %s.\n"),
- PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
- edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
- bstrftime(dt, sizeof(dt), time(NULL)));
+ PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
+ edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2),
+ bstrftime(dt, sizeof(dt), time(NULL)));
if (!mount_next_write_volume(dcr, 1)) {
free_block(label_blk);
dcr->block = block;
P(dev->mutex);
unblock_device(dev);
- return false; /* device locked */
+ return false; /* device locked */
}
- P(dev->mutex); /* lock again */
+ P(dev->mutex); /* lock again */
Jmsg(jcr, M_INFO, 0, _("New volume \"%s\" mounted on device %s at %s.\n"),
dcr->VolumeName, dev->print_name(), bstrftime(dt, sizeof(dt), time(NULL)));
if (!write_block_to_dev(dcr)) {
berrno be;
Pmsg1(0, "write_block_to_device Volume label failed. ERR=%s",
- be.strerror(dev->dev_errno));
+ be.strerror(dev->dev_errno));
free_block(label_blk);
dcr->block = block;
unblock_device(dev);
- return false; /* device locked */
+ return false; /* device locked */
}
free_block(label_blk);
dcr->block = block;
foreach_dlist(mdcr, dev->attached_dcrs) {
JCR *mjcr = mdcr->jcr;
if (mjcr->JobId == 0) {
- continue; /* ignore console */
+ continue; /* ignore console */
}
mdcr->NewVol = true;
if (jcr != mjcr) {
- bstrncpy(mdcr->VolumeName, dcr->VolumeName, sizeof(mdcr->VolumeName));
+ bstrncpy(mdcr->VolumeName, dcr->VolumeName, sizeof(mdcr->VolumeName));
}
}
if (!write_block_to_dev(dcr)) {
berrno be;
Pmsg1(0, "write_block_to_device overflow block failed. ERR=%s",
- be.strerror(dev->dev_errno));
+ be.strerror(dev->dev_errno));
unblock_device(dev);
- return false; /* device locked */
+ return false; /* device locked */
}
unblock_device(dev);
- return true; /* device locked */
+ return true; /* device locked */
}
/*
* a file is the directory only.
*
* Returns: false on failure
- * true on success
+ * true on success
*/
bool first_open_device(DEVICE *dev)
{
lock_device(dev);
/* Defer opening files */
- if (!dev_is_tape(dev)) {
+ if (!dev->is_tape()) {
Dmsg0(129, "Device is file, deferring open.\n");
unlock_device(dev);
return true;
if (!dev->is_open()) {
int mode;
if (dev_cap(dev, CAP_STREAM)) {
- mode = OPEN_WRITE_ONLY;
+ mode = OPEN_WRITE_ONLY;
} else {
- mode = OPEN_READ_WRITE;
+ mode = OPEN_READ_WRITE;
}
Dmsg0(129, "Opening device.\n");
dev->open_nowait = true;
if (open_dev(dev, NULL, mode) < 0) {
Emsg1(M_FATAL, 0, _("dev open failed: %s\n"), dev->errmsg);
- dev->open_nowait = false;
- unlock_device(dev);
- return false;
+ dev->open_nowait = false;
+ unlock_device(dev);
+ return false;
}
}
Dmsg1(129, "open_dev %s OK\n", dev->print_name());
if (!dev->is_open()) {
int mode;
if (dev_cap(dev, CAP_STREAM)) {
- mode = OPEN_WRITE_ONLY;
+ mode = OPEN_WRITE_ONLY;
} else {
- mode = OPEN_READ_WRITE;
+ mode = OPEN_READ_WRITE;
}
if (open_dev(dev, dcr->VolCatInfo.VolCatName, mode) < 0) {
- /* If polling, ignore the error */
- if (!dev->poll) {
+ /* If polling, ignore the error */
+ if (!dev->poll) {
Jmsg2(dcr->jcr, M_FATAL, 0, _("Unable to open device %s: ERR=%s\n"),
- dev->print_name(), strerror_dev(dev));
+ dev->print_name(), strerror_dev(dev));
Pmsg2(000, "Unable to open archive %s: ERR=%s\n",
- dev->print_name(), strerror_dev(dev));
- }
- return false;
+ dev->print_name(), strerror_dev(dev));
+ }
+ return false;
}
}
return true;
Dmsg3(500, "lock %d from %s:%d\n", dev->dev_blocked, file, line);
P(dev->mutex);
if (dev->dev_blocked && !pthread_equal(dev->no_wait_id, pthread_self())) {
- dev->num_waiting++; /* indicate that I am waiting */
+ dev->num_waiting++; /* indicate that I am waiting */
while (dev->dev_blocked) {
- if ((stat = pthread_cond_wait(&dev->wait, &dev->mutex)) != 0) {
- V(dev->mutex);
+ if ((stat = pthread_cond_wait(&dev->wait, &dev->mutex)) != 0) {
+ V(dev->mutex);
Emsg1(M_ABORT, 0, _("pthread_cond_wait failure. ERR=%s\n"),
- strerror(stat));
- }
+ strerror(stat));
+ }
}
- dev->num_waiting--; /* no longer waiting */
+ dev->num_waiting--; /* no longer waiting */
}
}
bool stat;
int blocked = dev->dev_blocked;
stat = (blocked == BST_UNMOUNTED) ||
- (blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
+ (blocked == BST_UNMOUNTED_WAITING_FOR_SYSOP);
return stat;
}
{
Dmsg3(500, "block set %d from %s:%d\n", state, file, line);
ASSERT(dev->dev_blocked == BST_NOT_BLOCKED);
- dev->dev_blocked = state; /* make other threads wait */
+ dev->dev_blocked = state; /* make other threads wait */
dev->no_wait_id = pthread_self(); /* allow us to continue */
}
dev->print_name());
}
} else {
- if (!dev_is_tape(dev)) {
+ if (!dev->is_tape()) {
bnet_fsend(dir, _("3906 cannot mount non-tape.\n"));
break;
}
dcr = jcr->dcr;
if (dev) {
P(dev->mutex); /* Use P to avoid indefinite block */
- if (!dev_is_tape(dev)) {
+ if (!dev->is_tape()) {
bnet_fsend(dir, _("3995 Device %s is not an autochanger.\n"),
dev->print_name());
} else if (!dev->is_open()) {
* so can do fast rejection.
*
* returns: 1 if block may contain valid records
- * 0 if block may be skipped (i.e. it contains no records of
- * that can match the bsr).
+ * 0 if block may be skipped (i.e. it contains no records of
+ * that can match the bsr).
*
*/
int match_bsr_block(BSR *bsr, DEV_BLOCK *block)
{
if (!bsr || !bsr->use_fast_rejection || (block->BlockVer < 2)) {
- return 1; /* cannot fast reject */
+ return 1; /* cannot fast reject */
}
for ( ; bsr; bsr=bsr->next) {
if (!match_block_sesstime(bsr, bsr->sesstime, block)) {
- continue;
+ continue;
}
if (!match_block_sessid(bsr, bsr->sessid, block)) {
- continue;
+ continue;
}
return 1;
}
static int match_block_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_BLOCK *block)
{
if (!sesstime) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (sesstime->sesstime == block->VolSessionTime) {
return 1;
static int match_block_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_BLOCK *block)
{
if (!sessid) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (sessid->sessid <= block->VolSessionId && sessid->sessid2 >= block->VolSessionId) {
return 1;
/*********************************************************************
*
- * Match Bootstrap records
- * returns 1 on match
- * returns 0 no match and reposition is set if we should
- * reposition the tape
- * returns -1 no additional matches possible
+ * Match Bootstrap records
+ * returns 1 on match
+ * returns 0 no match and reposition is set if we should
+ * reposition the tape
+ * returns -1 no additional matches possible
*/
int match_bsr(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec, SESSION_LABEL *sessrec)
{
/*
* The bsr->reposition flag is set any time a bsr is done.
- * In this case, we can probably reposition the
- * tape to the next available bsr position.
+ * In this case, we can probably reposition the
+ * tape to the next available bsr position.
*/
if (bsr) {
bsr->reposition = false;
* found or if we cannot use positioning
*/
if (stat != 0 || !bsr->use_positioning) {
- bsr->reposition = false;
+ bsr->reposition = false;
}
} else {
- stat = 1; /* no bsr => match all */
+ stat = 1; /* no bsr => match all */
}
return stat;
}
BSR *found_bsr = NULL;
if (!root_bsr || !root_bsr->use_positioning ||
- !root_bsr->reposition || !dev_is_tape(dev)) {
+ !root_bsr->reposition /* || !dev->is_tape()*/) {
Dmsg2(100, "No nxt_bsr use_pos=%d repos=%d\n", root_bsr->use_positioning, root_bsr->reposition);
return NULL;
}
root_bsr->mount_next_volume = false;
for (bsr=root_bsr; bsr; bsr=bsr->next) {
if (bsr->done || !match_volume(bsr, bsr->volume, &dev->VolHdr, 1)) {
- continue;
+ continue;
}
if (found_bsr == NULL) {
- found_bsr = bsr;
+ found_bsr = bsr;
} else {
- found_bsr = find_smallest_volfile(found_bsr, bsr);
+ found_bsr = find_smallest_volfile(found_bsr, bsr);
}
}
/*
found_bsr_sfile = vf->sfile;
while ( (vf=vf->next) ) {
if (vf->sfile < found_bsr_sfile) {
- found_bsr_sfile = vf->sfile;
+ found_bsr_sfile = vf->sfile;
}
}
vf = bsr->volfile;
bsr_sfile = vf->sfile;
while ( (vf=vf->next) ) {
if (vf->sfile < bsr_sfile) {
- bsr_sfile = vf->sfile;
+ bsr_sfile = vf->sfile;
}
}
if (found_bsr_sfile > bsr_sfile) {
vb = found_bsr->volblock;
found_bsr_sblock = vb->sblock;
while ( (vb=vb->next) ) {
- if (vb->sblock < found_bsr_sblock) {
- found_bsr_sblock = vb->sblock;
- }
+ if (vb->sblock < found_bsr_sblock) {
+ found_bsr_sblock = vb->sblock;
+ }
}
vb = bsr->volblock;
bsr_sblock = vb->sblock;
while ( (vb=vb->next) ) {
- if (vb->sblock < bsr_sblock) {
- bsr_sblock = vb->sblock;
- }
+ if (vb->sblock < bsr_sblock) {
+ bsr_sblock = vb->sblock;
+ }
}
if (found_bsr_sblock > bsr_sblock) {
- return_bsr = bsr;
+ return_bsr = bsr;
}
}
* for consistency with the other match calls.
*
* Returns: true if we should reposition
- * : false otherwise.
+ * : false otherwise.
*/
bool match_set_eof(BSR *bsr, DEV_RECORD *rec)
{
rbsr->done = true;
rbsr->root->reposition = true;
Dmsg2(100, "match_set_eof reposition count=%d found=%d\n",
- rbsr->count, rbsr->found);
+ rbsr->count, rbsr->found);
return true;
}
return false;
* returns -1 no additional matches possible
*/
static int match_all(BSR *bsr, DEV_RECORD *rec, VOLUME_LABEL *volrec,
- SESSION_LABEL *sessrec, bool done)
+ SESSION_LABEL *sessrec, bool done)
{
if (bsr->done) {
goto no_match;
}
if (!match_volfile(bsr, bsr->volfile, rec, 1)) {
Dmsg2(100, "Fail on file. bsr=%d rec=%d\n", bsr->volfile->efile,
- rec->File);
+ rec->File);
goto no_match;
}
if (!match_sesstime(bsr, bsr->sesstime, rec, 1)) {
Dmsg2(100, "Fail on sesstime. bsr=%d rec=%d\n",
- bsr->sesstime->sesstime, rec->VolSessionTime);
+ bsr->sesstime->sesstime, rec->VolSessionTime);
goto no_match;
}
/* NOTE!! This test MUST come after the sesstime test */
if (!match_sessid(bsr, bsr->sessid, rec)) {
Dmsg2(100, "Fail on sessid. bsr=%d rec=%d\n",
- bsr->sessid->sessid, rec->VolSessionId);
+ bsr->sessid->sessid, rec->VolSessionId);
goto no_match;
}
/* NOTE!! This test MUST come after sesstime and sessid tests */
if (!match_findex(bsr, bsr->FileIndex, rec, 1)) {
Dmsg2(100, "Fail on findex. bsr=%d rec=%d\n",
- bsr->FileIndex->findex2, rec->FileIndex);
+ bsr->FileIndex->findex2, rec->FileIndex);
goto no_match;
}
/*
* If a count was specified and we have a FileIndex, assume
- * it is a Bacula created bsr (or the equivalent). We
- * then save the bsr where the match occurred so that
- * after processing the record or records, we can update
- * the found count. I.e. rec->bsr points to the bsr that
- * satisfied the match.
+ * it is a Bacula created bsr (or the equivalent). We
+ * then save the bsr where the match occurred so that
+ * after processing the record or records, we can update
+ * the found count. I.e. rec->bsr points to the bsr that
+ * satisfied the match.
*/
if (bsr->count && bsr->FileIndex) {
rec->bsr = bsr;
- return 1; /* this is a complete match */
+ return 1; /* this is a complete match */
}
/*
* The selections below are not used by Bacula's
* restore command, and don't work because of
- * the rec->bsr = bsr optimization above.
+ * the rec->bsr = bsr optimization above.
*/
if (!match_jobid(bsr, bsr->JobId, sessrec, 1)) {
goto no_match;
static int match_volume(BSR *bsr, BSR_VOLUME *volume, VOLUME_LABEL *volrec, bool done)
{
if (!volume) {
- return 0; /* Volume must match */
+ return 0; /* Volume must match */
}
if (strcmp(volume->VolumeName, volrec->VolName) == 0) {
return 1;
static int match_client(BSR *bsr, BSR_CLIENT *client, SESSION_LABEL *sessrec, bool done)
{
if (!client) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (fnmatch(client->ClientName, sessrec->ClientName, 0) == 0) {
return 1;
static int match_job(BSR *bsr, BSR_JOB *job, SESSION_LABEL *sessrec, bool done)
{
if (!job) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (fnmatch(job->Job, sessrec->Job, 0) == 0) {
return 1;
static int match_job_type(BSR *bsr, BSR_JOBTYPE *job_type, SESSION_LABEL *sessrec, bool done)
{
if (!job_type) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (job_type->JobType == sessrec->JobType) {
return 1;
static int match_job_level(BSR *bsr, BSR_JOBLEVEL *job_level, SESSION_LABEL *sessrec, bool done)
{
if (!job_level) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (job_level->JobLevel == sessrec->JobLevel) {
return 1;
static int match_jobid(BSR *bsr, BSR_JOBID *jobid, SESSION_LABEL *sessrec, bool done)
{
if (!jobid) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (jobid->JobId <= sessrec->JobId && jobid->JobId2 >= sessrec->JobId) {
return 1;
static int match_volfile(BSR *bsr, BSR_VOLFILE *volfile, DEV_RECORD *rec, bool done)
{
if (!volfile) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
/* For the moment, these tests work only with tapes. */
if (!(rec->state & REC_ISTAPE)) {
- return 1; /* All File records OK for this match */
+ return 1; /* All File records OK for this match */
}
// Dmsg3(100, "match_volfile: sfile=%d efile=%d recfile=%d\n",
-// volfile->sfile, volfile->efile, rec->File);
+// volfile->sfile, volfile->efile, rec->File);
if (volfile->sfile <= rec->File && volfile->efile >= rec->File) {
return 1;
}
/* Once we get past last efile, we are done */
if (rec->File > volfile->efile) {
- volfile->done = true; /* set local done */
+ volfile->done = true; /* set local done */
}
if (volfile->next) {
return match_volfile(bsr, volfile->next, rec, volfile->done && done);
bsr->done = true;
bsr->root->reposition = true;
Dmsg2(100, "bsr done from volfile rec=%d volefile=%d\n",
- rec->File, volfile->efile);
+ rec->File, volfile->efile);
}
return 0;
}
static int match_stream(BSR *bsr, BSR_STREAM *stream, DEV_RECORD *rec, bool done)
{
if (!stream) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (stream->stream == rec->Stream) {
return 1;
static int match_sesstime(BSR *bsr, BSR_SESSTIME *sesstime, DEV_RECORD *rec, bool done)
{
if (!sesstime) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (sesstime->sesstime == rec->VolSessionTime) {
return 1;
static int match_sessid(BSR *bsr, BSR_SESSID *sessid, DEV_RECORD *rec)
{
if (!sessid) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (sessid->sessid <= rec->VolSessionId && sessid->sessid2 >= rec->VolSessionId) {
return 1;
/*
* When reading the Volume, the Volume Findex (rec->FileIndex) always
* are found in sequential order. Thus we can make optimizations.
+ *
+ * ***FIXME*** optimizations
+ * We could optimize a lot here by removing the recursion, and
+ * stopping the search earlier -- say when rec->FileIndex > findex->findex2
+ * and findex->next == NULL. Also, the current entry tests could be skipped
+ * if findex->done is set.
*/
static int match_findex(BSR *bsr, BSR_FINDEX *findex, DEV_RECORD *rec, bool done)
{
if (!findex) {
- return 1; /* no specification matches all */
+ return 1; /* no specification matches all */
}
if (findex->findex <= rec->FileIndex && findex->findex2 >= rec->FileIndex) {
return 1;
dcr->VolCatInfo.Slot = 0;
if (!dir_ask_sysop_to_mount_volume(dcr)) {
Jmsg(jcr, M_FATAL, 0, _("Too many errors trying to mount device %s.\n"),
- dev->print_name());
- return false;
+ dev->print_name());
+ return false;
}
}
if (job_canceled(jcr)) {
if (release) {
Dmsg0(100, "mount_next_volume release=1\n");
release_volume(dcr);
- ask = true; /* ask operator to mount tape */
+ ask = true; /* ask operator to mount tape */
}
/*
* Get Director's idea of what tape we should have mounted.
- * in dcr->VolCatInfo
+ * in dcr->VolCatInfo
*/
Dmsg0(200, "Before dir_find_next_appendable_volume.\n");
while (!dir_find_next_appendable_volume(dcr)) {
Dmsg0(200, "not dir_find_next\n");
if (!dir_ask_sysop_to_create_appendable_volume(dcr)) {
- return false;
+ return false;
}
Dmsg0(200, "Again dir_find_next_append...\n");
}
return false;
}
Dmsg3(100, "After find_next_append. Vol=%s Slot=%d Parts=%d\n",
- dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.Slot, dcr->VolCatInfo.VolCatParts);
+ dcr->VolCatInfo.VolCatName, dcr->VolCatInfo.Slot, dcr->VolCatInfo.VolCatParts);
dev->num_parts = dcr->VolCatInfo.VolCatParts;
Dmsg1(100, "autoload_dev returns %d\n", autochanger);
/*
* If we autochanged to correct Volume or (we have not just
- * released the Volume AND we can automount) we go ahead
- * and read the label. If there is no tape in the drive,
- * we will err, recurse and ask the operator the next time.
+ * released the Volume AND we can automount) we go ahead
+ * and read the label. If there is no tape in the drive,
+ * we will err, recurse and ask the operator the next time.
*/
- if (!release && dev_is_tape(dev) && dev_cap(dev, CAP_AUTOMOUNT)) {
+ if (!release && dev->is_tape() && dev_cap(dev, CAP_AUTOMOUNT)) {
ask = false; /* don't ask SYSOP this time */
}
/* Don't ask if not removable */
if (ask && !dir_ask_sysop_to_mount_volume(dcr)) {
Dmsg0(100, "Error return ask_sysop ...\n");
- return false; /* error return */
+ return false; /* error return */
}
if (job_canceled(jcr)) {
return false;
*/
if (!dev->is_dvd()) {
if (!open_device(dcr)) {
- if (dev->poll) {
- goto mount_next_vol;
- } else {
- return false;
- }
+ if (dev->poll) {
+ goto mount_next_vol;
+ } else {
+ return false;
+ }
}
} else {
/*
* Just copy the VolCatName in the device resource
* (usually done by open_dev).
- * It is necessary so we can open the real files later.
+ * It is necessary so we can open the real files later.
*/
bstrncpy(dev->VolCatInfo.VolCatName, dcr->VolCatInfo.VolCatName, sizeof(dev->VolCatInfo.VolCatName));
}
dcr->VolCatInfo.VolCatStatus);
/*
* At this point, dev->VolCatInfo has what is in the drive, if anything,
- * and dcr->VolCatInfo has what the Director wants.
+ * and dcr->VolCatInfo has what the Director wants.
*/
switch (vol_label_status) {
case VOL_OK:
Dmsg1(100, "Vol OK name=%s\n", dcr->VolumeName);
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
recycle = strcmp(dev->VolCatInfo.VolCatStatus, "Recycle") == 0;
- break; /* got a Volume */
+ break; /* got a Volume */
case VOL_NAME_ERROR:
VOLUME_CAT_INFO VolCatInfo;
/* If not removable, Volume is broken */
if (!dev_cap(dev, CAP_REM)) {
Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
- dcr->VolumeName, dev->print_name());
- mark_volume_in_error(dcr);
- goto mount_next_vol;
+ dcr->VolumeName, dev->print_name());
+ mark_volume_in_error(dcr);
+ goto mount_next_vol;
}
Dmsg1(100, "Vol NAME Error Name=%s\n", dcr->VolumeName);
/* If polling and got a previous bad name, ignore it */
if (dev->poll && strcmp(dev->BadVolName, dev->VolHdr.VolName) == 0) {
- ask = true;
+ ask = true;
Dmsg1(200, "Vol Name error supress due to poll. Name=%s\n",
- dcr->VolumeName);
- goto mount_next_vol;
+ dcr->VolumeName);
+ goto mount_next_vol;
}
/*
* OK, we got a different volume mounted. First save the
/* Check if this is a valid Volume in the pool */
bstrncpy(dcr->VolumeName, dev->VolHdr.VolName, sizeof(dcr->VolumeName));
if (!dir_get_volume_info(dcr, GET_VOL_INFO_FOR_WRITE)) {
- bstrncpy(dev->BadVolName, dev->VolHdr.VolName, sizeof(dev->BadVolName));
+ bstrncpy(dev->BadVolName, dev->VolHdr.VolName, sizeof(dev->BadVolName));
Jmsg(jcr, M_WARNING, 0, _("Director wanted Volume \"%s\".\n"
" Current Volume \"%s\" not acceptable because:\n"
" %s"),
- VolCatInfo.VolCatName, dev->VolHdr.VolName,
- jcr->dir_bsock->msg);
- /* Restore desired volume name, note device info out of sync */
- memcpy(&dcr->VolCatInfo, &VolCatInfo, sizeof(dcr->VolCatInfo));
- ask = true;
- goto mount_next_vol;
+ VolCatInfo.VolCatName, dev->VolHdr.VolName,
+ jcr->dir_bsock->msg);
+ /* Restore desired volume name, note device info out of sync */
+ memcpy(&dcr->VolCatInfo, &VolCatInfo, sizeof(dcr->VolCatInfo));
+ ask = true;
+ goto mount_next_vol;
}
Dmsg1(100, "want new name=%s\n", dcr->VolumeName);
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
recycle = strcmp(dev->VolCatInfo.VolCatStatus, "Recycle") == 0;
- break; /* got a Volume */
+ break; /* got a Volume */
/*
* At this point, we assume we have a blank tape mounted.
*/
* previous tape (or nothing).
*/
if (dev_cap(dev, CAP_LABEL) && (dcr->VolCatInfo.VolCatBytes == 0 ||
- (!dev->is_tape() && strcmp(dcr->VolCatInfo.VolCatStatus,
+ (!dev->is_tape() && strcmp(dcr->VolCatInfo.VolCatStatus,
"Recycle") == 0))) {
Dmsg0(100, "Create volume label\n");
- /* Create a new Volume label and write it to the device */
- if (!write_new_volume_label_to_dev(dcr, dcr->VolumeName,
- dcr->pool_name)) {
+ /* Create a new Volume label and write it to the device */
+ if (!write_new_volume_label_to_dev(dcr, dcr->VolumeName,
+ dcr->pool_name)) {
Dmsg0(100, "!write_vol_label\n");
- goto mount_next_vol;
- }
+ goto mount_next_vol;
+ }
Dmsg0(100, "dir_update_vol_info. Set Append\n");
/* Copy Director's info into the device info */
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
- if (!dir_update_volume_info(dcr, true)) { /* indicate tape labeled */
- return false;
- }
+ memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
+ if (!dir_update_volume_info(dcr, true)) { /* indicate tape labeled */
+ return false;
+ }
Jmsg(jcr, M_INFO, 0, _("Labeled new Volume \"%s\" on device %s.\n"),
- dcr->VolumeName, dev->print_name());
- goto read_volume; /* read label we just wrote */
+ dcr->VolumeName, dev->print_name());
+ goto read_volume; /* read label we just wrote */
}
/* If not removable, Volume is broken */
if (!dev_cap(dev, CAP_REM)) {
Jmsg(jcr, M_WARNING, 0, _("Volume \"%s\" not on device %s.\n"),
- dcr->VolumeName, dev->print_name());
- mark_volume_in_error(dcr);
- if (autochanger) {
- mark_volume_not_inchanger(dcr);
- }
- goto mount_next_vol;
+ dcr->VolumeName, dev->print_name());
+ mark_volume_in_error(dcr);
+ if (autochanger) {
+ mark_volume_not_inchanger(dcr);
+ }
+ goto mount_next_vol;
}
/* NOTE! Fall-through wanted. */
case VOL_NO_MEDIA:
ask = true;
/* Needed, so the medium can be changed */
if (dev_cap(dev, CAP_REQMOUNT)) {
- close_dev(dev);
+ close_dev(dev);
}
goto mount_next_vol;
}
* but never written. If so, rewrite the label but set as
* VOL_LABEL. We rewind and return the label (reconstructed)
* in the block so that in the case of a new tape, data can
- * be appended just after the block label. If we are writing
+ * be appended just after the block label. If we are writing
* a second volume, the calling routine will write the label
* before writing the overflow block.
*
*/
if (dev->VolHdr.LabelType == PRE_LABEL || recycle) {
if (!rewrite_volume_label(dcr, recycle)) {
- goto mount_next_vol;
+ goto mount_next_vol;
}
} else {
/*
*/
Dmsg0(200, "Device previously written, moving to end of data\n");
Jmsg(jcr, M_INFO, 0, _("Volume \"%s\" previously written, moving to end of data.\n"),
- dcr->VolumeName);
+ dcr->VolumeName);
if (!eod_dev(dev)) {
Jmsg(jcr, M_ERROR, 0, _("Unable to position to end of data on device %s: ERR=%s\n"),
- dev->print_name(), strerror_dev(dev));
- mark_volume_in_error(dcr);
- goto mount_next_vol;
+ dev->print_name(), strerror_dev(dev));
+ mark_volume_in_error(dcr);
+ goto mount_next_vol;
}
/* *****FIXME**** we should do some checking for files too */
- if (dev_is_tape(dev)) {
- /*
- * Check if we are positioned on the tape at the same place
- * that the database says we should be.
- */
- if (dev->VolCatInfo.VolCatFiles == dev_file(dev)) {
+ if (dev->is_tape()) {
+ /*
+ * Check if we are positioned on the tape at the same place
+ * that the database says we should be.
+ */
+ if (dev->VolCatInfo.VolCatFiles == dev_file(dev)) {
Jmsg(jcr, M_INFO, 0, _("Ready to append to end of Volume \"%s\" at file=%d.\n"),
- dcr->VolumeName, dev_file(dev));
- } else {
+ dcr->VolumeName, dev_file(dev));
+ } else {
Jmsg(jcr, M_ERROR, 0, _("I cannot write on Volume \"%s\" because:\n"
"The number of files mismatch! Volume=%u Catalog=%u\n"),
- dcr->VolumeName, dev_file(dev), dev->VolCatInfo.VolCatFiles);
- mark_volume_in_error(dcr);
- goto mount_next_vol;
- }
+ dcr->VolumeName, dev_file(dev), dev->VolCatInfo.VolCatFiles);
+ mark_volume_in_error(dcr);
+ goto mount_next_vol;
+ }
}
- dev->VolCatInfo.VolCatMounts++; /* Update mounts */
+ dev->VolCatInfo.VolCatMounts++; /* Update mounts */
Dmsg1(100, "update volinfo mounts=%d\n", dev->VolCatInfo.VolCatMounts);
if (!dir_update_volume_info(dcr, false)) {
- return false;
+ return false;
}
/* Return an empty block */
- empty_block(block); /* we used it for reading so set for write */
+ empty_block(block); /* we used it for reading so set for write */
}
dev->set_append();
Dmsg0(100, "set APPEND, normal return from read_dev_for_append\n");
{
DEVICE *dev = dcr->dev;
Jmsg(dcr->jcr, M_INFO, 0, _("Marking Volume \"%s\" in Error in Catalog.\n"),
- dcr->VolumeName);
+ dcr->VolumeName);
bstrncpy(dev->VolCatInfo.VolCatStatus, "Error", sizeof(dev->VolCatInfo.VolCatStatus));
Dmsg0(100, "dir_update_vol_info. Set Error.\n");
dir_update_volume_info(dcr, false);
dev->clear_read();
if (!acquire_device_for_read(dcr)) {
Jmsg2(jcr, M_FATAL, 0, "Cannot open Dev=%s, Vol=%s\n", dev->print_name(),
- dcr->VolumeName);
- return false;
+ dcr->VolumeName);
+ return false;
}
- return true; /* next volume mounted */
+ return true; /* next volume mounted */
}
Dmsg0(90, "End of Device reached.\n");
return false;
if (jcr) {
Jmsg(jcr, M_FATAL, 0, _("Bootstrap file error: %s\n"
" : Line %d, col %d of file %s\n%s\n"),
- buf, lc->line_no, lc->col_no, lc->fname, lc->line);
+ buf, lc->line_no, lc->col_no, lc->fname, lc->line);
} else {
e_msg(file, line, M_FATAL, 0, _("Bootstrap file error: %s\n"
" : Line %d, col %d of file %s\n%s\n"),
- buf, lc->line_no, lc->col_no, lc->fname, lc->line);
+ buf, lc->line_no, lc->col_no, lc->fname, lc->line);
}
}
/*********************************************************************
*
- * Parse Bootstrap file
+ * Parse Bootstrap file
*
*/
BSR *parse_bsr(JCR *jcr, char *fname)
while ((token=lex_get_token(lc, T_ALL)) != T_EOF) {
Dmsg1(200, "parse got token=%s\n", lex_tok_to_str(token));
if (token == T_EOL) {
- continue;
+ continue;
}
for (i=0; items[i].name; i++) {
- if (strcasecmp(items[i].name, lc->str) == 0) {
- token = lex_get_token(lc, T_ALL);
+ if (strcasecmp(items[i].name, lc->str) == 0) {
+ token = lex_get_token(lc, T_ALL);
Dmsg1 (200, "in T_IDENT got token=%s\n", lex_tok_to_str(token));
- if (token != T_EQUALS) {
+ if (token != T_EQUALS) {
scan_err1(lc, "expected an equals, got: %s", lc->str);
- bsr = NULL;
- break;
- }
+ bsr = NULL;
+ break;
+ }
Dmsg1(200, "calling handler for %s\n", items[i].name);
- /* Call item handler */
- bsr = items[i].handler(lc, bsr);
- i = -1;
- break;
- }
+ /* Call item handler */
+ bsr = items[i].handler(lc, bsr);
+ i = -1;
+ break;
+ }
}
if (i >= 0) {
Dmsg1(200, "Keyword = %s\n", lc->str);
scan_err1(lc, "Keyword %s not found", lc->str);
- bsr = NULL;
- break;
+ bsr = NULL;
+ break;
}
if (!bsr) {
- break;
+ break;
}
}
lc = lex_close_file(lc);
* all bsrs to have both sesstime and sessid set before
* we do fast rejection.
*/
- if (!(bsr->sesstime && bsr->sessid)) {
- return false;
- }
- if (bsr->next) {
- return is_fast_rejection_ok(bsr->next);
+ for ( ; bsr; bsr=bsr->next) {
+ if (!(bsr->sesstime && bsr->sessid)) {
+ return false;
+ }
}
return true;
}
{
/*
* Every bsr should have a volfile entry and a volblock entry
- * if we are going to use positioning
+ * if we are going to use positioning
*/
- if (!bsr->volfile || !bsr->volblock) {
- return false;
- }
- if (bsr->next) {
- return is_positioning_ok(bsr->next);
+ for ( ; bsr; bsr=bsr->next) {
+ if (!bsr->volfile || !bsr->volblock) {
+ return false;
+ }
}
return true;
}
for (p=lc->str; p && *p; ) {
n = strchr(p, '|');
if (n) {
- *n++ = 0;
+ *n++ = 0;
}
volume = (BSR_VOLUME *)malloc(sizeof(BSR_VOLUME));
memset(volume, 0, sizeof(BSR_VOLUME));
bstrncpy(volume->VolumeName, p, sizeof(volume->VolumeName));
/* Add it to the end of the volume chain */
if (!bsr->volume) {
- bsr->volume = volume;
+ bsr->volume = volume;
} else {
- BSR_VOLUME *bc = bsr->volume;
- for ( ;bc->next; bc=bc->next)
- { }
- bc->next = volume;
+ BSR_VOLUME *bc = bsr->volume;
+ for ( ;bc->next; bc=bc->next)
+ { }
+ bc->next = volume;
}
p = n;
}
}
if (!bsr->volume) {
Emsg1(M_ERROR,0, _("MediaType %s in bsr at inappropriate place.\n"),
- lc->str);
+ lc->str);
return bsr;
}
BSR_VOLUME *bv;
for (;;) {
token = lex_get_token(lc, T_NAME);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
client = (BSR_CLIENT *)malloc(sizeof(BSR_CLIENT));
memset(client, 0, sizeof(BSR_CLIENT));
bstrncpy(client->ClientName, lc->str, sizeof(client->ClientName));
/* Add it to the end of the client chain */
if (!bsr->client) {
- bsr->client = client;
+ bsr->client = client;
} else {
- BSR_CLIENT *bc = bsr->client;
- for ( ;bc->next; bc=bc->next)
- { }
- bc->next = client;
+ BSR_CLIENT *bc = bsr->client;
+ for ( ;bc->next; bc=bc->next)
+ { }
+ bc->next = client;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_NAME);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
job = (BSR_JOB *)malloc(sizeof(BSR_JOB));
memset(job, 0, sizeof(BSR_JOB));
bstrncpy(job->Job, lc->str, sizeof(job->Job));
/* Add it to the end of the client chain */
if (!bsr->job) {
- bsr->job = job;
+ bsr->job = job;
} else {
- /* Add to end of chain */
- BSR_JOB *bc = bsr->job;
- for ( ;bc->next; bc=bc->next)
- { }
- bc->next = job;
+ /* Add to end of chain */
+ BSR_JOB *bc = bsr->job;
+ for ( ;bc->next; bc=bc->next)
+ { }
+ bc->next = job;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32_RANGE);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
findex = (BSR_FINDEX *)malloc(sizeof(BSR_FINDEX));
memset(findex, 0, sizeof(BSR_FINDEX));
findex->findex2 = lc->pint32_val2;
/* Add it to the end of the chain */
if (!bsr->FileIndex) {
- bsr->FileIndex = findex;
+ bsr->FileIndex = findex;
} else {
- /* Add to end of chain */
- BSR_FINDEX *bs = bsr->FileIndex;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = findex;
+ /* Add to end of chain */
+ BSR_FINDEX *bs = bsr->FileIndex;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = findex;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32_RANGE);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
jobid = (BSR_JOBID *)malloc(sizeof(BSR_JOBID));
memset(jobid, 0, sizeof(BSR_JOBID));
jobid->JobId2 = lc->pint32_val2;
/* Add it to the end of the chain */
if (!bsr->JobId) {
- bsr->JobId = jobid;
+ bsr->JobId = jobid;
} else {
- /* Add to end of chain */
- BSR_JOBID *bs = bsr->JobId;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = jobid;
+ /* Add to end of chain */
+ BSR_JOBID *bs = bsr->JobId;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = jobid;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32_RANGE);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
volfile = (BSR_VOLFILE *)malloc(sizeof(BSR_VOLFILE));
memset(volfile, 0, sizeof(BSR_VOLFILE));
volfile->efile = lc->pint32_val2;
/* Add it to the end of the chain */
if (!bsr->volfile) {
- bsr->volfile = volfile;
+ bsr->volfile = volfile;
} else {
- /* Add to end of chain */
- BSR_VOLFILE *bs = bsr->volfile;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = volfile;
+ /* Add to end of chain */
+ BSR_VOLFILE *bs = bsr->volfile;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = volfile;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32_RANGE);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
volblock = (BSR_VOLBLOCK *)malloc(sizeof(BSR_VOLBLOCK));
memset(volblock, 0, sizeof(BSR_VOLBLOCK));
volblock->eblock = lc->pint32_val2;
/* Add it to the end of the chain */
if (!bsr->volblock) {
- bsr->volblock = volblock;
+ bsr->volblock = volblock;
} else {
- /* Add to end of chain */
- BSR_VOLBLOCK *bs = bsr->volblock;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = volblock;
+ /* Add to end of chain */
+ BSR_VOLBLOCK *bs = bsr->volblock;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = volblock;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32_RANGE);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
sid = (BSR_SESSID *)malloc(sizeof(BSR_SESSID));
memset(sid, 0, sizeof(BSR_SESSID));
sid->sessid2 = lc->pint32_val2;
/* Add it to the end of the chain */
if (!bsr->sessid) {
- bsr->sessid = sid;
+ bsr->sessid = sid;
} else {
- /* Add to end of chain */
- BSR_SESSID *bs = bsr->sessid;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = sid;
+ /* Add to end of chain */
+ BSR_SESSID *bs = bsr->sessid;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = sid;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_PINT32);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
stime = (BSR_SESSTIME *)malloc(sizeof(BSR_SESSTIME));
memset(stime, 0, sizeof(BSR_SESSTIME));
stime->sesstime = lc->pint32_val;
/* Add it to the end of the chain */
if (!bsr->sesstime) {
- bsr->sesstime = stime;
+ bsr->sesstime = stime;
} else {
- /* Add to end of chain */
- BSR_SESSTIME *bs = bsr->sesstime;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = stime;
+ /* Add to end of chain */
+ BSR_SESSTIME *bs = bsr->sesstime;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = stime;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
for (;;) {
token = lex_get_token(lc, T_INT32);
if (token == T_ERROR) {
- return NULL;
+ return NULL;
}
stream = (BSR_STREAM *)malloc(sizeof(BSR_STREAM));
memset(stream, 0, sizeof(BSR_STREAM));
stream->stream = lc->int32_val;
/* Add it to the end of the chain */
if (!bsr->stream) {
- bsr->stream = stream;
+ bsr->stream = stream;
} else {
- /* Add to end of chain */
- BSR_STREAM *bs = bsr->stream;
- for ( ;bs->next; bs=bs->next)
- { }
- bs->next = stream;
+ /* Add to end of chain */
+ BSR_STREAM *bs = bsr->stream;
+ for ( ;bs->next; bs=bs->next)
+ { }
+ bs->next = stream;
}
token = lex_get_token(lc, T_ALL);
if (token != T_COMMA) {
- break;
+ break;
}
}
return bsr;
/*********************************************************************
*
- * Free bsr resources
+ * Free bsr resources
*/
static void free_bsr_item(BSR *bsr)
* is not already in the list.
*
* returns: 1 if volume added
- * 0 if volume already in list
+ * 0 if volume already in list
*/
int add_vol(JCR *jcr, VOL_LIST *vol)
{
VOL_LIST *next = jcr->VolList;
- if (!next) { /* list empty ? */
- jcr->VolList = vol; /* yes, add volume */
+ if (!next) { /* list empty ? */
+ jcr->VolList = vol; /* yes, add volume */
} else {
for ( ; next->next; next=next->next) {
- if (strcmp(vol->VolumeName, next->VolumeName) == 0) {
- if (vol->start_file < next->start_file) {
- next->start_file = vol->start_file;
- }
- return 0; /* already in list */
- }
+ if (strcmp(vol->VolumeName, next->VolumeName) == 0) {
+ if (vol->start_file < next->start_file) {
+ next->start_file = vol->start_file;
+ }
+ return 0; /* already in list */
+ }
}
if (strcmp(vol->VolumeName, next->VolumeName) == 0) {
- if (vol->start_file < next->start_file) {
- next->start_file = vol->start_file;
- }
- return 0; /* already in list */
+ if (vol->start_file < next->start_file) {
+ next->start_file = vol->start_file;
+ }
+ return 0; /* already in list */
}
- next->next = vol; /* add volume */
+ next->next = vol; /* add volume */
}
return 1;
}
if (jcr->bsr) {
BSR *bsr = jcr->bsr;
if (!bsr->volume || !bsr->volume->VolumeName) {
- return;
+ return;
}
for ( ; bsr; bsr=bsr->next) {
- BSR_VOLUME *bsrvol;
- BSR_VOLFILE *volfile;
- uint32_t sfile = UINT32_MAX;
-
- /* Find minimum start file so that we can forward space to it */
- for (volfile = bsr->volfile; volfile; volfile=volfile->next) {
- if (volfile->sfile < sfile) {
- sfile = volfile->sfile;
- }
- }
- /* Now add volumes for this bsr */
- for (bsrvol = bsr->volume; bsrvol; bsrvol=bsrvol->next) {
- vol = new_vol();
- bstrncpy(vol->VolumeName, bsrvol->VolumeName, sizeof(vol->VolumeName));
- bstrncpy(vol->MediaType, bsrvol->MediaType, sizeof(vol->MediaType));
- vol->start_file = sfile;
- if (add_vol(jcr, vol)) {
- jcr->NumVolumes++;
+ BSR_VOLUME *bsrvol;
+ BSR_VOLFILE *volfile;
+ uint32_t sfile = UINT32_MAX;
+
+ /* Find minimum start file so that we can forward space to it */
+ for (volfile = bsr->volfile; volfile; volfile=volfile->next) {
+ if (volfile->sfile < sfile) {
+ sfile = volfile->sfile;
+ }
+ }
+ /* Now add volumes for this bsr */
+ for (bsrvol = bsr->volume; bsrvol; bsrvol=bsrvol->next) {
+ vol = new_vol();
+ bstrncpy(vol->VolumeName, bsrvol->VolumeName, sizeof(vol->VolumeName));
+ bstrncpy(vol->MediaType, bsrvol->MediaType, sizeof(vol->MediaType));
+ vol->start_file = sfile;
+ if (add_vol(jcr, vol)) {
+ jcr->NumVolumes++;
Dmsg2(400, "Added volume=%s mediatype=%s\n", vol->VolumeName,
- vol->MediaType);
- } else {
+ vol->MediaType);
+ } else {
Dmsg1(400, "Duplicate volume %s\n", vol->VolumeName);
- free((char *)vol);
- }
- sfile = 0; /* start at beginning of second volume */
- }
+ free((char *)vol);
+ }
+ sfile = 0; /* start at beginning of second volume */
+ }
}
} else {
/* This is the old way -- deprecated */
for (p = jcr->dcr->VolumeName; p && *p; ) {
n = strchr(p, '|'); /* volume name separator */
- if (n) {
- *n++ = 0; /* Terminate name */
- }
- vol = new_vol();
- bstrncpy(vol->VolumeName, p, sizeof(vol->VolumeName));
- bstrncpy(vol->MediaType, jcr->dcr->media_type, sizeof(vol->MediaType));
- if (add_vol(jcr, vol)) {
- jcr->NumVolumes++;
- } else {
- free((char *)vol);
- }
- p = n;
+ if (n) {
+ *n++ = 0; /* Terminate name */
+ }
+ vol = new_vol();
+ bstrncpy(vol->VolumeName, p, sizeof(vol->VolumeName));
+ bstrncpy(vol->MediaType, jcr->dcr->media_type, sizeof(vol->MediaType));
+ if (add_vol(jcr, vol)) {
+ jcr->NumVolumes++;
+ } else {
+ free((char *)vol);
+ }
+ p = n;
}
}
}
char * dev_vol_name(DEVICE *dev);
uint32_t dev_block(DEVICE *dev);
uint32_t dev_file(DEVICE *dev);
-bool dev_is_tape(DEVICE *dev);
/* From dvd.c */
bool dvd_close_job(DCR *dcr);
/* Forward referenced functions */
static void handle_session_record(DEVICE *dev, DEV_RECORD *rec, SESSION_LABEL *sessrec);
static BSR *position_to_first_file(JCR *jcr, DEVICE *dev);
-static int try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev);
+static bool try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev);
#ifdef DEBUG
static char *rec_state_to_str(DEV_RECORD *rec);
#endif
bool ok = true;
bool done = false;
SESSION_LABEL sessrec;
- dlist *recs; /* linked list of rec packets open */
+ dlist *recs; /* linked list of rec packets open */
recs = New(dlist(rec, &rec->link));
position_to_first_file(jcr, dev);
for ( ; ok && !done; ) {
if (job_canceled(jcr)) {
- ok = false;
- break;
+ ok = false;
+ break;
}
if (!read_block_from_device(dcr, CHECK_BLOCK_NUMBERS)) {
- if (dev->at_eot()) {
- DEV_RECORD *trec = new_record();
+ if (dev->at_eot()) {
+ DEV_RECORD *trec = new_record();
Jmsg(jcr, M_INFO, 0, "End of Volume at file %u on device %s, Volume \"%s\"\n",
- dev->file, dev->print_name(), dcr->VolumeName);
- if (!mount_cb(dcr)) {
+ dev->file, dev->print_name(), dcr->VolumeName);
+ if (!mount_cb(dcr)) {
Jmsg(jcr, M_INFO, 0, "End of all volumes.\n");
- ok = false; /* Stop everything */
- /*
- * Create EOT Label so that Media record may
- * be properly updated because this is the last
- * tape.
- */
- trec->FileIndex = EOT_LABEL;
- trec->File = dev->file;
- ok = record_cb(dcr, trec);
- free_record(trec);
- if (jcr->mount_next_volume) {
- jcr->mount_next_volume = false;
- dev->clear_eot();
- }
- break;
- }
- jcr->mount_next_volume = false;
- /*
- * We just have a new tape up, now read the label (first record)
- * and pass it off to the callback routine, then continue
- * most likely reading the previous record.
- */
- read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK);
- read_record_from_block(block, trec);
- handle_session_record(dev, trec, &sessrec);
- ok = record_cb(dcr, trec);
- free_record(trec);
- position_to_first_file(jcr, dev);
- /* After reading label, we must read first data block */
- continue;
+ ok = false; /* Stop everything */
+ /*
+ * Create EOT Label so that Media record may
+ * be properly updated because this is the last
+ * tape.
+ */
+ trec->FileIndex = EOT_LABEL;
+ trec->File = dev->file;
+ ok = record_cb(dcr, trec);
+ free_record(trec);
+ if (jcr->mount_next_volume) {
+ jcr->mount_next_volume = false;
+ dev->clear_eot();
+ }
+ break;
+ }
+ jcr->mount_next_volume = false;
+ /*
+ * We just have a new tape up, now read the label (first record)
+ * and pass it off to the callback routine, then continue
+ * most likely reading the previous record.
+ */
+ read_block_from_device(dcr, NO_BLOCK_NUMBER_CHECK);
+ read_record_from_block(block, trec);
+ handle_session_record(dev, trec, &sessrec);
+ ok = record_cb(dcr, trec);
+ free_record(trec);
+ position_to_first_file(jcr, dev);
+ /* After reading label, we must read first data block */
+ continue;
- } else if (dev->at_eof()) {
- if (verbose) {
+ } else if (dev->at_eof()) {
+ if (verbose) {
Jmsg(jcr, M_INFO, 0, "Got EOF at file %u on device %s, Volume \"%s\"\n",
- dev->file, dev->print_name(), dcr->VolumeName);
- }
+ dev->file, dev->print_name(), dcr->VolumeName);
+ }
Dmsg3(200, "Got EOF at file %u on device %s, Volume \"%s\"\n",
- dev->file, dev->print_name(), dcr->VolumeName);
- continue;
- } else if (dev_state(dev, ST_SHORT)) {
+ dev->file, dev->print_name(), dcr->VolumeName);
+ continue;
+ } else if (dev_state(dev, ST_SHORT)) {
Jmsg1(jcr, M_ERROR, 0, "%s", dev->errmsg);
- continue;
- } else {
- /* I/O error or strange end of tape */
- display_tape_error_status(jcr, dev);
- if (forge_on || jcr->ignore_label_errors) {
- fsr_dev(dev, 1); /* try skipping bad record */
+ continue;
+ } else {
+ /* I/O error or strange end of tape */
+ display_tape_error_status(jcr, dev);
+ if (forge_on || jcr->ignore_label_errors) {
+ fsr_dev(dev, 1); /* try skipping bad record */
Pmsg0(000, "Did fsr\n");
- continue; /* try to continue */
- }
- ok = false; /* stop everything */
- break;
- }
+ continue; /* try to continue */
+ }
+ ok = false; /* stop everything */
+ break;
+ }
}
- Dmsg2(300, "New block at position=(file:block) %d:%d\n", dev->file, dev->block_num);
+ Dmsg2(300, "New block at position=(file:block) %u:%u\n", dev->file, dev->block_num);
#ifdef if_and_when_FAST_BLOCK_REJECTION_is_working
/* this does not stop when file/block are too big */
if (!match_bsr_block(jcr->bsr, block)) {
- if (try_repositioning(jcr, rec, dev)) {
- break; /* get next volume */
- }
- continue; /* skip this record */
+ if (try_repositioning(jcr, rec, dev)) {
+ break; /* get next volume */
+ }
+ continue; /* skip this record */
}
#endif
*/
bool found = false;
foreach_dlist(rec, recs) {
- if (rec->VolSessionId == block->VolSessionId &&
- rec->VolSessionTime == block->VolSessionTime) {
- found = true;
- break;
- }
+ if (rec->VolSessionId == block->VolSessionId &&
+ rec->VolSessionTime == block->VolSessionTime) {
+ found = true;
+ break;
+ }
}
if (!found) {
- rec = new_record();
- recs->prepend(rec);
+ rec = new_record();
+ recs->prepend(rec);
Dmsg2(300, "New record for SI=%d ST=%d\n",
- block->VolSessionId, block->VolSessionTime);
+ block->VolSessionId, block->VolSessionTime);
}
Dmsg3(300, "After mount next vol. stat=%s blk=%d rem=%d\n", rec_state_to_str(rec),
- block->BlockNumber, rec->remainder);
+ block->BlockNumber, rec->remainder);
record = 0;
rec->state = 0;
Dmsg1(300, "Block empty %d\n", is_block_empty(rec));
for (rec->state=0; !is_block_empty(rec); ) {
- if (!read_record_from_block(block, rec)) {
+ if (!read_record_from_block(block, rec)) {
Dmsg3(400, "!read-break. state=%s blk=%d rem=%d\n", rec_state_to_str(rec),
- block->BlockNumber, rec->remainder);
- break;
- }
- Dmsg5(300, "read-OK. state=%s blk=%d rem=%d file:block=%d:%d\n",
- rec_state_to_str(rec), block->BlockNumber, rec->remainder,
- dev->file, dev->block_num);
- /*
- * At this point, we have at least a record header.
- * Now decide if we want this record or not, but remember
- * before accessing the record, we may need to read again to
- * get all the data.
- */
- record++;
+ block->BlockNumber, rec->remainder);
+ break;
+ }
+ Dmsg5(300, "read-OK. state=%s blk=%d rem=%d file:block=%u:%u\n",
+ rec_state_to_str(rec), block->BlockNumber, rec->remainder,
+ dev->file, dev->block_num);
+ /*
+ * At this point, we have at least a record header.
+ * Now decide if we want this record or not, but remember
+ * before accessing the record, we may need to read again to
+ * get all the data.
+ */
+ record++;
Dmsg6(300, "recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
- rec_state_to_str(rec), block->BlockNumber,
- rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
+ rec_state_to_str(rec), block->BlockNumber,
+ rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
- if (rec->FileIndex == EOM_LABEL) { /* end of tape? */
+ if (rec->FileIndex == EOM_LABEL) { /* end of tape? */
Dmsg0(40, "Get EOM LABEL\n");
- break; /* yes, get out */
- }
+ break; /* yes, get out */
+ }
- /* Some sort of label? */
- if (rec->FileIndex < 0) {
- handle_session_record(dev, rec, &sessrec);
- ok = record_cb(dcr, rec);
- if (rec->FileIndex == EOS_LABEL) {
+ /* Some sort of label? */
+ if (rec->FileIndex < 0) {
+ handle_session_record(dev, rec, &sessrec);
+ ok = record_cb(dcr, rec);
+ if (rec->FileIndex == EOS_LABEL) {
Dmsg2(300, "Remove rec. SI=%d ST=%d\n", rec->VolSessionId,
- rec->VolSessionTime);
- recs->remove(rec);
- free_record(rec);
- }
- continue;
- } /* end if label record */
+ rec->VolSessionTime);
+ recs->remove(rec);
+ free_record(rec);
+ }
+ continue;
+ } /* end if label record */
- /*
- * Apply BSR filter
- */
- if (jcr->bsr) {
- int stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec);
- if (stat == -1) { /* no more possible matches */
- done = true; /* all items found, stop */
- Dmsg2(300, "All done=(file:block) %d:%d\n", dev->file, dev->block_num);
- break;
- } else if (stat == 0) { /* no match */
- Dmsg4(300, "Clear rem=%d FI=%d before set_eof pos %d:%d\n",
- rec->remainder, rec->FileIndex, dev->file, dev->block_num);
- rec->remainder = 0;
- rec->state &= ~REC_PARTIAL_RECORD;
- if (try_repositioning(jcr, rec, dev)) {
- break;
- }
+ /*
+ * Apply BSR filter
+ */
+ if (jcr->bsr) {
+ int stat = match_bsr(jcr->bsr, rec, &dev->VolHdr, &sessrec);
+ if (stat == -1) { /* no more possible matches */
+ done = true; /* all items found, stop */
+ Dmsg2(300, "All done=(file:block) %u:%u\n", dev->file, dev->block_num);
+ break;
+ } else if (stat == 0) { /* no match */
+ Dmsg4(300, "Clear rem=%d FI=%d before set_eof pos %u:%u\n",
+ rec->remainder, rec->FileIndex, dev->file, dev->block_num);
+ rec->remainder = 0;
+ rec->state &= ~REC_PARTIAL_RECORD;
+ if (try_repositioning(jcr, rec, dev)) {
+ break;
+ }
continue; /* we don't want record, read next one */
- }
- }
- if (is_partial_record(rec)) {
+ }
+ }
+ if (is_partial_record(rec)) {
Dmsg6(300, "Partial, break. recno=%d state=%s blk=%d SI=%d ST=%d FI=%d\n", record,
- rec_state_to_str(rec), block->BlockNumber,
- rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
- break; /* read second part of record */
- }
- ok = record_cb(dcr, rec);
- if (rec->Stream == STREAM_MD5_SIGNATURE || rec->Stream == STREAM_SHA1_SIGNATURE) {
- Dmsg3(300, "Done FI=%d before set_eof pos %d:%d\n", rec->FileIndex,
- dev->file, dev->block_num);
- if (match_set_eof(jcr->bsr, rec) && try_repositioning(jcr, rec, dev)) {
- Dmsg2(300, "Break after match_set_eof pos %d:%d\n",
- dev->file, dev->block_num);
- break;
- }
- Dmsg2(300, "After set_eof pos %d:%d\n", dev->file, dev->block_num);
- }
+ rec_state_to_str(rec), block->BlockNumber,
+ rec->VolSessionId, rec->VolSessionTime, rec->FileIndex);
+ break; /* read second part of record */
+ }
+ ok = record_cb(dcr, rec);
+ if (rec->Stream == STREAM_MD5_SIGNATURE || rec->Stream == STREAM_SHA1_SIGNATURE) {
+ Dmsg3(300, "Done FI=%u before set_eof pos %u:%u\n", rec->FileIndex,
+ dev->file, dev->block_num);
+ if (match_set_eof(jcr->bsr, rec) && try_repositioning(jcr, rec, dev)) {
+ Dmsg2(300, "Break after match_set_eof pos %u:%u\n",
+ dev->file, dev->block_num);
+ break;
+ }
+ Dmsg2(300, "After set_eof pos %u:%u\n", dev->file, dev->block_num);
+ }
} /* end for loop over records */
- Dmsg2(300, "After end records position=(file:block) %d:%d\n", dev->file, dev->block_num);
+ Dmsg2(300, "After end records position=(file:block) %u:%u\n", dev->file, dev->block_num);
} /* end for loop over blocks */
-// Dmsg2(300, "Position=(file:block) %d:%d\n", dev->file, dev->block_num);
+// Dmsg2(300, "Position=(file:block) %u:%u\n", dev->file, dev->block_num);
/* Walk down list and free all remaining allocated recs */
while (!recs->empty()) {
/*
* See if we can reposition.
- * Returns: 1 if at end of volume
- * 0 otherwise
+ * Returns: true if at end of volume
+ * false otherwise
*/
-static int try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev)
+static bool try_repositioning(JCR *jcr, DEV_RECORD *rec, DEVICE *dev)
{
BSR *bsr;
bsr = find_next_bsr(jcr->bsr, dev);
if (bsr == NULL && jcr->bsr->mount_next_volume) {
Dmsg0(300, "Would mount next volume here\n");
- Dmsg2(300, "Current postion (file:block) %d:%d\n",
- dev->file, dev->block_num);
+ Dmsg2(300, "Current postion (file:block) %u:%u\n",
+ dev->file, dev->block_num);
jcr->bsr->mount_next_volume = false;
if (!dev->at_eot()) {
- /* Set EOT flag to force mount of next Volume */
- jcr->mount_next_volume = true;
- dev->state |= ST_EOT;
+ /* Set EOT flag to force mount of next Volume */
+ jcr->mount_next_volume = true;
+ dev->state |= ST_EOT;
}
rec->Block = 0;
- return 1;
+ return true;
}
if (bsr) {
if (verbose) {
- Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %d:%d to %d:%d\n",
- dev->file, dev->block_num, bsr->volfile->sfile,
- bsr->volblock->sblock);
+ Jmsg(jcr, M_INFO, 0, "Reposition from (file:block) %u:%u to %u:%u\n",
+ dev->file, dev->block_num, bsr->volfile->sfile,
+ bsr->volblock->sblock);
}
- Dmsg4(300, "Try_Reposition from (file:block) %d:%d to %d:%d\n",
- dev->file, dev->block_num, bsr->volfile->sfile,
- bsr->volblock->sblock);
+ Dmsg4(300, "Try_Reposition from (file:block) %u:%u to %u:%u\n",
+ dev->file, dev->block_num, bsr->volfile->sfile,
+ bsr->volblock->sblock);
reposition_dev(dev, bsr->volfile->sfile, bsr->volblock->sblock);
rec->Block = 0;
}
- return 0;
+ return false;
}
/*
BSR *bsr = NULL;
/*
* Now find and position to first file and block
- * on this tape.
+ * on this tape.
*/
if (jcr->bsr) {
jcr->bsr->reposition = true; /* force repositioning */
bsr = find_next_bsr(jcr->bsr, dev);
if (bsr && (bsr->volfile->sfile != 0 || bsr->volblock->sblock != 0)) {
Jmsg(jcr, M_INFO, 0, _("Forward spacing to file:block %u:%u.\n"),
- bsr->volfile->sfile, bsr->volblock->sblock);
+ bsr->volfile->sfile, bsr->volblock->sblock);
Dmsg2(300, "Forward spacing to file:block %u:%u.\n",
- bsr->volfile->sfile, bsr->volblock->sblock);
- reposition_dev(dev, bsr->volfile->sfile, bsr->volblock->sblock);
+ bsr->volfile->sfile, bsr->volblock->sblock);
+ reposition_dev(dev, bsr->volfile->sfile, bsr->volblock->sblock);
}
}
return bsr;
break;
}
Dmsg5(300, "%s Record: VolSessionId=%d VolSessionTime=%d JobId=%d DataLen=%d\n",
- rtype, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
+ rtype, rec->VolSessionId, rec->VolSessionTime, rec->Stream, rec->data_len);
}
#ifdef DEBUG