many others, a complete list can be found in the file AUTHORS.
This program is Free Software; you can redistribute it and/or
modify it under the terms of version two of the GNU General Public
- License as published by the Free Software Foundation plus additions
- that are listed in the file LICENSE.
+ License as published by the Free Software Foundation and included
+ in the file LICENSE.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
static bool changer_cmd(JCR *sjcr);
static bool do_label(JCR *jcr, int relabel);
static DCR *find_device(JCR *jcr, POOL_MEM &dev_name, int drive);
-static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot);
+static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot);
static void label_volume_if_ok(DCR *dcr, char *oldname,
char *newname, char *poolname,
int Slot, int relabel);
-static bool try_autoload_device(JCR *jcr, int slot, const char *VolName);
+static bool try_autoload_device(JCR *jcr, DCR *dcr, int slot, const char *VolName);
static void send_dir_busy_message(BSOCK *dir, DEVICE *dev);
struct s_cmds {
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), dev_name.c_str());
}
Dmsg0(90, "try_autoload_device - looking for volume_info\n");
- if (!try_autoload_device(dcr->jcr, slot, volname)) {
+ if (!try_autoload_device(dcr->jcr, dcr, slot, volname)) {
goto bail_out; /* error */
}
unbash_spaces(devname);
foreach_res(device, R_DEVICE) {
/* Find resource, and make sure we were able to open it */
- if (fnmatch(device->hdr.name, devname.c_str(), 0) == 0) {
+ if (strcmp(device->hdr.name, devname.c_str()) == 0) {
if (!device->dev) {
device->dev = init_dev(jcr, device);
}
if (!found) {
foreach_res(changer, R_AUTOCHANGER) {
/* Find resource, and make sure we were able to open it */
- if (fnmatch(devname.c_str(), changer->hdr.name, 0) == 0) {
+ if (strcmp(devname.c_str(), changer->hdr.name) == 0) {
/* Try each device in this AutoChanger */
foreach_alist(device, changer->device) {
Dmsg1(100, "Try changer device %s\n", device->hdr.name);
if (found) {
Dmsg1(100, "Found device %s\n", device->hdr.name);
- dcr = new_dcr(jcr, device->dev);
+ dcr = new_dcr(jcr, NULL, device->dev);
dcr->device = device;
- jcr->dcr = dcr;
}
return dcr;
}
case BST_UNMOUNTED_WAITING_FOR_SYSOP:
case BST_UNMOUNTED:
if (dev->is_autochanger() && slot > 0) {
- try_autoload_device(jcr, slot, "");
+ try_autoload_device(jcr, dcr, slot, "");
}
/* We freed the device, so reopen it and wake any waiting threads */
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
case BST_NOT_BLOCKED:
if (dev->is_autochanger() && slot > 0) {
- try_autoload_device(jcr, slot, "");
+ try_autoload_device(jcr, dcr, slot, "");
}
if (dev->is_open()) {
if (dev->is_labeled()) {
"If this is not a blank tape, try unmounting and remounting the Volume.\n"),
dev->print_name());
}
- } else if (dev->is_dvd()) {
+ } else if (dev->is_unmountable()) {
if (dev->mount(1)) {
bnet_fsend(dir, _("3002 Device %s is mounted.\n"),
dev->print_name());
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
}
if (!dev->is_busy()) {
unload_autochanger(dcr, -1);
}
- if (dev->is_dvd()) {
+ if (dev->is_unmountable()) {
if (dev->unmount(0)) {
bnet_fsend(dir, _("3002 Device %s unmounted.\n"),
dev->print_name());
/* ***FIXME**** what is this ???? */
dev->close();
}
- if (dev->is_dvd() && !dev->unmount(0)) {
+ if (dev->is_unmountable() && !dev->unmount(0)) {
bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
} else {
dev->set_blocked(BST_UNMOUNTED_WAITING_FOR_SYSOP);
if (!unload_autochanger(dcr, -1)) {
dev->close();
}
- if (dev->is_dvd() && !dev->unmount(0)) {
+ if (dev->is_unmountable() && !dev->unmount(0)) {
bnet_fsend(dir, _("3907 %s"), dev->bstrerror());
} else {
bnet_fsend(dir, _("3002 Device %s unmounted.\n"),
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
}
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
}
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
}
dev = dcr->dev;
dev->dlock(); /* Use P to avoid indefinite block */
if (!dev->is_open()) {
- read_volume_label(jcr, dev, Slot);
+ read_volume_label(jcr, dcr, dev, Slot);
dev->close();
/* Under certain "safe" conditions, we can steal the lock */
} else if (dev->can_steal_lock()) {
- read_volume_label(jcr, dev, Slot);
+ read_volume_label(jcr, dcr, dev, Slot);
} else if (dev->is_busy() || dev->is_blocked()) {
send_dir_busy_message(dir, dev);
} else { /* device not being used */
- read_volume_label(jcr, dev, Slot);
+ read_volume_label(jcr, dcr, dev, Slot);
}
dev->dunlock();
free_dcr(dcr);
- jcr->dcr = NULL;
} else {
bnet_fsend(dir, _("3999 Device \"%s\" not found or could not be opened.\n"), devname.c_str());
}
*
* Enter with the mutex set
*/
-static void read_volume_label(JCR *jcr, DEVICE *dev, int Slot)
+static void read_volume_label(JCR *jcr, DCR *dcr, DEVICE *dev, int Slot)
{
BSOCK *dir = jcr->dir_bsock;
bsteal_lock_t hold;
- DCR *dcr = jcr->dcr;
dcr->dev = dev;
steal_device_lock(dev, &hold, BST_WRITING_LABEL);
- if (!try_autoload_device(jcr, Slot, "")) {
+ if (!try_autoload_device(jcr, dcr, Slot, "")) {
goto bail_out; /* error */
}
return;
}
-static bool try_autoload_device(JCR *jcr, int slot, const char *VolName)
+static bool try_autoload_device(JCR *jcr, DCR *dcr, int slot, const char *VolName)
{
- DCR *dcr = jcr->dcr;
BSOCK *dir = jcr->dir_bsock;
bstrncpy(dcr->VolumeName, VolName, sizeof(dcr->VolumeName));