]> git.wh0rd.org - dump.git/blobdiff - rmt/rmt.c
Prepare for release 0.4b32.
[dump.git] / rmt / rmt.c
index acacb2d4f865d6a7d3d8f54fbfa887dbaccd5588..fc6eb827f4788c0c60b878f918c1eb0fc0e394b8 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.18 2002/04/15 11:57:29 stelian Exp $";
+       "$Id: rmt.c,v 1.21 2002/07/29 12:00:34 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>
@@ -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;