- Make sure that Python has access to Client address/port so that
it can check if Clients are alive.
- Implement copies and stripes.
+- Add history file to console.
Maybe in 1.37:
- By the way: on page http://www.bacula.org/?page=tapedrives , at the
if $bindir/mysql $* -f <<END-OF-DATA
USE bacula;
+--
+-- Note, we use BLOB rather than TEXT because in MySQL,
+-- BLOBs are identical to TEXT except that BLOB is case
+-- sensitive in sorts, which is what we want, and TEXT
+-- is case insensitive.
+--
CREATE TABLE Filename (
FilenameId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Name BLOB NOT NULL,
PRIMARY KEY(FilenameId),
- INDEX (Name(30))
+ INDEX (Name(255))
);
CREATE TABLE Path (
PathId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
Path BLOB NOT NULL,
PRIMARY KEY(PathId),
- INDEX (Path(50))
+ INDEX (Path(255))
);
CREATE TABLE MediaType (
MediaTypeId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- MediaType VARCHAR(128) NOT NULL,
+ MediaType TINYBLOB NOT NULL,
ReadOnly TINYINT DEFAULT 0,
PRIMARY KEY(MediaTypeId)
);
CREATE TABLE Storage (
StorageId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- Name VARCHAR(128) NOT NULL,
+ Name TINYBLOB NOT NULL,
AutoChanger TINYINT DEFAULT 0,
PRIMARY KEY(StorageId)
);
CREATE TABLE Device (
DeviceId INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
- Name VARCHAR(128) NOT NULL,
+ Name TINYBLOB NOT NULL,
MediaTypeId INTEGER UNSIGNED NOT NULL REFERENCES MediaType,
StorageId INTEGER UNSIGNED NOT NULL REFERENCES Storage,
DevMounts INTEGER UNSIGNED DEFAULT 0,
*
* Bacula Director -- Bootstrap Record routines.
*
- * BSR (bootstrap record) handling routines split from
- * ua_restore.c July MMIII
+ * BSR (bootstrap record) handling routines split from
+ * ua_restore.c July MMIII
*
* Kern Sibbald, July MMII
*
* for each Volume.
*/
static uint32_t write_findex(UAContext *ua, RBSR_FINDEX *fi,
- int32_t FirstIndex, int32_t LastIndex, FILE *fd)
+ int32_t FirstIndex, int32_t LastIndex, FILE *fd)
{
uint32_t count = 0;
for ( ; fi; fi=fi->next) {
int32_t findex, findex2;
if ((fi->findex >= FirstIndex && fi->findex <= LastIndex) ||
- (fi->findex2 >= FirstIndex && fi->findex2 <= LastIndex) ||
- (fi->findex < FirstIndex && fi->findex2 > LastIndex)) {
- findex = fi->findex < FirstIndex ? FirstIndex : fi->findex;
- findex2 = fi->findex2 > LastIndex ? LastIndex : fi->findex2;
- if (findex == findex2) {
+ (fi->findex2 >= FirstIndex && fi->findex2 <= LastIndex) ||
+ (fi->findex < FirstIndex && fi->findex2 > LastIndex)) {
+ findex = fi->findex < FirstIndex ? FirstIndex : fi->findex;
+ findex2 = fi->findex2 > LastIndex ? LastIndex : fi->findex2;
+ if (findex == findex2) {
fprintf(fd, "FileIndex=%d\n", findex);
- count++;
- } else {
+ count++;
+ } else {
fprintf(fd, "FileIndex=%d-%d\n", findex, findex2);
- count += findex2 - findex + 1;
- }
+ count += findex2 - findex + 1;
+ }
}
}
return count;
* falls within the range of selected files in the bsr.
*/
static bool is_volume_selected(RBSR_FINDEX *fi,
- int32_t FirstIndex, int32_t LastIndex)
+ int32_t FirstIndex, int32_t LastIndex)
{
- if (fi) {
+ for ( ; fi; fi=fi->next) {
if ((fi->findex >= FirstIndex && fi->findex <= LastIndex) ||
- (fi->findex2 >= FirstIndex && fi->findex2 <= LastIndex) ||
- (fi->findex < FirstIndex && fi->findex2 > LastIndex)) {
- return true;
+ (fi->findex2 >= FirstIndex && fi->findex2 <= LastIndex) ||
+ (fi->findex < FirstIndex && fi->findex2 > LastIndex)) {
+ return true;
}
- return is_volume_selected(fi->next, FirstIndex, LastIndex);
}
return false;
}
if (bsr) {
free_findex(bsr->fi);
if (bsr->VolParams) {
- free(bsr->VolParams);
+ free(bsr->VolParams);
}
free_bsr(bsr->next);
free(bsr);
jr.JobId = bsr->JobId;
if (!db_get_job_record(ua->jcr, ua->db, &jr)) {
bsendmsg(ua, _("Unable to get Job record. ERR=%s\n"), db_strerror(ua->db));
- return 0;
+ return 0;
}
bsr->VolSessionId = jr.VolSessionId;
bsr->VolSessionTime = jr.VolSessionTime;
if ((bsr->VolCount=db_get_job_volume_parameters(ua->jcr, ua->db, bsr->JobId,
- &(bsr->VolParams))) == 0) {
+ &(bsr->VolParams))) == 0) {
bsendmsg(ua, _("Unable to get Job Volume Parameters. ERR=%s\n"), db_strerror(ua->db));
- if (bsr->VolParams) {
- free(bsr->VolParams);
- bsr->VolParams = NULL;
- }
- return 0;
+ if (bsr->VolParams) {
+ free(bsr->VolParams);
+ bsr->VolParams = NULL;
+ }
+ return 0;
}
return complete_bsr(ua, bsr->next);
}
if (!fd) {
berrno be;
bsendmsg(ua, _("Unable to create bootstrap file %s. ERR=%s\n"),
- fname, be.strerror());
+ fname, be.strerror());
goto bail_out;
}
/* Write them to file */
start_prompt(ua, "");
for (RBSR *nbsr=bsr; nbsr; nbsr=nbsr->next) {
for (int i=0; i < nbsr->VolCount; i++) {
- if (nbsr->VolParams[i].VolumeName[0]) {
- add_prompt(ua, nbsr->VolParams[i].VolumeName);
- }
+ if (nbsr->VolParams[i].VolumeName[0]) {
+ add_prompt(ua, nbsr->VolParams[i].VolumeName);
+ }
}
}
for (int i=0; i < ua->num_prompts; i++) {
* VolCount is the number of JobMedia records.
*/
for (int i=0; i < bsr->VolCount; i++) {
- if (!is_volume_selected(bsr->fi, bsr->VolParams[i].FirstIndex,
- bsr->VolParams[i].LastIndex)) {
- bsr->VolParams[i].VolumeName[0] = 0; /* zap VolumeName */
- continue;
- }
+ if (!is_volume_selected(bsr->fi, bsr->VolParams[i].FirstIndex,
+ bsr->VolParams[i].LastIndex)) {
+ bsr->VolParams[i].VolumeName[0] = 0; /* zap VolumeName */
+ continue;
+ }
fprintf(fd, "Volume=\"%s\"\n", bsr->VolParams[i].VolumeName);
fprintf(fd, "MediaType=\"%s\"\n", bsr->VolParams[i].MediaType);
fprintf(fd, "VolSessionId=%u\n", bsr->VolSessionId);
fprintf(fd, "VolSessionTime=%u\n", bsr->VolSessionTime);
- if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) {
+ if (bsr->VolParams[i].StartFile == bsr->VolParams[i].EndFile) {
fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartFile);
- } else {
+ } else {
fprintf(fd, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile,
- bsr->VolParams[i].EndFile);
- }
- if (bsr->VolParams[i].StartBlock == bsr->VolParams[i].EndBlock) {
+ bsr->VolParams[i].EndFile);
+ }
+ if (bsr->VolParams[i].StartBlock == bsr->VolParams[i].EndBlock) {
fprintf(fd, "VolFile=%u\n", bsr->VolParams[i].StartBlock);
- } else {
+ } else {
fprintf(fd, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
- bsr->VolParams[i].EndBlock);
- }
+ bsr->VolParams[i].EndBlock);
+ }
// Dmsg2(100, "bsr VolParam FI=%u LI=%u\n",
-// bsr->VolParams[i].FirstIndex, bsr->VolParams[i].LastIndex);
+// bsr->VolParams[i].FirstIndex, bsr->VolParams[i].LastIndex);
- count = write_findex(ua, bsr->fi, bsr->VolParams[i].FirstIndex,
- bsr->VolParams[i].LastIndex, fd);
- if (count) {
+ count = write_findex(ua, bsr->fi, bsr->VolParams[i].FirstIndex,
+ bsr->VolParams[i].LastIndex, fd);
+ if (count) {
fprintf(fd, "Count=%u\n", count);
- }
- total_count += count;
- /* If the same file is present on two tapes or in two files
- * on a tape, it is a continuation, and should not be treated
- * twice in the totals.
- */
- if (!first && LastIndex == bsr->VolParams[i].FirstIndex) {
- total_count--;
- }
- first = false;
- LastIndex = bsr->VolParams[i].LastIndex;
+ }
+ total_count += count;
+ /* If the same file is present on two tapes or in two files
+ * on a tape, it is a continuation, and should not be treated
+ * twice in the totals.
+ */
+ if (!first && LastIndex == bsr->VolParams[i].FirstIndex) {
+ total_count--;
+ }
+ first = false;
+ LastIndex = bsr->VolParams[i].LastIndex;
}
write_bsr(ua, bsr->next, fd);
}
bsendmsg(ua, "VolSessionId=%u\n", bsr->VolSessionId);
bsendmsg(ua, "VolSessionTime=%u\n", bsr->VolSessionTime);
bsendmsg(ua, "VolFile=%u-%u\n", bsr->VolParams[i].StartFile,
- bsr->VolParams[i].EndFile);
+ bsr->VolParams[i].EndFile);
bsendmsg(ua, "VolBlock=%u-%u\n", bsr->VolParams[i].StartBlock,
- bsr->VolParams[i].EndBlock);
- print_findex(ua, bsr->fi);
+ bsr->VolParams[i].EndBlock);
+ print_findex(ua, bsr->fi);
}
print_bsr(ua, bsr->next);
}
RBSR_FINDEX *fi, *lfi;
if (findex == 0) {
- return; /* probably a dummy directory */
+ return; /* probably a dummy directory */
}
- if (bsr->fi == NULL) { /* if no FI add one */
+ if (bsr->fi == NULL) { /* if no FI add one */
/* This is the first FileIndex item in the chain */
bsr->fi = new_findex();
bsr->JobId = JobId;
/* Walk down list of bsrs until we find the JobId */
if (bsr->JobId != JobId) {
for (nbsr=bsr->next; nbsr; nbsr=nbsr->next) {
- if (nbsr->JobId == JobId) {
- bsr = nbsr;
- break;
- }
+ if (nbsr->JobId == JobId) {
+ bsr = nbsr;
+ break;
+ }
}
- if (!nbsr) { /* Must add new JobId */
- /* Add new JobId at end of chain */
- for (nbsr=bsr; nbsr->next; nbsr=nbsr->next)
- { }
- nbsr->next = new_bsr();
- nbsr->next->JobId = JobId;
- nbsr->next->fi = new_findex();
- nbsr->next->fi->findex = findex;
- nbsr->next->fi->findex2 = findex;
- return;
+ if (!nbsr) { /* Must add new JobId */
+ /* Add new JobId at end of chain */
+ for (nbsr=bsr; nbsr->next; nbsr=nbsr->next)
+ { }
+ nbsr->next = new_bsr();
+ nbsr->next->JobId = JobId;
+ nbsr->next->fi = new_findex();
+ nbsr->next->fi->findex = findex;
+ nbsr->next->fi->findex2 = findex;
+ return;
}
}
/* Check if this findex is smaller than first item */
if (findex < fi->findex) {
if ((findex+1) == fi->findex) {
- fi->findex = findex; /* extend down */
- return;
+ fi->findex = findex; /* extend down */
+ return;
}
- fi = new_findex(); /* yes, insert before first item */
+ fi = new_findex(); /* yes, insert before first item */
fi->findex = findex;
fi->findex2 = findex;
fi->next = lfi;
/* Walk down fi chain and find where to insert insert new FileIndex */
for ( ; fi; fi=fi->next) {
if (findex == (fi->findex2 + 1)) { /* extend up */
- RBSR_FINDEX *nfi;
- fi->findex2 = findex;
- /*
- * If the following record contains one higher, merge its
- * file index by extending it up.
- */
- if (fi->next && ((findex+1) == fi->next->findex)) {
- nfi = fi->next;
- fi->findex2 = nfi->findex2;
- fi->next = nfi->next;
- free(nfi);
- }
- return;
+ RBSR_FINDEX *nfi;
+ fi->findex2 = findex;
+ /*
+ * If the following record contains one higher, merge its
+ * file index by extending it up.
+ */
+ if (fi->next && ((findex+1) == fi->next->findex)) {
+ nfi = fi->next;
+ fi->findex2 = nfi->findex2;
+ fi->next = nfi->next;
+ free(nfi);
+ }
+ return;
}
if (findex < fi->findex) { /* add before */
- if ((findex+1) == fi->findex) {
- fi->findex = findex;
- return;
- }
- break;
+ if ((findex+1) == fi->findex) {
+ fi->findex = findex;
+ return;
+ }
+ break;
}
lfi = fi;
}
RBSR *nbsr;
RBSR_FINDEX *fi;
- if (bsr->fi == NULL) { /* if no FI add one */
+ if (bsr->fi == NULL) { /* if no FI add one */
/* This is the first FileIndex item in the chain */
bsr->fi = new_findex();
bsr->JobId = JobId;
/* Walk down list of bsrs until we find the JobId */
if (bsr->JobId != JobId) {
for (nbsr=bsr->next; nbsr; nbsr=nbsr->next) {
- if (nbsr->JobId == JobId) {
- bsr = nbsr;
- break;
- }
+ if (nbsr->JobId == JobId) {
+ bsr = nbsr;
+ break;
+ }
}
- if (!nbsr) { /* Must add new JobId */
- /* Add new JobId at end of chain */
- for (nbsr=bsr; nbsr->next; nbsr=nbsr->next)
- { }
- nbsr->next = new_bsr();
- nbsr->next->JobId = JobId;
- nbsr->next->fi = new_findex();
- nbsr->next->fi->findex = 1;
- nbsr->next->fi->findex2 = INT32_MAX;
- return;
+ if (!nbsr) { /* Must add new JobId */
+ /* Add new JobId at end of chain */
+ for (nbsr=bsr; nbsr->next; nbsr=nbsr->next)
+ { }
+ nbsr->next = new_bsr();
+ nbsr->next->JobId = JobId;
+ nbsr->next->fi = new_findex();
+ nbsr->next->fi->findex = 1;
+ nbsr->next->fi->findex2 = INT32_MAX;
+ return;
}
}
fi->findex2 = INT32_MAX;
return;
}
-
char pool_type[MAX_NAME_LENGTH];
};
-class DIRDEVICE {
- alist *device;
-};
-
static bool use_storage_cmd(JCR *jcr)
{
POOL_MEM store_name, dev_name, media_type, pool_name, pool_type;
DEVRES *device;
AUTOCHANGER *changer;
int append;
- bool ok;
+ bool ok;
int Copy, Stripe;
+ alist *dirstore;
+ DIRSTORE *store;
+ char *device_name;
/*
* If there are multiple devices, the director sends us
* use_device for each device that it wants to use.
*/
Dmsg1(100, "<dird: %s", dir->msg);
- ok = sscanf(dir->msg, use_storage, store_name.c_str(),
- media_type.c_str(), pool_name.c_str(),
- pool_type.c_str(), &append, &Copy, &Stripe) == 7;
- if (ok) {
+ dirstore = New(alist(10, not_owned_by_alist));
+ do {
+ ok = sscanf(dir->msg, use_storage, store_name.c_str(),
+ media_type.c_str(), pool_name.c_str(),
+ pool_type.c_str(), &append, &Copy, &Stripe) == 7;
+ if (!ok) {
+ break;
+ }
unbash_spaces(store_name);
unbash_spaces(media_type);
unbash_spaces(pool_name);
unbash_spaces(pool_type);
- if (bnet_recv(dir) <= 0) {
- return false;
- }
- ok = sscanf(dir->msg, use_device, dev_name.c_str()) == 1;
- if (!ok) {
- return false;
- }
- /* Eat to BNET_EOD -- end of Devices */
- while (bnet_recv(dir) > 0) {
- }
- /* Eat to end of Devices */
- while (bnet_recv(dir) > 0) {
- }
- LockRes();
- foreach_res(device, R_DEVICE) {
- /* Find resource, and make sure we were able to open it */
- if (fnmatch(dev_name.c_str(), device->hdr.name, 0) == 0 &&
- strcmp(device->media_type, media_type.c_str()) == 0) {
- const int name_len = MAX_NAME_LENGTH;
- DCR *dcr;
- UnlockRes();
- if (!device->dev) {
- device->dev = init_dev(jcr, NULL, device);
- }
- if (!device->dev) {
- Jmsg(jcr, M_WARNING, 0, _("\n"
- " Device \"%s\" requested by DIR could not be opened or does not exist.\n"),
- dev_name.c_str());
- bnet_fsend(dir, NOT_open, dev_name.c_str());
- Dmsg1(100, ">dird: %s\n", dir->msg);
- return false;
- }
- dcr = new_dcr(jcr, device->dev);
- if (!dcr) {
- bnet_fsend(dir, _("3926 Could not get dcr for device: %s\n"), dev_name.c_str());
- Dmsg1(100, ">dird: %s\n", dir->msg);
- return false;
- }
- Dmsg1(100, "Found device %s\n", device->hdr.name);
- bstrncpy(dcr->pool_name, pool_name, name_len);
- bstrncpy(dcr->pool_type, pool_type, name_len);
- bstrncpy(dcr->media_type, media_type, name_len);
- bstrncpy(dcr->dev_name, dev_name, name_len);
- dcr->Copy = Copy;
- dcr->Stripe = Stripe;
- jcr->dcr = dcr;
- if (append == SD_APPEND) {
- ok = reserve_device_for_append(dcr);
- } else {
- ok = reserve_device_for_read(dcr);
- }
- if (!ok) {
- bnet_fsend(dir, _("3927 Could not reserve device: %s\n"), dev_name.c_str());
- Dmsg1(100, ">dird: %s\n", dir->msg);
- free_dcr(jcr->dcr);
- return false;
- }
- Dmsg1(220, "Got: %s", dir->msg);
- bash_spaces(dev_name);
- ok = bnet_fsend(dir, OK_device, dev_name.c_str());
- Dmsg1(100, ">dird: %s\n", dir->msg);
- return ok;
+ store = new DIRSTORE;
+ dirstore->append(store);
+ memset(store, 0, sizeof(DIRSTORE));
+ store->device = New(alist(10));
+ bstrncpy(store->name, store_name, sizeof(store->name));
+ bstrncpy(store->media_type, media_type, sizeof(store->media_type));
+ bstrncpy(store->pool_name, pool_name, sizeof(store->pool_name));
+ bstrncpy(store->pool_type, pool_type, sizeof(store->pool_type));
+
+ /* Now get all devices */
+ while (bnet_recv(dir) >= 0) {
+ ok = sscanf(dir->msg, use_device, dev_name.c_str()) == 1;
+ if (!ok) {
+ break;
}
+ unbash_spaces(dev_name);
+ store->device->append(bstrdup(dev_name.c_str()));
+ }
+ } while (ok && bnet_recv(dir) >= 0);
+
+ /* This loop is debug code and can be removed */
+ /* ***FIXME*** turn off in production */
+ foreach_alist(store, dirstore) {
+ Dmsg4(100, "Storage=%s media_type=%s pool=%s pool_type=%s\n",
+ store->name, store->media_type, store->pool_name,
+ store->pool_type);
+ foreach_alist(device_name, store->device) {
+ Dmsg1(100, " Device=%s\n", device_name);
}
+ }
- foreach_res(changer, R_AUTOCHANGER) {
- /* Find resource, and make sure we were able to open it */
- if (fnmatch(dev_name.c_str(), changer->hdr.name, 0) == 0) {
- const int name_len = MAX_NAME_LENGTH;
- DCR *dcr;
- /* Try each device in this AutoChanger */
- foreach_alist(device, changer->device) {
- Dmsg1(100, "Try changer device %s\n", device->hdr.name);
+
+ if (ok) {
+ LockRes();
+ store = (DIRSTORE *)dirstore->first();
+ foreach_alist(device_name, store->device) {
+ foreach_res(device, R_DEVICE) {
+ /* Find resource, and make sure we were able to open it */
+ if (fnmatch(device_name, device->hdr.name, 0) == 0 &&
+ strcmp(device->media_type, store->media_type) == 0) {
+ const int name_len = MAX_NAME_LENGTH;
+ DCR *dcr;
+ UnlockRes();
if (!device->dev) {
device->dev = init_dev(jcr, NULL, device);
}
if (!device->dev) {
- Dmsg1(100, "Device %s could not be opened. Skipped\n", dev_name.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, dev_name.c_str());
- continue;
- }
- if (!device->dev->autoselect) {
- continue; /* device is not available */
- }
+ " Device \"%s\" requested by DIR could not be opened or does not exist.\n"),
+ dev_name.c_str());
+ bnet_fsend(dir, NOT_open, dev_name.c_str());
+ Dmsg1(100, ">dird: %s\n", dir->msg);
+ return false;
+ }
dcr = new_dcr(jcr, device->dev);
if (!dcr) {
bnet_fsend(dir, _("3926 Could not get dcr for device: %s\n"), dev_name.c_str());
Dmsg1(100, ">dird: %s\n", dir->msg);
- UnlockRes();
return false;
}
- Dmsg1(100, "Found changer device %s\n", device->hdr.name);
- bstrncpy(dcr->pool_name, pool_name, name_len);
- bstrncpy(dcr->pool_type, pool_type, name_len);
- bstrncpy(dcr->media_type, media_type, name_len);
- bstrncpy(dcr->dev_name, dev_name, name_len);
+ Dmsg1(100, "Found device %s\n", device->hdr.name);
+ bstrncpy(dcr->pool_name, store->pool_name, name_len);
+ bstrncpy(dcr->pool_type, store->pool_type, name_len);
+ bstrncpy(dcr->media_type, store->media_type, name_len);
+ bstrncpy(dcr->dev_name, device_name, name_len);
+ dcr->Copy = Copy;
+ dcr->Stripe = Stripe;
jcr->dcr = dcr;
if (append == SD_APPEND) {
ok = reserve_device_for_append(dcr);
ok = reserve_device_for_read(dcr);
}
if (!ok) {
- Jmsg(jcr, M_WARNING, 0, _("Could not reserve device: %s\n"), dev_name.c_str());
+ bnet_fsend(dir, _("3927 Could not reserve device: %s\n"), dev_name.c_str());
+ Dmsg1(100, ">dird: %s\n", dir->msg);
free_dcr(jcr->dcr);
- continue;
+ goto get_out;
}
- Dmsg1(100, "Device %s opened.\n", dev_name.c_str());
- UnlockRes();
- pm_strcpy(dev_name, device->hdr.name);
+ Dmsg1(220, "Got: %s", dir->msg);
bash_spaces(dev_name);
ok = bnet_fsend(dir, OK_device, dev_name.c_str());
Dmsg1(100, ">dird: %s\n", dir->msg);
- return ok;
+ goto get_out;
+ }
+ }
+ foreach_res(changer, R_AUTOCHANGER) {
+ /* Find resource, and make sure we were able to open it */
+ if (fnmatch(device_name, changer->hdr.name, 0) == 0) {
+ const int name_len = MAX_NAME_LENGTH;
+ DCR *dcr;
+ /* 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, NULL, device);
+ }
+ if (!device->dev) {
+ Dmsg1(100, "Device %s could not be opened. Skipped\n", dev_name.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, dev_name.c_str());
+ continue;
+ }
+ if (!device->dev->autoselect) {
+ continue; /* device is not available */
+ }
+ dcr = new_dcr(jcr, device->dev);
+ if (!dcr) {
+ bnet_fsend(dir, _("3926 Could not get dcr for device: %s\n"), dev_name.c_str());
+ Dmsg1(100, ">dird: %s\n", dir->msg);
+ UnlockRes();
+ ok = false;
+ goto get_out;
+ }
+ Dmsg1(100, "Found changer device %s\n", device->hdr.name);
+ bstrncpy(dcr->pool_name, store->pool_name, name_len);
+ bstrncpy(dcr->pool_type, store->pool_type, name_len);
+ bstrncpy(dcr->media_type, store->media_type, name_len);
+ bstrncpy(dcr->dev_name, device_name, name_len);
+ jcr->dcr = dcr;
+ if (append == SD_APPEND) {
+ ok = reserve_device_for_append(dcr);
+ } else {
+ ok = reserve_device_for_read(dcr);
+ }
+ if (!ok) {
+ Jmsg(jcr, M_WARNING, 0, _("Could not reserve device: %s\n"), dev_name.c_str());
+ free_dcr(jcr->dcr);
+ continue;
+ }
+ Dmsg1(100, "Device %s opened.\n", device_name);
+ UnlockRes();
+ pm_strcpy(dev_name, device->hdr.name);
+ bash_spaces(dev_name);
+ ok = bnet_fsend(dir, OK_device, dev_name.c_str());
+ Dmsg1(100, ">dird: %s\n", dir->msg);
+ goto get_out;
+ }
+ break; /* we found it but could not open a device */
}
- break; /* we found it but could not open a device */
}
}
dev_name.c_str(), media_type.c_str());
bnet_fsend(dir, NO_device, dev_name.c_str());
Dmsg1(100, ">dird: %s\n", dir->msg);
+ ok = false;
} else {
unbash_spaces(dir->msg);
pm_strcpy(jcr->errmsg, dir->msg);
Jmsg(jcr, M_FATAL, 0, _("Bad Use Device command: %s\n"), jcr->errmsg);
bnet_fsend(dir, BAD_use, jcr->errmsg);
Dmsg1(100, ">dird: %s\n", dir->msg);
+ ok = false;
}
- return false; /* ERROR return */
+get_out:
+ foreach_alist(store, dirstore) {
+ delete store->device;
+ delete store;
+ }
+ delete dirstore;
+ return ok;
}
#ifdef needed
/* */
#undef VERSION
#define VERSION "1.37.12"
-#define BDATE "02 April 2005"
-#define LSMDATE "02Apr05"
+#define BDATE "04 April 2005"
+#define LSMDATE "04Apr05"
/* Debug flags */
#undef DEBUG