- vol = new_vol();
- strcpy(vol->VolumeName, bsr->VolumeName);
- if (add_vol(jcr, vol)) {
- jcr->NumVolumes++;
- Dmsg1(400, "Added volume %s\n", vol->VolumeName);
- } else {
- Dmsg1(400, "Duplicate volume %s\n", vol->VolumeName);
- free((char *)vol);
- }
+ BSR_VOLUME *bsrvol;
+ BSR_VOLFILE *volfile;
+ uint32_t sfile = UINT32_MAX;
+
+ /* Find minimum start file so that we can forward space to it */
+ for (volfile = bsr->volfile; volfile; volfile=volfile->next) {
+ if (volfile->sfile < sfile) {
+ sfile = volfile->sfile;
+ }
+ }
+ /* Now add volumes for this bsr */
+ for (bsrvol = bsr->volume; bsrvol; bsrvol=bsrvol->next) {
+ vol = new_restore_volume();
+ bstrncpy(vol->VolumeName, bsrvol->VolumeName, sizeof(vol->VolumeName));
+ bstrncpy(vol->MediaType, bsrvol->MediaType, sizeof(vol->MediaType));
+ bstrncpy(vol->device, bsrvol->device, sizeof(vol->device));
+ vol->Slot = bsrvol->Slot;
+ vol->start_file = sfile;
+ if (add_restore_volume(jcr, vol)) {
+ jcr->NumReadVolumes++;
+ Dmsg2(400, "Added volume=%s mediatype=%s\n", vol->VolumeName,
+ vol->MediaType);
+ } else {
+ Dmsg1(400, "Duplicate volume %s\n", vol->VolumeName);
+ free((char *)vol);
+ }
+ sfile = 0; /* start at beginning of second volume */
+ }