本文整理汇总了C++中DEVICE::set_blocksizes方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::set_blocksizes方法的具体用法?C++ DEVICE::set_blocksizes怎么用?C++ DEVICE::set_blocksizes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::set_blocksizes方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write_new_volume_label_to_dev
//.........这里部分代码省略.........
/* 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;
}
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;
}
rec = new_record();
create_volume_label_record(dcr, dev, rec);
rec->Stream = 0;
rec->maskedStream = 0;
if (!write_record_to_block(dcr, rec)) {
Dmsg2(130, "Bad Label write on %s: ERR=%s\n", dev->print_name(), dev->print_errmsg());
free_record(rec);
goto bail_out;
} else {
Dmsg2(130, "Wrote label of %d bytes to %s\n", rec->data_len, dev->print_name());
free_record(rec);
}
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;
}
dev = dcr->dev;
Dmsg0(130, " Wrote block to device\n");
if (dev->weof(1)) {
dev->set_labeled();
write_ansi_ibm_labels(dcr, ANSI_EOF_LABEL, dev->VolHdr.VolumeName);
}
if (debug_level >= 20) {
dump_volume_label(dev);
}
Dmsg0(100, "Call reserve_volume\n");
if (reserve_volume(dcr, VolName) == NULL) {
Mmsg2(jcr->errmsg, _("Could not reserve volume %s on %s\n"),
dev->VolHdr.VolumeName, dev->print_name());
Dmsg1(100, "%s", jcr->errmsg);
goto bail_out;
}
dev = dcr->dev; /* may have changed in reserve_volume */
dev->clear_append(); /* remove append since this is PRE_LABEL */
/*
* Reset blocksizes from volinfo to device as we set blocksize to DEFAULT_BLOCK_SIZE to read the label.
*/
dev->set_blocksizes(dcr);
return true;
bail_out:
volume_unused(dcr);
dev->clear_volhdr();
dev->clear_append(); /* remove append since this is PRE_LABEL */
return false;
}