本文整理汇总了C++中DEVICE::get_file方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::get_file方法的具体用法?C++ DEVICE::get_file怎么用?C++ DEVICE::get_file使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::get_file方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_session_label
/* Write session label
* Returns: false on failure
* true on success
*/
bool write_session_label(DCR *dcr, int label)
{
JCR *jcr = dcr->jcr;
DEVICE *dev = dcr->dev;
DEV_RECORD *rec;
DEV_BLOCK *block = dcr->block;
char buf1[100], buf2[100];
rec = new_record();
Dmsg1(130, "session_label record=%x\n", rec);
switch (label) {
case SOS_LABEL:
set_start_vol_position(dcr);
break;
case EOS_LABEL:
if (dev->is_tape()) {
dcr->EndBlock = dev->EndBlock;
dcr->EndFile = dev->EndFile;
} else {
dcr->EndBlock = (uint32_t)dev->file_addr;
dcr->EndFile = (uint32_t)(dev->file_addr >> 32);
}
break;
default:
Jmsg1(jcr, M_ABORT, 0, _("Bad Volume session label = %d\n"), label);
break;
}
create_session_label(dcr, rec, label);
rec->FileIndex = label;
/*
* We guarantee that the session record can totally fit
* into a block. If not, write the block, and put it in
* the next block. Having the sesssion record totally in
* one block makes reading them much easier (no need to
* read the next block).
*/
if (!can_write_record_to_block(block, rec)) {
Dmsg0(150, "Cannot write session label to block.\n");
if (!dcr->write_block_to_device()) {
Dmsg0(130, "Got session label write_block_to_dev error.\n");
free_record(rec);
return false;
}
}
if (!write_record_to_block(dcr, rec)) {
free_record(rec);
return false;
}
Dmsg6(150, "Write sesson_label record JobId=%d FI=%s SessId=%d Strm=%s len=%d "
"remainder=%d\n", jcr->JobId,
FI_to_ascii(buf1, rec->FileIndex), rec->VolSessionId,
stream_to_ascii(buf2, rec->Stream, rec->FileIndex), rec->data_len,
rec->remainder);
free_record(rec);
Dmsg2(150, "Leave write_session_label Block=%ud File=%ud\n",
dev->get_block_num(), dev->get_file());
return true;
}
示例2: release_device
/*
* This job is done, so release the device. From a Unix standpoint,
* the device remains open.
*
* Note, if we were spooling, we may enter with the device blocked.
* We unblock at the end, only if it was us who blocked the
* device.
*
*/
bool release_device(DCR *dcr)
{
JCR *jcr = dcr->jcr;
DEVICE *dev = dcr->dev;
bool ok = true;
char tbuf[100];
int was_blocked = BST_NOT_BLOCKED;
dev->Lock();
if (!dev->is_blocked()) {
block_device(dev, BST_RELEASING);
} else {
was_blocked = dev->blocked();
dev->set_blocked(BST_RELEASING);
}
lock_volumes();
Dmsg2(100, "release_device device %s is %s\n", dev->print_name(), dev->is_tape()?"tape":"disk");
/* if device is reserved, job never started, so release the reserve here */
dcr->clear_reserved();
if (dev->can_read()) {
VOLUME_CAT_INFO *vol = &dev->VolCatInfo;
generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
dev->clear_read(); /* clear read bit */
Dmsg2(150, "dir_update_vol_info. label=%d Vol=%s\n",
dev->is_labeled(), vol->VolCatName);
if (dev->is_labeled() && vol->VolCatName[0] != 0) {
dir_update_volume_info(dcr, false, false); /* send Volume info to Director */
remove_read_volume(jcr, dcr->VolumeName);
volume_unused(dcr);
}
} else if (dev->num_writers > 0) {
/*
* Note if WEOT is set, we are at the end of the tape
* and may not be positioned correctly, so the
* job_media_record and update_vol_info have already been
* done, which means we skip them here.
*/
dev->num_writers--;
Dmsg1(100, "There are %d writers in release_device\n", dev->num_writers);
if (dev->is_labeled()) {
Dmsg2(200, "dir_create_jobmedia. Release vol=%s dev=%s\n",
dev->getVolCatName(), dev->print_name());
if (!dev->at_weot() && !dir_create_jobmedia_record(dcr)) {
Jmsg2(jcr, M_FATAL, 0, _("Could not create JobMedia record for Volume=\"%s\" Job=%s\n"),
dcr->getVolCatName(), jcr->Job);
}
/* If no more writers, and no errors, and wrote something, write an EOF */
if (!dev->num_writers && dev->can_write() && dev->block_num > 0) {
dev->weof(1);
write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
}
if (!dev->at_weot()) {
dev->VolCatInfo.VolCatFiles = dev->get_file(); /* set number of files */
/* Note! do volume update before close, which zaps VolCatInfo */
dir_update_volume_info(dcr, 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 */
generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
}
}
} 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);
generate_plugin_event(jcr, bsdEventDeviceClose, 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))) {
generate_plugin_event(jcr, bsdEventDeviceClose, dcr);
if (!dev->close()) {
Jmsg(jcr, M_ERROR, 0, "%s", dev->errmsg);
}
free_volume(dev);
}
unlock_volumes();
/* Fire off Alert command and include any output */
if (!job_canceled(jcr) && dcr->device->alert_command) {
//.........这里部分代码省略.........