+ if (device->volume_label != NULL) {
+ *label = g_strdup(device->volume_label);
+ *timestamp = strdup(device->volume_time);
+ } else if (label_status & READ_LABEL_STATUS_VOLUME_UNLABELED) {
+ g_object_unref(device);
+ if (!getconf_seen(CNF_LABEL_NEW_TAPES)) {
+ *error_message = newvstrallocf(*error_message,
+ _("%sFound a non-amanda tape.\n"),
+ *error_message);
+
+ return -1;
+ }
+ *label = find_brand_new_tape_label();
+ if (*label != NULL) {
+ *timestamp = stralloc("X");
+ *error_message = newvstrallocf(*error_message,
+ _("%sFound a non-amanda tape, will label it `%s'.\n"),
+ *error_message, *label);
+
+ return 3;
+ }
+ *error_message = newvstrallocf(*error_message,
+ _("%sFound a non-amanda tape, but have no labels left.\n"),
+ *error_message);
+
+ return -1;
+ } else {
+ char * label_errstr;
+ char ** label_strv =
+ g_flags_nick_to_strv(label_status, READ_LABEL_STATUS_FLAGS_TYPE);
+
+ switch (g_strv_length(label_strv)) {
+ case 0:
+ label_errstr = g_strdup(_("Unknown error reading volume label.\n"));
+ break;
+
+ case 1:
+ label_errstr =
+ g_strdup_printf(_("Error reading volume label: %s\n"),
+ *label_strv);
+ break;
+
+ default:
+ {
+ char * tmp_str = g_english_strjoinv(label_strv, "or");
+ label_errstr =
+ g_strdup_printf(_("Error reading label: One of %s\n"),
+ tmp_str);
+ g_free(tmp_str);
+ }
+ }
+
+ g_strfreev(label_strv);
+
+ *error_message = newvstralloc(*error_message, *error_message,
+ label_errstr, NULL);
+ g_free(label_errstr);
+ return -1;