fix read code
authorKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 19 May 1982 15:46:22 +0000 (07:46 -0800)
committerKirk McKusick <mckusick@ucbvax.Berkeley.EDU>
Wed, 19 May 1982 15:46:22 +0000 (07:46 -0800)
SCCS-vsn: usr.sbin/rmt/rmt.c 4.3

usr/src/usr.sbin/rmt/rmt.c

index 86c8da7..8b682fa 100644 (file)
@@ -1,5 +1,5 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)rmt.c      4.2 82/04/19";
+static char sccsid[] = "@(#)rmt.c      4.3 82/05/19";
 #endif
 
 /*
 #endif
 
 /*
@@ -59,7 +59,7 @@ if (debug) fprintf(debug, "rmtd: O %s %s\n", device, mode);
                tape = open(device, atoi(mode));
                if (tape < 0)
                        goto ioerror;
                tape = open(device, atoi(mode));
                if (tape < 0)
                        goto ioerror;
-               break;
+               goto respond;
 
        case 'C':
 if (debug) fprintf(debug, "rmtd: C\n");
 
        case 'C':
 if (debug) fprintf(debug, "rmtd: C\n");
@@ -67,7 +67,7 @@ if (debug) fprintf(debug, "rmtd: C\n");
                if (close(tape) < 0)
                        goto ioerror;
                tape = -1;
                if (close(tape) < 0)
                        goto ioerror;
                tape = -1;
-               break;
+               goto respond;
 
        case 'L':
                gets(count); gets(pos);
 
        case 'L':
                gets(count); gets(pos);
@@ -75,7 +75,7 @@ if (debug) fprintf(debug, "rmtd: L %s %s\n", count, pos);
                rval = lseek(tape, (long) atoi(count), atoi(pos));
                if (rval < 0)
                        goto ioerror;
                rval = lseek(tape, (long) atoi(count), atoi(pos));
                if (rval < 0)
                        goto ioerror;
-               break;
+               goto respond;
 
        case 'W':
                gets(count);
 
        case 'W':
                gets(count);
@@ -91,7 +91,7 @@ if (debug) fprintf(debug, "rmtd: premature eof\n");
                rval = write(tape, record, n);
                if (rval < 0)
                        goto ioerror;
                rval = write(tape, record, n);
                if (rval < 0)
                        goto ioerror;
-               break;
+               goto respond;
 
        case 'R':
                gets(count);
 
        case 'R':
                gets(count);
@@ -102,8 +102,10 @@ if (debug) fprintf(debug, "rmtd: R %s\n", count);
                rval = read(tape, record, n);
                if (rval < 0)
                        goto ioerror;
                rval = read(tape, record, n);
                if (rval < 0)
                        goto ioerror;
-               (void) write(1, record, n);
-               break;
+               (void) sprintf(resp, "A%d\n", rval);
+               (void) write(1, resp, strlen(resp));
+               (void) write(1, record, rval);
+               goto top;
 
        case 'I':
                gets(op); gets(count);
 
        case 'I':
                gets(op); gets(count);
@@ -115,7 +117,7 @@ if (debug) fprintf(debug, "rmtd: I %s %s\n", op, count);
                        goto ioerror;
                  rval = mtop.mt_count;
                }
                        goto ioerror;
                  rval = mtop.mt_count;
                }
-               break;
+               goto respond;
 
        case 'S':               /* status */
 if (debug) fprintf(debug, "rmtd: S\n");
 
        case 'S':               /* status */
 if (debug) fprintf(debug, "rmtd: S\n");
@@ -124,13 +126,14 @@ if (debug) fprintf(debug, "rmtd: S\n");
                        goto ioerror;
                  rval = sizeof (mtget);
                  (void) write(1, (char *)&mtget, sizeof (mtget));
                        goto ioerror;
                  rval = sizeof (mtget);
                  (void) write(1, (char *)&mtget, sizeof (mtget));
-                 break;
+                 goto respond;
                }
 
        default:
 if (debug) fprintf(debug, "rmtd: garbage command %c\n", c);
                exit(1);
        }
                }
 
        default:
 if (debug) fprintf(debug, "rmtd: garbage command %c\n", c);
                exit(1);
        }
+respond:
 if (debug) fprintf(debug, "rmtd: A %d\n", rval);
        (void) sprintf(resp, "A%d\n", rval);
        (void) write(1, resp, strlen(resp));
 if (debug) fprintf(debug, "rmtd: A %d\n", rval);
        (void) sprintf(resp, "A%d\n", rval);
        (void) write(1, resp, strlen(resp));