/*
Bacula® - The Network Backup Solution
- Copyright (C) 2000-2009 Free Software Foundation Europe e.V.
+ Copyright (C) 2000-2010 Free Software Foundation Europe e.V.
The main author of Bacula is Kern Sibbald, with contributions from
many others, a complete list can be found in the file AUTHORS.
* daemon. More complicated coding (double buffering, writer
* thread, ...) is left for a later version.
*
- * Version $Id$
*/
/*
Mmsg1(dev->errmsg, _("Unable to init mutex: ERR=%s\n"), be.bstrerror(errstat));
Jmsg0(jcr, M_ERROR_TERM, 0, dev->errmsg);
}
+ /* Ensure that we respect this order in P/V operations */
+ bthread_mutex_set_priority(&dev->m_mutex, PRIO_SD_DEV_ACCESS);
+ bthread_mutex_set_priority(&dev->spool_mutex, PRIO_SD_DEV_SPOOL);
+ bthread_mutex_set_priority(&dev->acquire_mutex, PRIO_SD_DEV_ACQUIRE);
#ifdef xxx
if ((errstat = rwl_init(&dev->lock)) != 0) {
berrno be;
}
}
if (dcr) {
- bstrncpy(VolCatInfo.VolCatName, dcr->VolumeName, sizeof(VolCatInfo.VolCatName));
+ dcr->setVolCatName(dcr->VolumeName);
+ VolCatInfo = dcr->VolCatInfo; /* structure assign */
}
Dmsg4(100, "open dev: type=%d dev_name=%s vol=%s mode=%s\n", dev_type,
- print_name(), VolCatInfo.VolCatName, mode_to_str(omode));
+ print_name(), getVolCatName(), mode_to_str(omode));
state &= ~(ST_LABEL|ST_APPEND|ST_READ|ST_EOT|ST_WEOT|ST_EOF);
label_type = B_BACULA_LABEL;
if (is_tape() || is_fifo()) {
if (!IsPathSeparator(archive_name.c_str()[strlen(archive_name.c_str())-1])) {
pm_strcat(archive_name, "/");
}
- pm_strcat(archive_name, VolCatInfo.VolCatName);
+ pm_strcat(archive_name, getVolCatName());
}
mount(1); /* do mount if required */
}
/*
- * Open a DVD device. N.B. at this point, dcr->VolCatInfo.VolCatName
- * (NB:??? I think it's VolCatInfo.VolCatName that is right)
+ * Open a DVD device. N.B. at this point, dcr->getVolCatName()
+ * (NB:??? I think it's getVolCatName() that is right)
* has the desired Volume name, but there is NO assurance that
* any other field of VolCatInfo is correct.
*/
* copy here, when opening.
*/
VolCatInfo = dcr->VolCatInfo; /* structure assignment */
- Dmsg1(100, "Volume=%s\n", VolCatInfo.VolCatName);
+ Dmsg1(100, "Volume=%s\n", getVolCatName());
if (VolCatInfo.VolCatName[0] == 0) {
Dmsg1(10, "Could not open DVD device %s. No Volume name given.\n",
return fsf(VolCatInfo.VolCatFiles);
#endif
- Dmsg0(100, "eod\n");
+ Dmsg0(100, "Enter eod\n");
if (at_eot()) {
return true;
}
}
if (!is_tape()) {
pos = lseek(dcr, (boffset_t)0, SEEK_END);
-// Dmsg1(100, "====== Seek to %lld\n", pos);
+ Dmsg1(200, "====== Seek to %lld\n", pos);
if (pos >= 0) {
update_pos(dcr);
set_eot();
berrno be;
Mmsg2(errmsg, _("lseek error on %s. ERR=%s.\n"),
print_name(), be.bstrerror());
+ Dmsg0(100, errmsg);
return false;
}
#ifdef MTEOM
/* If unknown position, rewind */
if (get_os_tape_file() < 0) {
if (!rewind(NULL)) {
+ Dmsg0(100, "Rewind error\n");
return false;
}
}
update_pos(dcr);
Mmsg2(errmsg, _("ioctl MTEOM error on %s. ERR=%s.\n"),
print_name(), be.bstrerror());
+ Dmsg0(100, errmsg);
return false;
}
clrerror(-1);
Mmsg2(errmsg, _("ioctl MTIOCGET error on %s. ERR=%s.\n"),
print_name(), be.bstrerror());
+ Dmsg0(100, errmsg);
return false;
}
Dmsg1(100, "EOD file=%d\n", os_file);
* Rewind then use FSF until EOT reached
*/
if (!rewind(NULL)) {
+ Dmsg0(100, "Rewind error.\n");
return false;
}
/*
for (file_num=file; !at_eot(); file_num++) {
Dmsg0(200, "eod: doing fsf 1\n");
if (!fsf(1)) {
- Dmsg0(200, "fsf error.\n");
+ Dmsg0(100, "fsf error.\n");
return false;
}
/*
{
Dmsg1(100, "Clear volhdr vol=%s\n", VolHdr.VolumeName);
memset(&VolHdr, 0, sizeof(VolHdr));
+ setVolCatInfo(false);
}
void DEVICE::close()
{
Dmsg1(100, "close_dev %s\n", print_name());
- if (has_cap(CAP_OFFLINEUNMOUNT)) {
- offline();
- }
+ offline_or_rewind();
if (!is_open()) {
Dmsg2(100, "device %s already closed vol=%s\n", print_name(),
/* Try at most 10 times to (un)mount the device. This should perhaps be configurable. */
tries = 10;
} else {
- tries = 0;
+ tries = 1;
}
results = get_memory(4000);
/* Try at most 10 times to (un)mount the device. This should perhaps be configurable. */
tries = 10;
} else {
- tries = 0;
+ tries = 1;
}
results = get_memory(4000);
char *
dev_vol_name(DEVICE *dev)
{
- return dev->VolCatInfo.VolCatName;
+ return dev->getVolCatName();
}