dev->volume_capacity = device->volume_capacity;
dev->max_rewind_wait = device->max_rewind_wait;
dev->max_open_wait = device->max_open_wait;
+ dev->max_open_vols = device->max_open_vols;
dev->device = device;
if (tape) {
}
timeout = dev->max_open_wait;
errno = 0;
+ if (dev->state & ST_FIFO && timeout) {
+ /* Set open timer */
+ dev->tid = start_thread_timer(pthread_self(), timeout);
+ }
/* If busy retry each second for max_open_wait seconds */
while ((dev->fd = open(dev->dev_name, dev->mode, MODE_RW)) < 0) {
if (errno == EAGAIN) {
dev->dev_errno = errno;
Mmsg2(&dev->errmsg, _("stored: unable to open device %s: ERR=%s\n"),
dev->dev_name, strerror(dev->dev_errno));
+ /* Stop any open timer we set */
+ if (dev->tid) {
+ stop_thread_timer(dev->tid);
+ dev->tid = 0;
+ }
Emsg0(M_FATAL, 0, dev->errmsg);
break;
}
dev->use_count++;
update_pos_dev(dev); /* update position */
}
+ /* Stop any open() timer we started */
+ if (dev->tid) {
+ stop_thread_timer(dev->tid);
+ dev->tid = 0;
+ }
Dmsg1(29, "open_dev: tape %d opened\n", dev->fd);
} else {
/*
} else {
Emsg0(M_ABORT, 0, _("Illegal mode given to open_dev.\n"));
}
- if ((dev->fd = open(archive_name, dev->mode, MODE_RW)) < 0) {
+ /* If creating file, give 0640 permissions */
+ if ((dev->fd = open(archive_name, dev->mode, 0640)) < 0) {
dev->dev_errno = errno;
Mmsg2(&dev->errmsg, _("Could not open: %s, ERR=%s\n"), archive_name, strerror(dev->dev_errno));
Emsg0(M_FATAL, 0, dev->errmsg);
memset(&dev->VolCatInfo, 0, sizeof(dev->VolCatInfo));
memset(&dev->VolHdr, 0, sizeof(dev->VolHdr));
dev->use_count--;
+ if (dev->tid) {
+ stop_thread_timer(dev->tid);
+ dev->tid = 0;
+ }
}
/*
Emsg0(M_FATAL, 0, dev->errmsg);
return;
}
- close_dev(dev);
+ do_close(dev);
Dmsg0(29, "term_dev\n");
if (dev->dev_name) {
free_memory(dev->dev_name);