+ qname = quote_string(dp->name);
+ g_printf(_("driver: finished-cmd time %s taper wrote %s:%s\n"),
+ walltime_str(curclock()), dp->host->hostname, qname);
+ fflush(stdout);
+
+ if (strcmp(result_argv[2], "INPUT-ERROR") == 0) {
+ taper->input_error = newstralloc(taper->input_error, result_argv[4]);
+ taper->result = FAILED;
+ amfree(qname);
+ break;
+ } else if (strcmp(result_argv[2], "INPUT-GOOD") != 0) {
+ taper->tape_error = newstralloc(taper->tape_error,
+ _("Taper protocol error"));
+ taper->result = FAILED;
+ log_add(L_FAIL, _("%s %s %s %d [%s]"),
+ dp->host->hostname, qname, sched(dp)->datestamp,
+ sched(dp)->level, taper->tape_error);
+ amfree(qname);
+ break;
+ }
+ if (strcmp(result_argv[3], "TAPE-ERROR") == 0 ||
+ strcmp(result_argv[3], "TAPE-CONFIG") == 0) {
+ taper->state &= ~TAPER_STATE_TAPE_STARTED;
+ taper->tape_error = newstralloc(taper->tape_error, result_argv[5]);
+ taper->result = FAILED;
+ amfree(qname);
+ break;
+ } else if (strcmp(result_argv[3], "TAPE-GOOD") != 0) {
+ taper->state &= ~TAPER_STATE_TAPE_STARTED;
+ taper->tape_error = newstralloc(taper->tape_error,
+ _("Taper protocol error"));
+ taper->result = FAILED;
+ log_add(L_FAIL, _("%s %s %s %d [%s]"),
+ dp->host->hostname, qname, sched(dp)->datestamp,
+ sched(dp)->level, taper->tape_error);
+ amfree(qname);
+ break;
+ }
+
+ amfree(qname);
+ taper->result = cmd;
+
+ break;
+
+ case PARTIAL: /* PARTIAL <handle> INPUT-* TAPE-* <stat mess> <input err mesg> <tape err mesg>*/
+ case DONE: /* DONE <handle> INPUT-GOOD TAPE-GOOD <stat mess> <input err mesg> <tape err mesg> */
+ if(result_argc != 7) {
+ error(_("error: [taper PARTIAL result_argc != 7: %d"), result_argc);
+ /*NOTREACHED*/
+ }
+
+ dp = serial2disk(result_argv[1]);
+ taper = sched(dp)->taper;
+ assert(dp == taper->disk);
+ if (!taper->dumper)
+ free_serial(result_argv[1]);
+
+ qname = quote_string(dp->name);
+ g_printf(_("driver: finished-cmd time %s taper wrote %s:%s\n"),
+ walltime_str(curclock()), dp->host->hostname, qname);
+ fflush(stdout);
+
+ if (strcmp(result_argv[2], "INPUT-ERROR") == 0) {
+ taper->input_error = newstralloc(taper->input_error, result_argv[5]);
+ taper->result = FAILED;
+ amfree(qname);
+ break;
+ } else if (strcmp(result_argv[2], "INPUT-GOOD") != 0) {
+ taper->tape_error = newstralloc(taper->tape_error,
+ _("Taper protocol error"));
+ taper->result = FAILED;
+ log_add(L_FAIL, _("%s %s %s %d [%s]"),
+ dp->host->hostname, qname, sched(dp)->datestamp,
+ sched(dp)->level, taper->tape_error);
+ amfree(qname);
+ break;
+ }
+ if (strcmp(result_argv[3], "TAPE-ERROR") == 0 ||
+ strcmp(result_argv[3], "TAPE-CONFIG") == 0) {
+ taper->state &= ~TAPER_STATE_TAPE_STARTED;
+ taper->tape_error = newstralloc(taper->tape_error, result_argv[6]);
+ taper->result = FAILED;
+ amfree(qname);
+ break;
+ } else if (strcmp(result_argv[3], "TAPE-GOOD") != 0) {
+ taper->state &= ~TAPER_STATE_TAPE_STARTED;
+ taper->tape_error = newstralloc(taper->tape_error,
+ _("Taper protocol error"));
+ taper->result = FAILED;
+ log_add(L_FAIL, _("%s %s %s %d [%s]"),
+ dp->host->hostname, qname, sched(dp)->datestamp,
+ sched(dp)->level, taper->tape_error);
+ amfree(qname);
+ break;
+ }
+
+ s = strstr(result_argv[4], " kb ");
+ if (s) {
+ s += 4;
+ sched(dp)->dumpsize = OFF_T_ATOI(s);
+ } else {
+ s = strstr(result_argv[4], " bytes ");
+ if (s) {
+ s += 7;
+ sched(dp)->dumpsize = OFF_T_ATOI(s)/1024;
+ }
+ }
+
+ taper->result = cmd;
+ amfree(qname);
+
+ break;
+
+ case PARTDONE: /* PARTDONE <handle> <label> <fileno> <kbytes> <stat> */
+ dp = serial2disk(result_argv[1]);
+ taper = sched(dp)->taper;
+ assert(dp == taper->disk);
+ if (result_argc != 6) {
+ error(_("error [taper PARTDONE result_argc != 6: %d]"),
+ result_argc);
+ /*NOTREACHED*/
+ }
+ if (!taper->first_label) {
+ amfree(taper->first_label);
+ taper->first_label = stralloc(result_argv[2]);
+ taper->first_fileno = OFF_T_ATOI(result_argv[3]);
+ }
+ taper->written += OFF_T_ATOI(result_argv[4]);
+ if (taper->written > sched(taper->disk)->act_size)
+ sched(taper->disk)->act_size = taper->written;
+
+ partsize = 0;
+ s = strstr(result_argv[5], " kb ");
+ if (s) {
+ s += 4;
+ partsize = OFF_T_ATOI(s);
+ } else {
+ s = strstr(result_argv[5], " bytes ");
+ if (s) {
+ s += 7;
+ partsize = OFF_T_ATOI(s)/1024;
+ }
+ }
+ taper->left -= partsize;
+
+ break;
+
+ case REQUEST_NEW_TAPE: /* REQUEST-NEW-TAPE <handle> */
+ if (result_argc != 2) {
+ error(_("error [taper REQUEST_NEW_TAPE result_argc != 2: %d]"),
+ result_argc);
+ /*NOTREACHED*/
+ }