Dmsg1(90, "release_device device is %s\n", dev_is_tape(dev)?"tape":"disk");
if (dev->state & ST_READ) {
dev->state &= ~ST_READ; /* clear read bit */
- if (!dev_is_tape(dev)) {
+ if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+ if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+ offline_dev(dev);
+ }
close_dev(dev);
}
/******FIXME**** send read volume usage statistics to director */
dev->VolCatInfo.VolCatFiles++; /* increment number of files */
/* Note! do volume update before close, which zaps VolCatInfo */
dir_update_volume_info(jcr, &dev->VolCatInfo, 0); /* send Volume info to Director */
- if (!dev_is_tape(dev)) {
+
+ if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+ if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+ offline_dev(dev);
+ }
close_dev(dev);
- } else {
- Dmsg0(90, "Device is tape leave open in release_device\n");
}
} else {
dir_create_job_media_record(jcr);
memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
dev->state &= ~ST_LABEL; /* label not yet read */
- /* Rewind device */
+ if (!dev_is_tape(dev) || !(dev->capabilities & CAP_ALWAYSOPEN)) {
+ if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+ offline_dev(dev);
+ }
+ close_dev(dev);
+ }
+
+ /* If we have not closed the device, then at least rewind the tape */
if (dev->state & ST_OPENED) {
+ if (dev->capabilities & CAP_OFFLINEUNMOUNT) {
+ offline_dev(dev);
+ }
if (!rewind_dev(dev)) {
Jmsg2(jcr, M_WARNING, 0, _("Rewind error on device %s. ERR=%s\n"),
dev_name(dev), strerror_dev(dev));
Dmsg1(100, "Want changer slot=%d\n", slot);
if (slot > 0 && jcr->device->changer_name && jcr->device->changer_command) {
- uint32_t timeout = jcr->device->changer_timeout;
+ uint32_t timeout = jcr->device->max_changer_wait;
POOLMEM *changer, *results;
int status, loaded;
PrevVolName, edit_uint64_with_commas(dev->VolCatInfo.VolCatBytes, b1),
edit_uint64_with_commas(dev->VolCatInfo.VolCatBlocks, b2));
- if (!dev_is_tape(dev)) { /* If file, */
- close_dev(dev); /* yes, close it */
- }
-
/* Unlock, but leave BLOCKED */
unlock_device(dev);
if (!mount_next_volume(jcr, dev, label_blk, 1)) {
const char *str;
char add[20];
- Dmsg1(200, "edit_job_codes: %s\n", imsg);
+ Dmsg1(200, "edit_device_codes: %s\n", imsg);
add[2] = 0;
o = omsg;
for (p=imsg; *p; p++) {