本文整理汇总了C++中DEVICE::is_open方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::is_open方法的具体用法?C++ DEVICE::is_open怎么用?C++ DEVICE::is_open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::is_open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dvd_open_first_part
/*
* Open the first part file.
* - Close the fd
* - Reopen the device
*/
static bool dvd_open_first_part(DCR *dcr, int mode)
{
DEVICE *dev = dcr->dev;
Dmsg5(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d num_dvd_parts=%d append=%d\n", dev->print_name(),
dev->getVolCatName(), dev->openmode, dev->num_dvd_parts, dev->can_append());
dev->close_part(dcr);
Dmsg2(400, "Call dev->open(vol=%s, mode=%d)\n", dcr->getVolCatName(),
mode);
Dmsg0(100, "Set part=1\n");
dev->part = 1;
dev->part_start = 0;
if (dev->open(dcr, mode) < 0) {
Dmsg0(400, "open dev() failed\n");
return false;
}
Dmsg2(400, "Leave open_first_part state=%s append=%d\n", dev->is_open()?"open":"not open", dev->can_append());
return true;
}
示例2: LockRes
void *device_initialization(void *arg)
{
DEVRES *device;
DCR *dcr;
JCR *jcr;
DEVICE *dev;
int errstat;
LockRes();
pthread_detach(pthread_self());
jcr = new_jcr(sizeof(JCR), stored_free_jcr);
new_plugins(jcr); /* instantiate plugins */
jcr->setJobType(JT_SYSTEM);
/*
* Initialize job start condition variable
*/
errstat = pthread_cond_init(&jcr->job_start_wait, NULL);
if (errstat != 0) {
berrno be;
Jmsg1(jcr, M_ABORT, 0, _("Unable to init job start cond variable: ERR=%s\n"), be.bstrerror(errstat));
}
/*
* Initialize job end condition variable
*/
errstat = pthread_cond_init(&jcr->job_end_wait, NULL);
if (errstat != 0) {
berrno be;
Jmsg1(jcr, M_ABORT, 0, _("Unable to init job endstart cond variable: ERR=%s\n"), be.bstrerror(errstat));
}
foreach_res(device, R_DEVICE) {
Dmsg1(90, "calling init_dev %s\n", device->device_name);
dev = init_dev(NULL, device);
Dmsg1(10, "SD init done %s\n", device->device_name);
if (!dev) {
Jmsg1(NULL, M_ERROR, 0, _("Could not initialize %s\n"), device->device_name);
continue;
}
jcr->dcr = dcr = new_dcr(jcr, NULL, dev, NULL);
generate_plugin_event(jcr, bsdEventDeviceInit, dcr);
if (dev->is_autochanger()) {
/* If autochanger set slot in dev structure */
get_autochanger_loaded_slot(dcr);
}
if (device->cap_bits & CAP_ALWAYSOPEN) {
Dmsg1(20, "calling first_open_device %s\n", dev->print_name());
if (!first_open_device(dcr)) {
Jmsg1(NULL, M_ERROR, 0, _("Could not open device %s\n"), dev->print_name());
Dmsg1(20, "Could not open device %s\n", dev->print_name());
free_dcr(dcr);
jcr->dcr = NULL;
continue;
}
}
if (device->cap_bits & CAP_AUTOMOUNT && dev->is_open()) {
switch (read_dev_volume_label(dcr)) {
case VOL_OK:
memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
volume_unused(dcr); /* mark volume "released" */
break;
default:
Jmsg1(NULL, M_WARNING, 0, _("Could not mount device %s\n"), dev->print_name());
break;
}
}
free_dcr(dcr);
jcr->dcr = NULL;
}