本文整理汇总了C++中DEVICE::close方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::close方法的具体用法?C++ DEVICE::close怎么用?C++ DEVICE::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dir_ask_sysop_to_mount_volume
bool dir_ask_sysop_to_mount_volume(DCR *dcr, int /*mode*/)
{
DEVICE *dev = dcr->dev;
fprintf(stderr, _("Mount Volume \"%s\" on device %s and press return when ready: "),
dcr->VolumeName, dev->print_name());
dev->close(dcr);
getchar();
return true;
}
示例2: mount_next_read_volume
/*
* If we are reading, we come here at the end of the tape
* and see if there are more volumes to be mounted.
*/
bool mount_next_read_volume(DCR *dcr)
{
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
Dmsg2(90, "NumReadVolumes=%d CurReadVolume=%d\n", jcr->NumReadVolumes, jcr->CurReadVolume);
volume_unused(dcr); /* release current volume */
/*
* End Of Tape -- mount next Volume (if another specified)
*/
if (jcr->NumReadVolumes > 1 && jcr->CurReadVolume < jcr->NumReadVolumes) {
dev->close();
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;
}
return true; /* next volume mounted */
}
Dmsg0(90, "End of Device reached.\n");
return false;
}
示例3: acquire_device_for_read
//.........这里部分代码省略.........
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 */
if (!unload_autochanger(dcr, -1)) {
/* at least free the device so we can re-open with correct volume */
dev->close(dcr);
free_volume(dev);
}
dev->set_load();
/* Fall through */
default:
Jmsg1(jcr, M_WARNING, 0, "Read acquire: %s", jcr->errmsg);
default_path:
Dmsg0(rdbglvl, "default path\n");
tape_previously_mounted = true;
/*
* If the device requires mount, close it, so the device can be ejected.
*/
if (dev->requires_mount()) {
dev->close(dcr);
free_volume(dev);
}
/* Call autochanger only once unless ask_sysop called */
if (try_autochanger) {
int status;
Dmsg2(rdbglvl, "calling autoload Vol=%s Slot=%d\n",
dcr->VolumeName, dcr->VolCatInfo.Slot);
status = autoload_device(dcr, 0, NULL);
if (status > 0) {
try_autochanger = false;
continue; /* try reading volume mounted */
}
}
/* Mount a specific volume and no other */
Dmsg0(rdbglvl, "calling dir_ask_sysop\n");
示例4: release_device
//.........这里部分代码省略.........
dev->weof(1);
write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
}
if (!dev->at_weot()) {
dev->VolCatInfo.VolCatFiles = dev->file; /* set number of files */
/*
* Note! do volume update before close, which zaps VolCatInfo
*/
dcr->dir_update_volume_info(false, false); /* send Volume info to Director */
Dmsg2(200, "dir_update_vol_info. Release vol=%s dev=%s\n",
dev->getVolCatName(), dev->print_name());
}
if (dev->num_writers == 0) { /* if not being used */
volume_unused(dcr); /* we obviously are not using the volume */
}
}
} else {
/*
* If we reach here, it is most likely because the job has failed,
* since the device is not in read mode and there are no writers.
* It was probably reserved.
*/
volume_unused(dcr);
}
Dmsg3(100, "%d writers, %d reserve, dev=%s\n", dev->num_writers, dev->num_reserved(), dev->print_name());
/*
* If no writers, close if file or !CAP_ALWAYS_OPEN
*/
if (dev->num_writers == 0 && (!dev->is_tape() || !dev->has_cap(CAP_ALWAYSOPEN))) {
dev->close(dcr);
free_volume(dev);
}
unlock_volumes();
/*
* Fire off Alert command and include any output
*/
if (!job_canceled(jcr)) {
if (!dcr->device->drive_tapealert_enabled && dcr->device->alert_command) {
int status = 1;
POOLMEM *alert, *line;
BPIPE *bpipe;
alert = get_pool_memory(PM_FNAME);
line = get_pool_memory(PM_FNAME);
alert = edit_device_codes(dcr, alert, dcr->device->alert_command, "");
/*
* Wait maximum 5 minutes
*/
bpipe = open_bpipe(alert, 60 * 5, "r");
if (bpipe) {
while (bfgets(line, bpipe->rfd)) {
Jmsg(jcr, M_ALERT, 0, _("Alert: %s"), line);
}
status = close_bpipe(bpipe);
} else {
status = errno;
}
if (status != 0) {
示例5: 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;
}
//.........这里部分代码省略.........