本文整理汇总了C++中DEVICE::bstrerror方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::bstrerror方法的具体用法?C++ DEVICE::bstrerror怎么用?C++ DEVICE::bstrerror使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::bstrerror方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvd_close_job
bool dvd_close_job(DCR *dcr)
{
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
bool ok = true;
/*
* If the device is a dvd and WritePartAfterJob
* is set to yes, open the next part, so, in case of a device
* that requires mount, it will be written to the device.
*/
if (dev->is_dvd() && jcr->write_part_after_job && (dev->part_size > 0)) {
Dmsg1(400, "Writing last part=%d write_partafter_job is set.\n",
dev->part);
if (dev->part < dev->num_dvd_parts+1) {
Jmsg3(jcr, M_FATAL, 0, _("Error writing. Current part less than total number of parts (%d/%d, device=%s)\n"),
dev->part, dev->num_dvd_parts, dev->print_name());
dev->dev_errno = EIO;
ok = false;
}
if (ok && !dvd_write_part(dcr)) {
Jmsg2(jcr, M_FATAL, 0, _("Unable to write last on %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
dev->dev_errno = EIO;
ok = false;
}
}
return ok;
}
示例2: do_append_data
/*
* Append Data sent from File daemon
*
*/
bool do_append_data(JCR *jcr)
{
int32_t n;
int32_t file_index, stream, last_file_index;
BSOCK *fd = jcr->file_bsock;
bool ok = true;
DEV_RECORD rec;
char buf1[100], buf2[100];
DCR *dcr = jcr->dcr;
DEVICE *dev;
char ec[50];
if (!dcr) {
Jmsg0(jcr, M_FATAL, 0, _("DCR is NULL!!!\n"));
return false;
}
dev = dcr->dev;
if (!dev) {
Jmsg0(jcr, M_FATAL, 0, _("DEVICE is NULL!!!\n"));
return false;
}
Dmsg1(100, "Start append data. res=%d\n", dev->num_reserved());
memset(&rec, 0, sizeof(rec));
if (!fd->set_buffer_size(dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
jcr->setJobStatus(JS_ErrorTerminated);
Jmsg0(jcr, M_FATAL, 0, _("Unable to set network buffer size.\n"));
return false;
}
if (!acquire_device_for_append(dcr)) {
jcr->setJobStatus(JS_ErrorTerminated);
return false;
}
jcr->setJobStatus(JS_Running);
dir_send_job_status(jcr);
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
Dmsg1(50, "Begin append device=%s\n", dev->print_name());
begin_data_spool(dcr);
begin_attribute_spool(jcr);
Dmsg0(100, "Just after acquire_device_for_append\n");
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
/*
* Write Begin Session Record
*/
if (!write_session_label(dcr, SOS_LABEL)) {
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
dev->bstrerror());
jcr->setJobStatus(JS_ErrorTerminated);
ok = false;
}
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
/* Tell File daemon to send data */
if (!fd->fsend(OK_data)) {
berrno be;
Jmsg1(jcr, M_FATAL, 0, _("Network send error to FD. ERR=%s\n"),
be.bstrerror(fd->b_errno));
ok = false;
}
/*
* Get Data from File daemon, write to device. To clarify what is
* going on here. We expect:
* - A stream header
* - Multiple records of data
* - EOD record
*
* The Stream header is just used to sychronize things, and
* none of the stream header is written to tape.
* The Multiple records of data, contain first the Attributes,
* then after another stream header, the file data, then
* after another stream header, the MD5 data if any.
*
* So we get the (stream header, data, EOD) three time for each
* file. 1. for the Attributes, 2. for the file data if any,
* and 3. for the MD5 if any.
*/
dcr->VolFirstIndex = dcr->VolLastIndex = 0;
jcr->run_time = time(NULL); /* start counting time for rates */
for (last_file_index = 0; ok && !jcr->is_job_canceled(); ) {
/* Read Stream header from the File daemon.
//.........这里部分代码省略.........
示例3: acquire_device_for_read
//.........这里部分代码省略.........
Dmsg2(rdbglvl, "dir_get_vol_info failed for vol=%s: %s\n",
dcr->VolumeName, jcr->errmsg);
Jmsg1(jcr, M_WARNING, 0, "Read acquire: %s", jcr->errmsg);
}
dev->set_load(); /* set to load volume */
for ( ;; ) {
/* If not polling limit retries */
if (!dev->poll && retry++ > 10) {
break;
}
dev->clear_labeled(); /* force reread of label */
if (job_canceled(jcr)) {
char ed1[50];
Mmsg1(dev->errmsg, _("Job %s canceled.\n"), edit_int64(jcr->JobId, ed1));
Jmsg(jcr, M_INFO, 0, dev->errmsg);
goto get_out; /* error return */
}
dcr->do_unload();
dcr->do_swapping(false/*!is_writing*/);
dcr->do_load(false /*!is_writing*/);
set_dcr_from_vol(dcr, vol); /* refresh dcr with desired volume info */
/*
* This code ensures that the device is ready for
* reading. If it is a file, it opens it.
* If it is a tape, it checks the volume name
*/
Dmsg1(rdbglvl, "stored: open vol=%s\n", dcr->VolumeName);
if (!dev->open(dcr, OPEN_READ_ONLY)) {
if (!dev->poll) {
Jmsg3(jcr, M_WARNING, 0, _("Read open device %s Volume \"%s\" failed: ERR=%s\n"),
dev->print_name(), dcr->VolumeName, dev->bstrerror());
}
goto default_path;
}
Dmsg1(rdbglvl, "opened dev %s OK\n", dev->print_name());
/* Read Volume Label */
Dmsg0(rdbglvl, "calling read-vol-label\n");
vol_label_status = read_dev_volume_label(dcr);
switch (vol_label_status) {
case VOL_OK:
Dmsg0(rdbglvl, "Got correct volume.\n");
ok = true;
dev->VolCatInfo = dcr->VolCatInfo; /* structure assignment */
break; /* got it */
case VOL_IO_ERROR:
Dmsg0(rdbglvl, "IO Error\n");
/*
* Send error message generated by read_dev_volume_label()
* only we really had a tape mounted. This supresses superfluous
* error messages when nothing is mounted.
*/
if (tape_previously_mounted) {
Jmsg(jcr, M_WARNING, 0, "Read acquire: %s", jcr->errmsg);
}
goto default_path;
case VOL_NAME_ERROR:
Dmsg3(rdbglvl, "Vol name=%s want=%s drv=%s.\n", dev->VolHdr.VolumeName,
dcr->VolumeName, dev->print_name());
if (dev->is_volume_to_unload()) {
goto default_path;
}
dev->set_unload(); /* force unload of unwanted tape */
示例4: do_append_data
/*
* Append Data sent from Client (FD/SD)
*
*/
bool do_append_data(JCR *jcr)
{
int32_t n;
int32_t file_index, stream, last_file_index;
uint64_t stream_len;
BSOCK *fd = jcr->file_bsock;
bool ok = true;
DEV_RECORD rec;
char buf1[100], buf2[100];
DCR *dcr = jcr->dcr;
DEVICE *dev;
char ec[50];
POOLMEM *eblock = NULL;
POOL_MEM errmsg(PM_EMSG);
if (!dcr) {
pm_strcpy(jcr->errmsg, _("DCR is NULL!!!\n"));
Jmsg0(jcr, M_FATAL, 0, jcr->errmsg);
return false;
}
dev = dcr->dev;
if (!dev) {
pm_strcpy(jcr->errmsg, _("DEVICE is NULL!!!\n"));
Jmsg0(jcr, M_FATAL, 0, jcr->errmsg);
return false;
}
Dmsg1(100, "Start append data. res=%d\n", dev->num_reserved());
memset(&rec, 0, sizeof(rec));
if (!fd->set_buffer_size(dcr->device->max_network_buffer_size, BNET_SETBUF_WRITE)) {
jcr->setJobStatus(JS_ErrorTerminated);
pm_strcpy(jcr->errmsg, _("Unable to set network buffer size.\n"));
Jmsg0(jcr, M_FATAL, 0, jcr->errmsg);
return false;
}
if (!acquire_device_for_append(dcr)) {
jcr->setJobStatus(JS_ErrorTerminated);
return false;
}
jcr->sendJobStatus(JS_Running);
//ASSERT(dev->VolCatInfo.VolCatName[0]);
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
Dmsg1(50, "Begin append device=%s\n", dev->print_name());
begin_data_spool(dcr);
begin_attribute_spool(jcr);
Dmsg0(100, "Just after acquire_device_for_append\n");
//ASSERT(dev->VolCatInfo.VolCatName[0]);
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
/*
* Write Begin Session Record
*/
if (!write_session_label(dcr, SOS_LABEL)) {
Jmsg1(jcr, M_FATAL, 0, _("Write session label failed. ERR=%s\n"),
dev->bstrerror());
jcr->setJobStatus(JS_ErrorTerminated);
ok = false;
}
//ASSERT(dev->VolCatInfo.VolCatName[0]);
if (dev->VolCatInfo.VolCatName[0] == 0) {
Pmsg0(000, _("NULL Volume name. This shouldn't happen!!!\n"));
}
/* Tell File daemon to send data */
if (!fd->fsend(OK_data)) {
berrno be;
Jmsg1(jcr, M_FATAL, 0, _("Network send error to FD. ERR=%s\n"),
be.bstrerror(fd->b_errno));
ok = false;
}
/*
* Get Data from File daemon, write to device. To clarify what is
* going on here. We expect:
* - A stream header
* - Multiple records of data
* - EOD record
*
* The Stream header is just used to synchronize things, and
* none of the stream header is written to tape.
* The Multiple records of data, contain first the Attributes,
* then after another stream header, the file data, then
* after another stream header, the MD5 data if any.
*
* So we get the (stream header, data, EOD) three time for each
//.........这里部分代码省略.........
示例5: do_mac_run
//.........这里部分代码省略.........
}
Dmsg1(110, "Got Ticket=%d\n", jcr->Ticket);
} else {
Jmsg(jcr, M_FATAL, 0, _("Bad response from stored to start replicate command\n"));
goto bail_out;
}
/*
* Let the remote SD know we are now really going to send the data.
*/
sd->fsend(replicate_data, jcr->Ticket);
Dmsg1(110, ">stored: %s", sd->msg);
/*
* Expect to get response to the replicate data cmd from Storage daemon
*/
if (!response(jcr, sd, OK_data, "replicate data")) {
ok = false;
goto bail_out;
}
/*
* Read all data and send it to remote SD.
*/
ok = read_records(jcr->read_dcr, clone_record_to_remote_sd, mount_next_read_volume);
/*
* Send the last EOD to close the last data transfer and a next EOD to
* signal the remote we are done.
*/
if (!sd->signal(BNET_EOD) || !sd->signal(BNET_EOD)) {
if (!jcr->is_job_canceled()) {
Jmsg1(jcr, M_FATAL, 0, _("Network send error to SD. ERR=%s\n"),
sd->bstrerror());
}
goto bail_out;
}
/*
* Expect to get response that the replicate data succeeded.
*/
if (!response(jcr, sd, OK_replicate, "replicate data")) {
ok = false;
goto bail_out;
}
/*
* End replicate session.
*/
sd->fsend(end_replicate);
Dmsg1(110, ">stored: %s", sd->msg);
/*
* Expect to get response to the end replicate cmd from Storage daemon
*/
if (!response(jcr, sd, OK_end_replicate, "end replicate")) {
ok = false;
goto bail_out;
}
/* Inform Storage daemon that we are done */
sd->signal(BNET_TERMINATE);
} else {
if (!jcr->read_dcr || !jcr->dcr) {
Jmsg(jcr, M_FATAL, 0, _("Read and write devices not properly initialized.\n"));
goto bail_out;
示例6: clone_record_internally
/*
* Called here for each record from read_records()
* This function is used when we do a internal clone of a Job e.g.
* this SD is both the reading and writing SD.
*
* Returns: true if OK
* false if error
*/
static bool clone_record_internally(DCR *dcr, DEV_RECORD *rec)
{
JCR *jcr = dcr->jcr;
DEVICE *dev = jcr->dcr->dev;
char buf1[100], buf2[100];
#ifdef xxx
Dmsg5(000, "on entry JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
jcr->JobId, FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
#endif
/*
* If label and not for us, discard it
*/
if (rec->FileIndex < 0 && rec->match_stat <= 0) {
return true;
}
/*
* We want to write SOS_LABEL and EOS_LABEL discard all others
*/
switch (rec->FileIndex) {
case PRE_LABEL:
case VOL_LABEL:
case EOT_LABEL:
case EOM_LABEL:
return true; /* don't write vol labels */
}
// if (jcr->is_JobType(JT_BACKUP)) {
/*
* For normal migration jobs, FileIndex values are sequential because
* we are dealing with one job. However, for Vbackup (consolidation),
* we will be getting records from multiple jobs and writing them back
* out, so we need to ensure that the output FileIndex is sequential.
* We do so by detecting a FileIndex change and incrementing the
* JobFiles, which we then use as the output FileIndex.
*/
if (rec->FileIndex >= 0) {
/*
* If something changed, increment FileIndex
*/
if (rec->VolSessionId != rec->last_VolSessionId ||
rec->VolSessionTime != rec->last_VolSessionTime ||
rec->FileIndex != rec->last_FileIndex) {
jcr->JobFiles++;
rec->last_VolSessionId = rec->VolSessionId;
rec->last_VolSessionTime = rec->VolSessionTime;
rec->last_FileIndex = rec->FileIndex;
}
rec->FileIndex = jcr->JobFiles; /* set sequential output FileIndex */
}
// }
/*
* Modify record SessionId and SessionTime to correspond to output.
*/
rec->VolSessionId = jcr->VolSessionId;
rec->VolSessionTime = jcr->VolSessionTime;
Dmsg5(200, "before write JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
jcr->JobId, FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
while (!write_record_to_block(jcr->dcr, rec)) {
Dmsg4(200, "!write_record_to_block blkpos=%u:%u len=%d rem=%d\n",
dev->file, dev->block_num, rec->data_len, rec->remainder);
if (!jcr->dcr->write_block_to_device()) {
Dmsg2(90, "Got write_block_to_dev error on device %s. %s\n",
dev->print_name(), dev->bstrerror());
Jmsg2(jcr, M_FATAL, 0, _("Fatal append error on device %s: ERR=%s\n"),
dev->print_name(), dev->bstrerror());
return false;
}
Dmsg2(200, "===== Wrote block new pos %u:%u\n", dev->file, dev->block_num);
}
/*
* Restore packet
*/
rec->VolSessionId = rec->last_VolSessionId;
rec->VolSessionTime = rec->last_VolSessionTime;
if (rec->FileIndex < 0) {
return true; /* don't send LABELs to Dir */
}
jcr->JobBytes += rec->data_len; /* increment bytes of this job */
Dmsg5(500, "wrote_record JobId=%d FI=%s SessId=%d Strm=%s len=%d\n",
jcr->JobId, FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len);
//.........这里部分代码省略.........
示例7: write_new_volume_label_to_dev
/*
* Write a Volume Label
* !!! Note, this is ONLY used for writing
* a fresh volume label. Any data
* after the label will be destroyed,
* in fact, we write the label 5 times !!!!
*
* This routine should be used only when labeling a blank tape.
*/
bool write_new_volume_label_to_dev(DCR *dcr, const char *VolName,
const char *PoolName, bool relabel)
{
JCR *jcr = dcr->jcr;
DEVICE *dev = dcr->dev;
DEV_BLOCK *block = dcr->block;
Dmsg0(150, "write_volume_label()\n");
if (*VolName == 0) {
Pmsg0(0, "=== ERROR: write_new_volume_label_to_dev called with NULL VolName\n");
goto bail_out;
}
if (relabel) {
volume_unused(dcr); /* mark current volume unused */
/* Truncate device */
if (!dev->truncate(dcr)) {
goto bail_out;
}
if (!dev->is_tape()) {
dev->close(dcr); /* make sure file closed for rename */
}
}
/* Set the new filename for open, ... */
dev->setVolCatName(VolName);
dcr->setVolCatName(VolName);
Dmsg1(150, "New VolName=%s\n", VolName);
if (!dev->open(dcr, OPEN_READ_WRITE)) {
/* If device is not tape, attempt to create it */
if (dev->is_tape() || !dev->open(dcr, CREATE_READ_WRITE)) {
Jmsg3(jcr, M_WARNING, 0, _("Open device %s Volume \"%s\" failed: ERR=%s\n"),
dev->print_name(), dcr->VolumeName, dev->bstrerror());
goto bail_out;
}
}
Dmsg1(150, "Label type=%d\n", dev->label_type);
/*
* Let any stored plugin know that we are about to write a new label to the volume.
*/
if (generate_plugin_event(jcr, bsdEventLabelWrite, dcr) != bRC_OK) {
Dmsg0(200, "Error from bsdEventLabelWrite plugin event.\n");
goto bail_out;
}
for ( ;; ) {
empty_block(block);
if (!dev->rewind(dcr)) {
Dmsg2(130, "Bad status on %s from rewind: ERR=%s\n", dev->print_name(), dev->print_errmsg());
if (!forge_on) {
goto bail_out;
}
}
/* Temporarily mark in append state to enable writing */
dev->set_append();
/* Create PRE_LABEL */
create_volume_label(dev, VolName, PoolName);
/*
* If we have already detected an ANSI label, re-read it
* to skip past it. Otherwise, we write a new one if
* so requested.
*/
if (dev->label_type != B_BAREOS_LABEL) {
if (read_ansi_ibm_label(dcr) != VOL_OK) {
dev->rewind(dcr);
goto bail_out;
}
} else if (!write_ansi_ibm_labels(dcr, ANSI_VOL_LABEL, VolName)) {
goto bail_out;
}
create_volume_label_record(dcr, dev, dcr->rec);
dcr->rec->Stream = 0;
dcr->rec->maskedStream = 0;
if (!write_record_to_block(dcr, dcr->rec)) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
} else {
Dmsg2(130, "Wrote label of %d bytes to %s\n", dcr->rec->data_len, dev->print_name());
}
Dmsg0(130, "Call write_block_to_dev()\n");
if (!dcr->write_block_to_dev()) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
goto bail_out;
}
//.........这里部分代码省略.........