- 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) {
- /* Try each device in this AutoChanger */
- foreach_alist(device, changer->device) {
- Dmsg1(100, "Try changer device %s\n", device->hdr.name);
- if (!device->dev) {
- device->dev = init_dev(jcr, device);
- }
- if (!device->dev) {
- Dmsg1(100, "Device %s could not be opened. Skipped\n", devname.c_str());
- Jmsg(jcr, M_WARNING, 0, _("\n"
- " Device \"%s\" in changer \"%s\" requested by DIR could not be opened or does not exist.\n"),
- device->hdr.name, devname.c_str());
- continue;
- }
- if (!device->dev->autoselect) {
- Dmsg1(100, "Device %s not autoselect skipped.\n", devname.c_str());
- continue; /* device is not available */
- }
- if (drive < 0 || drive == (int)device->dev->drive_index) {
- Dmsg1(20, "Found changer device %s\n", device->hdr.name);
- found = true;
- break;
+ if (!found) {
+ foreach_res(changer, R_AUTOCHANGER) {
+ /* Find resource, and make sure we were able to open it */
+ 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 (!device->dev) {
+ device->dev = init_dev(jcr, device);
+ }
+ if (!device->dev) {
+ Dmsg1(100, "Device %s could not be opened. Skipped\n", devname.c_str());
+ Jmsg(jcr, M_WARNING, 0, _("\n"
+ " Device \"%s\" in changer \"%s\" requested by DIR could not be opened or does not exist.\n"),
+ device->hdr.name, devname.c_str());
+ continue;
+ }
+ if (!device->dev->autoselect) {
+ Dmsg1(100, "Device %s not autoselect skipped.\n", devname.c_str());
+ continue; /* device is not available */
+ }
+ if (drive < 0 || drive == (int)device->dev->drive_index) {
+ Dmsg1(20, "Found changer device %s\n", device->hdr.name);
+ found = true;
+ break;
+ }
+ Dmsg3(100, "Device %s drive wrong: want=%d got=%d skipping\n",
+ devname.c_str(), drive, (int)device->dev->drive_index);