+ Enter(100);
+ ASSERT2(dcr->VolumeName[0], "Empty Volume name");
+ ASSERT(!dcr->block->adata);
+ if (!open_device(dcr, OPEN_READ_WRITE)) {
+ Jmsg4(jcr, M_WARNING, 0, _("Open %s device %s Volume \"%s\" failed: ERR=%s\n"),
+ print_type(), print_name(), dcr->VolumeName, bstrerror());
+ Leave(100);
+ return false;
+ }
+ Dmsg2(190, "set append found freshly labeled volume. fd=%d dev=%x\n", fd(), this);
+ VolHdr.LabelType = VOL_LABEL; /* set Volume label */
+ set_append();
+ Dmsg0(100, "Rewrite_volume_label set volcatbytes=0\n");
+ clearVolCatBytes(); /* resets both ameta and adata byte counts */
+ setVolCatStatus("Append"); /* set append status */
+
+ if (!has_cap(CAP_STREAM)) {
+ if (!rewind(dcr)) {
+ Jmsg3(jcr, M_FATAL, 0, _("Rewind error on %s device %s: ERR=%s\n"),
+ print_type(), print_name(), print_errmsg());
+ Leave(100);
+ return false;
+ }
+ if (recycle) {
+ Dmsg1(150, "Doing recycle. Vol=%s\n", dcr->VolumeName);
+ if (!truncate(dcr)) {
+ Jmsg3(jcr, M_FATAL, 0, _("Truncate error on %s device %s: ERR=%s\n"),
+ print_type(), print_name(), print_errmsg());
+ Leave(100);
+ return false;
+ }
+ if (!open_device(dcr, OPEN_READ_WRITE)) {
+ Jmsg3(jcr, M_FATAL, 0,
+ _("Failed to re-open device after truncate on %s device %s: ERR=%s"),
+ print_type(), print_name(), print_errmsg());
+ Leave(100);
+ return false;
+ }
+ }
+ }
+