if (part <= num_dvd_parts) {
omode = OPEN_READ_ONLY;
make_mounted_dvd_filename(this, archive_name);
+ set_part_spooled(false);
} else {
omode = OPEN_READ_WRITE;
make_spooled_dvd_filename(this, archive_name);
+ set_part_spooled(true);
}
set_mode(omode);
/* Remove the last part file if it is empty */
if (num_dvd_parts > 0) {
struct stat statp;
- int part_save = part;
+ uint32_t part_save = part;
POOL_MEM archive_name(PM_FNAME);
int status;
part, num_dvd_parts, VolCatInfo.VolCatName);
Dmsg1(100, "unlink(%s)\n", archive_name.c_str());
unlink(archive_name.c_str());
- set_part_spooled(false); /* no spooled part left */
+ if (part_save == part) {
+ set_part_spooled(false); /* no spooled part left */
+ }
} else if (status < 0) {
- set_part_spooled(false); /* spool doesn't exit */
+ if (part_save == part) {
+ set_part_spooled(false); /* spool doesn't exit */
+ }
}
part = part_save; /* restore part number */
}
openmode = 0;
}
+/*
+ * This call closes the device, but it is used in DVD handling
+ * where we close one part and then open the next part. The
+ * difference between close_part() and close() is that close_part()
+ * saves the state information of the device (e.g. the Volume lable,
+ * the Volume Catalog record, ... This permits opening and closing
+ * the Volume parts multiple times without losing track of what the
+ * main Volume parameters are.
+ */
+void DEVICE::close_part(DCR *dcr)
+{
+ VOLUME_LABEL saveVolHdr;
+ VOLUME_CAT_INFO saveVolCatInfo; /* Volume Catalog Information */
+
+
+ memcpy(&saveVolHdr, &VolHdr, sizeof(saveVolHdr));
+ memcpy(&saveVolCatInfo, &VolCatInfo, sizeof(saveVolCatInfo));
+ close(); /* close current part */
+ memcpy(&VolHdr, &saveVolHdr, sizeof(VolHdr));
+ memcpy(&VolCatInfo, &saveVolCatInfo, sizeof(VolCatInfo));
+ memcpy(&dcr->VolCatInfo, &saveVolCatInfo, sizeof(dcr->VolCatInfo));
+}
+
+
bool DEVICE::truncate(DCR *dcr) /* We need the DCR for DVD-writing */