本文整理汇总了C++中DEVICE::print_name方法的典型用法代码示例。如果您正苦于以下问题:C++ DEVICE::print_name方法的具体用法?C++ DEVICE::print_name怎么用?C++ DEVICE::print_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DEVICE
的用法示例。
在下文中一共展示了DEVICE::print_name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: write_volume_label_to_block
/*
* Put a volume label into the block
*
* Returns: false on failure
* true on success
*/
static bool write_volume_label_to_block(DCR *dcr)
{
DEVICE *dev = dcr->dev;
DEV_BLOCK *block = dcr->block;
DEV_RECORD rec;
JCR *jcr = dcr->jcr;
Dmsg0(130, "write Label in write_volume_label_to_block()\n");
memset(&rec, 0, sizeof(rec));
rec.data = get_memory(SER_LENGTH_Volume_Label);
empty_block(block); /* Volume label always at beginning */
create_volume_label_record(dcr, dev, &rec);
block->BlockNumber = 0;
if (!write_record_to_block(dcr, &rec)) {
free_pool_memory(rec.data);
Jmsg1(jcr, M_FATAL, 0, _("Cannot write Volume label to block for device %s\n"),
dev->print_name());
return false;
} else {
Dmsg2(130, "Wrote label of %d bytes to block. Vol=%s\n", rec.data_len,
dcr->VolumeName);
}
free_pool_memory(rec.data);
return true;
}
示例3: 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;
}
示例4: list_volumes
/*
* List Volumes -- this should be moved to status.c
*/
void list_volumes(void sendit(const char *msg, int len, void *sarg), void *arg)
{
VOLRES *vol;
POOL_MEM msg(PM_MESSAGE);
int len;
foreach_vol(vol) {
DEVICE *dev = vol->dev;
if (dev) {
len = Mmsg(msg, "%s on device %s\n", vol->vol_name, dev->print_name());
sendit(msg.c_str(), len, arg);
len = Mmsg(msg, " Reader=%d writers=%d reserves=%d volinuse=%d\n",
dev->can_read() ? 1 : 0, dev->num_writers, dev->num_reserved(),
vol->is_in_use());
sendit(msg.c_str(), len, arg);
} else {
len = Mmsg(msg, "Volume %s no device. volinuse= %d\n",
vol->vol_name, vol->is_in_use());
sendit(msg.c_str(), len, arg);
}
}
endeach_vol(vol);
lock_read_volumes();
foreach_dlist(vol, read_vol_list) {
DEVICE *dev = vol->dev;
if (dev) {
len = Mmsg(msg, "Read volume: %s on device %s\n", vol->vol_name, dev->print_name());
sendit(msg.c_str(), len, arg);
len = Mmsg(msg, " Reader=%d writers=%d reserves=%d volinuse=%d JobId=%d\n",
dev->can_read() ? 1 : 0, dev->num_writers, dev->num_reserved(),
vol->is_in_use(), vol->get_jobid());
sendit(msg.c_str(), len, arg);
} else {
len = Mmsg(msg, "Volume: %s no device. volinuse= %d\n",
vol->vol_name, vol->is_in_use());
sendit(msg.c_str(), len, arg);
}
}
示例5: set_label_blocksize
/*
* Set the block size of the device to the label_block_size
* to read labels as we want to always use that blocksize when
* writing volume labels
*/
void DEVICE::set_label_blocksize(DCR *dcr)
{
DEVICE *dev = this;
Dmsg3(100, "setting minblocksize to %u, "
"maxblocksize to label_block_size=%u, on device %s\n",
dev->device->label_block_size, dev->device->label_block_size, dev->print_name());
dev->min_block_size = dev->device->label_block_size;
dev->max_block_size = dev->device->label_block_size;
/*
* If blocklen is not dev->max_block_size create a new block with the right size
* (as header is always label_block_size)
*/
if (dcr->block) {
if (dcr->block->buf_len != dev->max_block_size) {
free_block(dcr->block);
dcr->block = new_block(dev);
Dmsg2(100, "created new block of buf_len: %u on device %s\n",
dcr->block->buf_len, dev->print_name());
}
}
}
示例6: memset
/*
* Create a new Device Control Record and attach
* it to the device (if this is a real job).
* Note, this has been updated so that it can be called first
* without a DEVICE, then a second or third time with a DEVICE,
* and each time, it should cleanup and point to the new device.
* This should facilitate switching devices.
* Note, each dcr must point to the controlling job (jcr). However,
* a job can have multiple dcrs, so we must not store in the jcr's
* structure as previously. The higher level routine must store
* this dcr in the right place
*
*/
DCR *new_dcr(JCR *jcr, DCR *dcr, DEVICE *dev, bool writing)
{
DEVICE *odev;
if (!dcr) {
dcr = (DCR *)malloc(sizeof(DCR));
memset(dcr, 0, sizeof(DCR));
dcr->tid = pthread_self();
dcr->spool_fd = -1;
}
dcr->jcr = jcr; /* point back to jcr */
odev = dcr->dev;
if (dcr->attached_to_dev && odev) {
Dmsg2(100, "Detach 0x%x from olddev %s\n", dcr, odev->print_name());
odev->detach_dcr_from_dev(dcr);
}
ASSERT2(!dcr->attached_to_dev, "DCR is attached. Wrong!");
/* Set device information, possibly change device */
if (dev) {
dcr->free_blocks();
dcr->block = new_block(dev);
dcr->ameta_block = dcr->block;
if (dcr->rec) {
free_record(dcr->rec);
}
dcr->rec = new_record();
/* Use job spoolsize prior to device spoolsize */
if (jcr && jcr->spool_size) {
dcr->max_job_spool_size = jcr->spool_size;
} else {
dcr->max_job_spool_size = dev->device->max_job_spool_size;
}
dcr->device = dev->device;
dcr->set_dev(dev);
Dmsg2(100, "Attach 0x%x to dev %s\n", dcr, dev->print_name());
dev->attach_dcr_to_dev(dcr);
}
if (writing) {
dcr->set_writing();
} else {
dcr->clear_writing();
}
return dcr;
}
示例7: attach_dcr_to_dev
static void attach_dcr_to_dev(DCR *dcr)
{
DEVICE *dev;
JCR *jcr;
P(dcr->m_mutex);
dev = dcr->dev;
jcr = dcr->jcr;
if (jcr) Dmsg1(500, "JobId=%u enter attach_dcr_to_dev\n", (uint32_t)jcr->JobId);
/* ***FIXME*** return error if dev not initiated */
if (!dcr->attached_to_dev && dev->initiated && jcr && jcr->getJobType() != JT_SYSTEM) {
dev->Lock();
Dmsg4(200, "Attach Jid=%d dcr=%p size=%d dev=%s\n", (uint32_t)jcr->JobId,
dcr, dev->attached_dcrs->size(), dev->print_name());
dev->attached_dcrs->append(dcr); /* attach dcr to device */
dev->Unlock();
dcr->attached_to_dev = true;
}
V(dcr->m_mutex);
}
示例8: locked_detach_dcr_from_dev
/*
* DCR is locked before calling this routine
*/
static void locked_detach_dcr_from_dev(DCR *dcr)
{
DEVICE *dev = dcr->dev;
Dmsg0(500, "Enter detach_dcr_from_dev\n"); /* jcr is NULL in some cases */
/* Detach this dcr only if attached */
if (dcr->attached_to_dev && dev) {
dcr->unreserve_device();
dev->Lock();
Dmsg4(200, "Detach Jid=%d dcr=%p size=%d to dev=%s\n", (uint32_t)dcr->jcr->JobId,
dcr, dev->attached_dcrs->size(), dev->print_name());
dcr->attached_to_dev = false;
if (dev->attached_dcrs->size()) {
dev->attached_dcrs->remove(dcr); /* detach dcr from device */
}
// remove_dcr_from_dcrs(dcr); /* remove dcr from jcr list */
dev->Unlock();
}
dcr->attached_to_dev = false;
}
示例9: 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;
}
示例10: acquire_device_for_read
/*********************************************************************
* Acquire device for reading.
* The drive should have previously been reserved by calling
* reserve_device_for_read(). We read the Volume label from the block and
* leave the block pointers just after the label.
*
* Returns: NULL if failed for any reason
* dcr if successful
*/
bool acquire_device_for_read(DCR *dcr)
{
DEVICE *dev;
JCR *jcr = dcr->jcr;
bool ok = false;
bool tape_previously_mounted;
VOL_LIST *vol;
bool try_autochanger = true;
int i;
int vol_label_status;
int retry = 0;
Enter(rdbglvl);
dev = dcr->dev;
dev->Lock_read_acquire();
Dmsg2(rdbglvl, "dcr=%p dev=%p\n", dcr, dcr->dev);
Dmsg2(rdbglvl, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type);
dev->dblock(BST_DOING_ACQUIRE);
if (dev->num_writers > 0) {
Jmsg2(jcr, M_FATAL, 0, _("Acquire read: num_writers=%d not zero. Job %d canceled.\n"),
dev->num_writers, jcr->JobId);
goto get_out;
}
/* Find next Volume, if any */
vol = jcr->VolList;
if (!vol) {
char ed1[50];
Jmsg(jcr, M_FATAL, 0, _("No volumes specified for reading. Job %s canceled.\n"),
edit_int64(jcr->JobId, ed1));
goto get_out;
}
jcr->CurReadVolume++;
for (i=1; i<jcr->CurReadVolume; i++) {
vol = vol->next;
}
if (!vol) {
Jmsg(jcr, M_FATAL, 0, _("Logic error: no next volume to read. Numvol=%d Curvol=%d\n"),
jcr->NumReadVolumes, jcr->CurReadVolume);
goto get_out; /* should not happen */
}
set_dcr_from_vol(dcr, vol);
Dmsg2(rdbglvl, "Want Vol=%s Slot=%d\n", vol->VolumeName, vol->Slot);
/*
* If the MediaType requested for this volume is not the
* same as the current drive, we attempt to find the same
* device that was used to write the orginal volume. If
* found, we switch to using that device.
*
* N.B. A lot of routines rely on the dcr pointer not changing
* read_records.c even has multiple dcrs cached, so we take care
* here to release all important parts of the dcr and re-acquire
* them such as the block pointer (size may change), but we do
* not release the dcr.
*/
Dmsg2(rdbglvl, "MediaType dcr=%s dev=%s\n", dcr->media_type, dev->device->media_type);
if (dcr->media_type[0] && !bstrcmp(dcr->media_type, dev->device->media_type)) {
RCTX rctx;
DIRSTORE *store;
int status;
Jmsg3(jcr, M_INFO, 0, _("Changing read device. Want Media Type=\"%s\" have=\"%s\"\n"
" device=%s\n"),
dcr->media_type, dev->device->media_type, dev->print_name());
Dmsg3(rdbglvl, "Changing read device. Want Media Type=\"%s\" have=\"%s\"\n"
" device=%s\n",
dcr->media_type, dev->device->media_type, dev->print_name());
dev->dunblock(DEV_UNLOCKED);
lock_reservations();
memset(&rctx, 0, sizeof(RCTX));
rctx.jcr = jcr;
jcr->read_dcr = dcr;
jcr->reserve_msgs = New(alist(10, not_owned_by_alist));
rctx.any_drive = true;
rctx.device_name = vol->device;
store = new DIRSTORE;
memset(store, 0, sizeof(DIRSTORE));
store->name[0] = 0; /* No dir name */
bstrncpy(store->media_type, vol->MediaType, sizeof(store->media_type));
bstrncpy(store->pool_name, dcr->pool_name, sizeof(store->pool_name));
bstrncpy(store->pool_type, dcr->pool_type, sizeof(store->pool_type));
store->append = false;
rctx.store = store;
clean_device(dcr); /* clean up the dcr */
/*
//.........这里部分代码省略.........
示例11: 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)
{
utime_t now;
JCR *jcr = dcr->jcr;
DEVICE *dev = dcr->dev;
bool ok = true;
char tbuf[100];
int was_blocked = BST_NOT_BLOCKED;
/*
* Capture job statistics now that we are done using this device.
*/
now = (utime_t)time(NULL);
update_job_statistics(jcr, now);
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;
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) {
dcr->dir_update_volume_info(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() && !dcr->dir_create_jobmedia_record(false)) {
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->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
//.........这里部分代码省略.........
示例12: Enter
/*
* Acquire device for writing. We permit multiple writers.
* If this is the first one, we read the label.
*
* Returns: NULL if failed for any reason
* dcr if successful.
* Note, normally reserve_device_for_append() is called
* before this routine.
*/
DCR *acquire_device_for_append(DCR *dcr)
{
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
bool ok = false;
bool have_vol = false;
Enter(200);
init_device_wait_timers(dcr);
dev->Lock_acquire(); /* only one job at a time */
dev->Lock();
Dmsg1(100, "acquire_append device is %s\n", dev->is_tape() ? "tape" : "disk");
/*
* With the reservation system, this should not happen
*/
if (dev->can_read()) {
Jmsg1(jcr, M_FATAL, 0, _("Want to append, but device %s is busy reading.\n"), dev->print_name());
Dmsg1(200, "Want to append but device %s is busy reading.\n", dev->print_name());
goto get_out;
}
dev->clear_unload();
/*
* have_vol defines whether or not mount_next_write_volume should
* ask the Director again about what Volume to use.
*/
if (dev->can_append() && dcr->is_suitable_volume_mounted() &&
!bstrcmp(dcr->VolCatInfo.VolCatStatus, "Recycle")) {
Dmsg0(190, "device already in append.\n");
/*
* At this point, the correct tape is already mounted, so
* we do not need to do mount_next_write_volume(), unless
* we need to recycle the tape.
*/
if (dev->num_writers == 0) {
dev->VolCatInfo = dcr->VolCatInfo; /* structure assignment */
}
have_vol = dcr->is_tape_position_ok();
}
if (!have_vol) {
dev->rLock(true);
block_device(dev, BST_DOING_ACQUIRE);
dev->Unlock();
Dmsg1(190, "jid=%u Do mount_next_write_vol\n", (uint32_t)jcr->JobId);
if (!dcr->mount_next_write_volume()) {
if (!job_canceled(jcr)) {
/* Reduce "noise" -- don't print if job canceled */
Jmsg(jcr, M_FATAL, 0, _("Could not ready device %s for append.\n"),
dev->print_name());
Dmsg1(200, "Could not ready device %s for append.\n",
dev->print_name());
}
dev->Lock();
unblock_device(dev);
goto get_out;
}
Dmsg2(190, "Output pos=%u:%u\n", dcr->dev->file, dcr->dev->block_num);
dev->Lock();
unblock_device(dev);
}
dev->num_writers++; /* we are now a writer */
if (jcr->NumWriteVolumes == 0) {
jcr->NumWriteVolumes = 1;
}
dev->VolCatInfo.VolCatJobs++; /* increment number of jobs on vol */
Dmsg4(100, "=== nwriters=%d nres=%d vcatjob=%d dev=%s\n",
dev->num_writers, dev->num_reserved(), dev->VolCatInfo.VolCatJobs, dev->print_name());
dcr->dir_update_volume_info(false, false); /* send Volume info to Director */
ok = true;
get_out:
/* Don't plugin close here, we might have multiple writers */
dcr->clear_reserved();
dev->Unlock();
dev->Unlock_acquire();
Leave(200);
return ok ? dcr : NULL;
}
示例13: set_blocksizes
/*
* Set the block size of the device.
* If the volume block size is zero, we set the max block size to what is
* configured in the device resource i.e. dev->device->max_block_size.
*
* If dev->device->max_block_size is zero, do nothing and leave dev->max_block_size as it is.
*/
void DEVICE::set_blocksizes(DCR *dcr) {
DEVICE* dev = this;
JCR* jcr = dcr->jcr;
uint32_t max_bs;
Dmsg4(100, "Device %s has dev->device->max_block_size of %u and dev->max_block_size of %u, dcr->VolMaxBlocksize is %u\n",
dev->print_name(), dev->device->max_block_size, dev->max_block_size, dcr->VolMaxBlocksize);
if (dcr->VolMaxBlocksize == 0 && dev->device->max_block_size != 0) {
Dmsg2(100, "setting dev->max_block_size to dev->device->max_block_size=%u "
"on device %s because dcr->VolMaxBlocksize is 0\n",
dev->device->max_block_size, dev->print_name());
dev->min_block_size = dev->device->min_block_size;
dev->max_block_size = dev->device->max_block_size;
} else if (dcr->VolMaxBlocksize != 0) {
dev->min_block_size = dcr->VolMinBlocksize;
dev->max_block_size = dcr->VolMaxBlocksize;
}
/*
* Sanity check
*/
if (dev->max_block_size == 0) {
max_bs = DEFAULT_BLOCK_SIZE;
} else {
max_bs = dev->max_block_size;
}
if (dev->min_block_size > max_bs) {
Jmsg(jcr, M_ERROR_TERM, 0, _("Min block size > max on device %s\n"), dev->print_name());
}
if (dev->max_block_size > MAX_BLOCK_LENGTH) {
Jmsg3(jcr, M_ERROR, 0, _("Block size %u on device %s is too large, using default %u\n"),
dev->max_block_size, dev->print_name(), DEFAULT_BLOCK_SIZE);
dev->max_block_size = 0;
}
if (dev->max_block_size % TAPE_BSIZE != 0) {
Jmsg3(jcr, M_WARNING, 0, _("Max block size %u not multiple of device %s block size=%d.\n"),
dev->max_block_size, dev->print_name(), TAPE_BSIZE);
}
if (dev->max_volume_size != 0 && dev->max_volume_size < (dev->max_block_size << 4)) {
Jmsg(jcr, M_ERROR_TERM, 0, _("Max Vol Size < 8 * Max Block Size for device %s\n"), dev->print_name());
}
Dmsg3(100, "set minblocksize to %d, maxblocksize to %d on device %s\n",
dev->min_block_size, dev->max_block_size, dev->print_name());
/*
* If blocklen is not dev->max_block_size create a new block with the right size.
* (as header is always dev->label_block_size which is preset with DEFAULT_BLOCK_SIZE)
*/
if (dcr->block) {
if (dcr->block->buf_len != dev->max_block_size) {
Dmsg2(100, "created new block of buf_len: %u on device %s\n",
dev->max_block_size, dev->print_name());
free_block(dcr->block);
dcr->block = new_block(dev);
Dmsg2(100, "created new block of buf_len: %u on device %s, freeing block\n",
dcr->block->buf_len, dev->print_name());
}
}
}
示例14: set_os_device_parameters
void set_os_device_parameters(DCR *dcr)
{
DEVICE *dev = dcr->dev;
if (strcmp(dev->dev_name, "/dev/null") == 0) {
return; /* no use trying to set /dev/null */
}
#if defined(HAVE_LINUX_OS) || defined(HAVE_WIN32)
struct mtop mt_com;
Dmsg0(100, "In set_os_device_parameters\n");
#if defined(MTSETBLK)
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSETBLK;
mt_com.mt_count = 0;
Dmsg0(100, "Set block size to zero\n");
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTSETBLK);
}
}
#endif
#if defined(MTSETDRVBUFFER)
if (getuid() == 0) { /* Only root can do this */
mt_com.mt_op = MTSETDRVBUFFER;
mt_com.mt_count = MT_ST_CLEARBOOLEANS;
if (!dev->has_cap(CAP_TWOEOF)) {
mt_com.mt_count |= MT_ST_TWO_FM;
}
if (dev->has_cap(CAP_EOM)) {
mt_com.mt_count |= MT_ST_FAST_MTEOM;
}
Dmsg0(100, "MTSETDRVBUFFER\n");
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTSETDRVBUFFER);
}
}
#endif
return;
#endif
#ifdef HAVE_NETBSD_OS
struct mtop mt_com;
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSETBSIZ;
mt_com.mt_count = 0;
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTSETBSIZ);
}
/* Get notified at logical end of tape */
mt_com.mt_op = MTEWARN;
mt_com.mt_count = 1;
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTEWARN);
}
}
return;
#endif
#if HAVE_FREEBSD_OS || HAVE_OPENBSD_OS
struct mtop mt_com;
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSETBSIZ;
mt_com.mt_count = 0;
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTSETBSIZ);
}
}
#if defined(MTIOCSETEOTMODEL)
uint32_t neof;
if (dev->has_cap(CAP_TWOEOF)) {
neof = 2;
} else {
neof = 1;
}
if (dev->d_ioctl(dev->fd(), MTIOCSETEOTMODEL, (caddr_t)&neof) < 0) {
berrno be;
dev->dev_errno = errno; /* save errno */
Mmsg2(dev->errmsg, _("Unable to set eotmodel on device %s: ERR=%s\n"),
dev->print_name(), be.bstrerror(dev->dev_errno));
Jmsg(dcr->jcr, M_FATAL, 0, dev->errmsg);
}
#endif
return;
#endif
#ifdef HAVE_SUN_OS
struct mtop mt_com;
if (dev->min_block_size == dev->max_block_size &&
dev->min_block_size == 0) { /* variable block mode */
mt_com.mt_op = MTSRSZ;
mt_com.mt_count = 0;
if (dev->d_ioctl(dev->fd(), MTIOCTOP, (char *)&mt_com) < 0) {
dev->clrerror(MTSRSZ);
}
}
return;
//.........这里部分代码省略.........
示例15: dir_ask_sysop_to_create_appendable_volume
/**
* Request the sysop to create an appendable volume
*
* Entered with device blocked.
* Leaves with device blocked.
*
* Returns: true on success (operator issues a mount command)
* false on failure
* Note, must create dev->errmsg on error return.
*
* On success, dcr->VolumeName and dcr->VolCatInfo contain
* information on suggested volume, but this may not be the
* same as what is actually mounted.
*
* When we return with success, the correct tape may or may not
* actually be mounted. The calling routine must read it and
* verify the label.
*/
bool dir_ask_sysop_to_create_appendable_volume(DCR *dcr)
{
int status = W_TIMEOUT;
DEVICE *dev = dcr->dev;
JCR *jcr = dcr->jcr;
bool got_vol = false;
if (job_canceled(jcr)) {
return false;
}
Dmsg0(dbglvl, "enter dir_ask_sysop_to_create_appendable_volume\n");
ASSERT(dev->blocked());
for ( ;; ) {
if (job_canceled(jcr)) {
Mmsg(dev->errmsg,
_("Job %s canceled while waiting for mount on Storage Device \"%s\".\n"),
jcr->Job, dev->print_name());
Jmsg(jcr, M_INFO, 0, "%s", dev->errmsg);
return false;
}
got_vol = dir_find_next_appendable_volume(dcr); /* get suggested volume */
if (got_vol) {
goto get_out;
} else {
if (status == W_TIMEOUT || status == W_MOUNT) {
Mmsg(dev->errmsg, _(
"Job %s is waiting. Cannot find any appendable volumes.\n"
"Please use the \"label\" command to create a new Volume for:\n"
" Storage: %s\n"
" Pool: %s\n"
" Media type: %s\n"),
jcr->Job,
dev->print_name(),
dcr->pool_name,
dcr->media_type);
Jmsg(jcr, M_MOUNT, 0, "%s", dev->errmsg);
Dmsg1(dbglvl, "%s", dev->errmsg);
}
}
jcr->sendJobStatus(JS_WaitMedia);
status = wait_for_sysop(dcr);
Dmsg1(dbglvl, "Back from wait_for_sysop status=%d\n", status);
if (dev->poll) {
Dmsg1(dbglvl, "Poll timeout in create append vol on device %s\n", dev->print_name());
continue;
}
if (status == W_TIMEOUT) {
if (!double_dev_wait_time(dev)) {
Mmsg(dev->errmsg, _("Max time exceeded waiting to mount Storage Device %s for Job %s\n"),
dev->print_name(), jcr->Job);
Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
Dmsg1(dbglvl, "Gave up waiting on device %s\n", dev->print_name());
return false; /* exceeded maximum waits */
}
continue;
}
if (status == W_ERROR) {
berrno be;
Mmsg0(dev->errmsg, _("pthread error in mount_next_volume.\n"));
Jmsg(jcr, M_FATAL, 0, "%s", dev->errmsg);
return false;
}
Dmsg1(dbglvl, "Someone woke me for device %s\n", dev->print_name());
}
get_out:
jcr->sendJobStatus(JS_Running);
Dmsg0(dbglvl, "leave dir_ask_sysop_to_mount_create_appendable_volume\n");
return true;
}