X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=rmt%2Frmt.c;h=e23d0a3f350c860a6c15efe68230d2058f2c933e;hb=95c74f382492999827000f544fcb6844150cda81;hp=f52c36ba8b602b38c632457a4cd9b5fc9adee081;hpb=c930abff2469b9571a22fc49d16f50f36f5a9301;p=dump.git diff --git a/rmt/rmt.c b/rmt/rmt.c index f52c36b..e23d0a3 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -2,7 +2,8 @@ * Ported to Linux's Second Extended File System as part of the * dump and restore backup suit * Remy Card , 1994-1997 - * Stelian Pop , 1999 + * Stelian Pop , 1999-2000 + * Stelian Pop - AlcĂ´ve , 2000 */ /* @@ -40,12 +41,14 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.8 1999/11/21 02:24:47 tiniou Exp $"; + "$Id: rmt.c,v 1.14 2001/04/27 15:22:47 stelian Exp $"; #endif /* not linux */ /* * rmt */ +#include +#include #include #include #include @@ -85,6 +88,7 @@ main(int argc, char *argv[]) int rval = 0; char c; int n, i, cc; + unsigned long block = 0; argc--, argv++; if (argc > 0) { @@ -111,24 +115,26 @@ top: * specify the permission bits; allow rw for everyone, * as modified by the users umask */ - tape = open(device, atoi(filemode), 0666); + tape = OPEN(device, atoi(filemode), 0666); if (tape < 0) goto ioerror; + block = 0; goto respond; case 'C': - DEBUG("rmtd: C\n"); + DEBUG1("rmtd: C (%lu blocks)\n", block); getstring(device); /* discard */ if (close(tape) < 0) goto ioerror; tape = -1; + block = 0; goto respond; case 'L': getstring(count); getstring(pos); DEBUG2("rmtd: L %s %s\n", count, pos); - rval = lseek(tape, (off_t)atol(count), atoi(pos)); + rval = LSEEK(tape, (off_t)atol(count), atoi(pos)); if (rval < 0) goto ioerror; goto respond; @@ -136,7 +142,7 @@ top: case 'W': getstring(count); n = atoi(count); - DEBUG1("rmtd: W %s\n", count); + DEBUG2("rmtd: W %s (block = %lu)\n", count, block); record = checkbuf(record, n); for (i = 0; i < n; i += cc) { cc = read(0, &record[i], n - i); @@ -148,11 +154,12 @@ top: rval = write(tape, record, n); if (rval < 0) goto ioerror; + block += n >> 10; goto respond; case 'R': getstring(count); - DEBUG1("rmtd: R %s\n", count); + DEBUG2("rmtd: R %s (block %lu)\n", count, block); n = atoi(count); record = checkbuf(record, n); rval = read(tape, record, n); @@ -161,6 +168,7 @@ top: (void)sprintf(resp, "A%d\n", rval); (void)write(1, resp, strlen(resp)); (void)write(1, record, rval); + block += n >> 10; goto top; case 'I':