results = get_memory(2000);
results[0] = 0;
/* If busy retry each second */
- Dmsg1(100, "Run prog=%s\n", ocmd.c_str());
+ Dmsg1(20, "Run mount prog=%s\n", ocmd.c_str());
while ((status = run_program_full_output(ocmd.c_str(),
dev->max_open_wait/2, results)) != 0) {
- Dmsg2(99, "Mount status=%d result=%s\n", status, results);
- /* Doesn't work with internationalisation (This is not a problem) */
+ Dmsg2(20, "Mount status=%d result=%s\n", status, results);
+ /* Doesn't work with internationalization (This is not a problem) */
if (mount && fnmatch("*is already mounted on*", results, 0) == 0) {
break;
}
char ed1[50];
bool ok = false;
int status;
+
+ if (!dev->is_dvd() || dev->is_freespace_ok()) {
+ return true;
+ }
/* The device must be mounted in order to dvd-freespace to work */
mount_dvd(dev, 1);
if (!icmd) {
dev->free_space = 0;
dev->free_space_errno = 0;
- dev->clear_freespace_ok(); /* No valid freespace */
+ dev->clear_freespace_ok(); /* No valid freespace */
dev->clear_media();
Dmsg2(29, "ERROR: update_free_space_dev: free_space=%s, free_space_errno=%d (!icmd)\n",
edit_uint64(dev->free_space, ed1), dev->free_space_errno);
while (1) {
berrno be;
- Dmsg1(100, "Run prog=%s\n", ocmd.c_str());
+ Dmsg1(20, "Run freespace prog=%s\n", ocmd.c_str());
status = run_program_full_output(ocmd.c_str(), dev->max_open_wait/2, results);
+ Dmsg2(20, "Freespace status=%d result=%s\n", status, results);
if (status == 0) {
free = str_to_int64(results);
Dmsg1(400, "Free space program run: Freespace=%s\n", results);
DEVICE *dev = dcr->dev;
POOL_MEM archive_name(PM_FNAME);
+ dev->clear_freespace_ok(); /* need to update freespace */
+
/* Don't write empty part files.
* This is only useful when growisofs does not support write beyond
* the 4GB boundary.
* in case of a serious emergency.
*/
- if (dev->part == 1)
+ if (dev->part == 1) {
timeout = 16000;
- else
+ } else {
timeout = dev->max_open_wait + (dev->part_size/(1350*1024/4));
+ }
- Dmsg2(29, "dvd_write_part: cmd=%s timeout=%d\n", ocmd.c_str(), timeout);
-
+ Dmsg2(20, "Write part: cmd=%s timeout=%d\n", ocmd.c_str(), timeout);
status = run_program_full_output(ocmd.c_str(), timeout, results.c_str());
+ Dmsg2(20, "Write part status=%d result=%s\n", status, results.c_str());
+ dev->truncated_dvd = false;
if (status != 0) {
Jmsg2(dcr->jcr, M_FATAL, 0, _("Error writing part %d to the DVD: ERR=%s\n"),
dev->part, results.c_str());
dev->dev_errno = EIO;
mark_volume_in_error(dcr);
sm_check(__FILE__, __LINE__, false);
- dev->truncated_dvd = false;
return false;
}
Jmsg(dcr->jcr, M_INFO, 0, _("Part %d written to DVD.\n"), dev->part);
- if (dev->truncated_dvd) {
- dev->truncated_dvd = false; /* turn off flag */
- } else { /* DVD part written */
- dev->num_dvd_parts++; /* there is now one more part on DVD */
- dev->VolCatInfo.VolCatParts = dev->num_dvd_parts;
- }
+ Dmsg2(400, "dvd_write_part: Part %d written to DVD\nResults: %s\n",
+ dev->part, results.c_str());
+
+ dev->num_dvd_parts++; /* there is now one more part on DVD */
+ dev->VolCatInfo.VolCatParts = dev->num_dvd_parts;
+ Dmsg1(000, "Update num_parts=%d\n", dev->num_dvd_parts);
/* Delete spool file */
make_spooled_dvd_filename(dev, archive_name);
int dvd_open_next_part(DCR *dcr)
{
DEVICE *dev = dcr->dev;
- VOLUME_LABEL VolHdr;
Dmsg6(29, "Enter: == open_next_part part=%d npart=%d dev=%s vol=%s mode=%d file_addr=%d\n",
dev->part, dev->num_dvd_parts, dev->print_name(),
return dev->fd;
}
- /*
- * Note, when we close, the Volume header is zeroed. Since
- * we reopen, but are in fact opening the same volume without
- * re-reading the Volume header, we simply save and restore it.
- */
- memcpy(&VolHdr, &dev->VolHdr, sizeof(VolHdr));
- dev->close(); /* close current part */
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
+ dev->close_part(dcr); /* close current part */
/*
* If we have a spooled part open, write it to the
dev->part++;
Dmsg2(29, "Inc part=%d num_dvd_parts=%d\n", dev->part, dev->num_dvd_parts);
+ /* Are we working on a part past what is written in the DVD? */
if (dev->num_dvd_parts < dev->part) {
POOL_MEM archive_name(PM_FNAME);
struct stat buf;
* First check what is on DVD. If our part is there, we
* are in trouble, so bail out.
* NB: This is however not a problem if we are writing the first part.
- * It simply means that we are overriding an existing volume...
+ * It simply means that we are over writing an existing volume...
*/
if (dev->num_dvd_parts > 0) {
make_mounted_dvd_filename(dev, archive_name); /* makes dvd name */
}
}
+#ifdef neeeded
Dmsg2(400, "num_dvd_parts=%d part=%d\n", dev->num_dvd_parts, dev->part);
make_spooled_dvd_filename(dev, archive_name); /* makes spool name */
/* Check if the next part exists in spool directory . */
- Dmsg1(100, "Check if part on spool: $s\n", archive_name.c_str());
+ Dmsg1(100, "Check if part on spool: %s\n", archive_name.c_str());
if ((stat(archive_name.c_str(), &buf) == 0) || (errno != ENOENT)) {
- Dmsg1(29, "open_next_part %s is in the way, deleting it...\n", archive_name.c_str());
+ Dmsg1(29, "======= Part %s is in the way, deleting it...\n", archive_name.c_str());
/* Then try to unlink it */
if (unlink(archive_name.c_str()) < 0) {
berrno be;
return -1;
}
}
+#endif
}
Dmsg2(400, "Call dev->open(vol=%s, mode=%d)\n", dcr->VolCatInfo.VolCatName,
if (dev->open(dcr, OPEN_READ_ONLY) < 0) {
return -1;
}
- /* Restore Volume header record */
- memcpy(&dev->VolHdr, &VolHdr, sizeof(dev->VolHdr));
dev->set_labeled(); /* all next parts are "labeled" */
return dev->fd;
int dvd_open_first_part(DCR *dcr, int mode)
{
DEVICE *dev = dcr->dev;
- VOLUME_LABEL VolHdr;
Dmsg5(29, "Enter: ==== open_first_part dev=%s Vol=%s mode=%d num_dvd_parts=%d append=%d\n", dev->print_name(),
dev->VolCatInfo.VolCatName, dev->openmode, dev->num_dvd_parts, dev->can_append());
- /*
- * Note, when we close, the Volume header is zeroed. Since
- * we reopen, but are in fact opening the same volume without
- * re-reading the Volume header, we simply save and restore it.
- */
- memcpy(&VolHdr, &dev->VolHdr, sizeof(VolHdr));
- dev->close();
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
+ dev->close_part(dcr);
Dmsg2(400, "Call dev->open(vol=%s, mode=%d)\n", dcr->VolCatInfo.VolCatName,
mode);
dev->part = 1;
dev->part_start = 0;
-
- /* Restore Volume header record */
- memcpy(&dev->VolHdr, &VolHdr, sizeof(dev->VolHdr));
if (dev->open(dcr, mode) < 0) {
Dmsg0(400, "open dev() failed\n");
return -1;
JCR *jcr = dcr->jcr;
bool ok = true;
- /* If the device is a dvd and WritePartAfterJob
+ /*
+ * If the device is a dvd and WritePartAfterJob
* is set to yes, open the next part, so, in case of a device
* that requires mount, it will be written to the device.
*/
{
DEVICE* dev = dcr->dev;
- dev->close();
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
+ dev->close_part(dcr);
if (!unmount_dvd(dev, 1)) {
Dmsg0(400, "truncate_dvd: Failed to unmount DVD\n");
return false;
}
- dev->close();
- memcpy(&dev->VolCatInfo, &dcr->VolCatInfo, sizeof(dev->VolCatInfo));
+ dev->close_part(dcr);
Dmsg0(400, "truncate_dvd: Opening first part (2)...\n");
struct dirent *entry, *result;
int name_max;
int count = 0;
- bool matched = false;
+ bool matched = true;
struct stat filestat;
name_max = pathconf(".", _PC_NAME_MAX);
filename.c_str(), be.strerror());
return false;
}
- Dmsg2(99, "check_can_write_on_non_blank_dvd: size of %s is %d\n",
+ Dmsg2(99, "check_can_write_on_non_blank_dvd: size of %s is %lld\n",
filename.c_str(), filestat.st_size);
matched = filestat.st_size == 0;
}