X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=rmt%2Frmt.c;h=3167e1dd76e1f4015ccf83af6d26a763a28b7e0f;hb=5bf65105dbaf0bb3d6fb4ccb3d8790bda496d861;hp=acacb2d4f865d6a7d3d8f54fbfa887dbaccd5588;hpb=d24dc8af74ac524f4a4807674f4863630d8f829f;p=dump.git diff --git a/rmt/rmt.c b/rmt/rmt.c index acacb2d..3167e1d 100644 --- a/rmt/rmt.c +++ b/rmt/rmt.c @@ -41,7 +41,7 @@ #ifndef lint static const char rcsid[] = - "$Id: rmt.c,v 1.18 2002/04/15 11:57:29 stelian Exp $"; + "$Id: rmt.c,v 1.22 2003/01/10 14:42:51 stelian Exp $"; #endif /* not linux */ /* @@ -49,6 +49,7 @@ static const char rcsid[] = */ #include #include +#include #include #include #include @@ -84,7 +85,7 @@ static FILE *debug; * and relicensed by his permission from GPL to BSD for use in dump. * * rmt_version is 0 for regular clients (Linux included) - * rmt_version is 1 for extended clients (Sun especially). In this cas + * rmt_version is 1 for extended clients (Sun especially). In this case * we support some extended commands (see below) and we remap * the ioctl commands to the UNIX "standard", as per: * ftp://ftp.fokus.gmd.de/pub/unix/star/README.mtio @@ -123,7 +124,7 @@ main(int argc, char *argv[]) { int rval = 0; char c; - int n, i, cc; + int n, i, cc, oflags; unsigned long block = 0; argc--, argv++; @@ -146,12 +147,24 @@ top: getstring(device); getstring(filemode); DEBUG2("rmtd: O %s %s\n", device, filemode); + /* + * Translate extended GNU syntax into its numeric platform equivalent + */ + oflags = rmtflags_toint(filemode); +#ifdef O_TEXT + /* + * Default to O_BINARY the client may not know that we need it. + */ + if ((oflags & O_TEXT) == 0) + oflags |= O_BINARY; +#endif + DEBUG2("rmtd: O %s %d\n", device, oflags); /* * XXX the rmt protocol does not provide a means to * specify the permission bits; allow rw for everyone, * as modified by the users umask */ - tape = OPEN(device, atoi(filemode), 0666); + tape = OPEN(device, oflags, 0666); if (tape < 0) goto ioerror; block = 0; @@ -170,7 +183,7 @@ top: 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)atoll(count), atoi(pos)); if (rval < 0) goto ioerror; goto respond;