+
+request_new_volume:
+ /* Tell the driver we overwrote this volume, even if it was empty, and request
+ * a new volume. */
+ if (state->device)
+ state->last_errmsg = newstralloc(state->last_errmsg, device_error_or_status(state->device));
+ else
+ state->last_errmsg = newstralloc(state->last_errmsg, "(unknown)");
+
+ putresult(NEW_TAPE, "%s %s\n", dump_info->handle,
+ state->next_tape_label);
+ if (old_volume_name) {
+ log_add(L_WARNING, "Problem writing label '%s' to volume %s "
+ "(volume may be erased): %s\n",
+ state->next_tape_label, old_volume_name,
+ state->last_errmsg);
+ } else {
+ log_add(L_WARNING, "Problem writing label '%s' to new volume "
+ "(volume may be erased): %s\n", state->next_tape_label,
+ state->last_errmsg);
+ }
+
+ if (state->device) {
+ g_object_unref(state->device);
+ state->device = NULL;
+ }
+
+ amfree(state->next_tape_label);
+ amfree(old_volume_name);
+ amfree(old_volume_time);
+
+ return find_and_label_new_tape(state, dump_info);
+
+skip_volume:
+ /* grab a new volume without talking to the driver again -- we do this if we're
+ * confident we didn't overwrite the last tape we got. */
+ if (state->device)
+ state->last_errmsg = newstralloc(state->last_errmsg, device_error_or_status(state->device));
+ else
+ state->last_errmsg = newstralloc(state->last_errmsg, "(unknown)");
+
+ if (old_volume_name) {
+ log_add(L_WARNING, "Problem writing label '%s' to volume '%s' "
+ "(old volume data intact): %s\n",
+ state->next_tape_label, old_volume_name, state->last_errmsg);
+ } else {
+ log_add(L_WARNING, "Problem writing label '%s' to new volume "
+ "(old volume data intact): %s\n", state->next_tape_label,
+ state->last_errmsg);
+ }
+
+ if (state->device) {
+ g_object_unref(state->device);
+ state->device = NULL;
+ }
+
+ amfree(state->next_tape_label);
+ amfree(old_volume_name);
+ amfree(old_volume_time);
+
+ request.state = state;
+ request.prolong = TRUE;
+ request.errmsg = NULL;
+ search_result = GPOINTER_TO_INT(tape_search_thread(&request));
+ if (search_result) {
+ amfree(request.errmsg);
+ return label_new_tape(state, dump_info);
+ } else {
+ /* Problem finding a new tape! */
+ log_taper_scan_errmsg(request.errmsg);
+ putresult(NO_NEW_TAPE, "%s\n", dump_info->handle);
+ return FALSE;
+ }