]> git.wh0rd.org - dump.git/blobdiff - rmt/rmt.c
Fixed largefile seeks in rmt
[dump.git] / rmt / rmt.c
index 3c8f5fd3dd3ab17f90af0d6ea5738b6d5106fa27..7f93f57cf32991dd70d96fa329d05ab867db7cb5 100644 (file)
--- a/rmt/rmt.c
+++ b/rmt/rmt.c
@@ -41,7 +41,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-       "$Id: rmt.c,v 1.19 2002/04/16 21:00:59 stelian Exp $";
+       "$Id: rmt.c,v 1.23 2003/02/12 11:02:31 stelian Exp $";
 #endif /* not linux */
 
 /*
@@ -49,6 +49,7 @@ static const char rcsid[] =
  */
 #include <config.h>
 #include <compatlfs.h>
+#include <rmtflags.h>
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <sys/mtio.h>
@@ -121,9 +122,9 @@ void         getstring __P((char *));
 int
 main(int argc, char *argv[])
 {
-       int rval = 0;
+       OFF_T 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;
@@ -201,7 +214,7 @@ top:
                rval = read(tape, record, n);
                if (rval < 0)
                        goto ioerror;
-               (void)sprintf(resp, "A%d\n", rval);
+               (void)sprintf(resp, "A%lld\n", (long long)rval);
                (void)write(1, resp, strlen(resp));
                (void)write(1, record, rval);
                block += n >> 10;
@@ -334,7 +347,7 @@ top:
                  if (ioctl(tape, MTIOCGET, (char *)&mtget) < 0)
                        goto ioerror;
                  rval = sizeof (mtget);
-                 (void)sprintf(resp, "A%d\n", rval);
+                 (void)sprintf(resp, "A%lld\n", (long long)rval);
                  (void)write(1, resp, strlen(resp));
                  (void)write(1, (char *)&mtget, sizeof (mtget));
                  goto top;
@@ -394,8 +407,8 @@ top:
                exit(3);
        }
 respond:
-       DEBUG1("rmtd: A %d\n", rval);
-       (void)sprintf(resp, "A%d\n", rval);
+       DEBUG1("rmtd: A %lld\n", (long long)rval);
+       (void)sprintf(resp, "A%lld\n", (long long)rval);
        (void)write(1, resp, strlen(resp));
        goto top;
 ioerror: