]> git.wh0rd.org - dump.git/blobdiff - rmt/rmt.c
Version 0.4b6.
[dump.git] / rmt / rmt.c
index 74116b0a46e84f82a1a96ce321d5d766caf8a030..92353af4d2ee77ef3297ffd391ac683ed5b2a45f 100644 (file)
--- a/rmt/rmt.c
+++ b/rmt/rmt.c
@@ -1,7 +1,8 @@
 /*
  *     Ported to Linux's Second Extended File System as part of the
  *     dump and restore backup suit
- *     Remy Card <card@Linux.EU.Org>, 1994, 1995, 1996
+ *     Remy Card <card@Linux.EU.Org>, 1994-1997
+ *      Stelian Pop <pop@cybercable.fr>, 1999 
  *
  */
 
  */
 
 #ifndef lint
-static char copyright[] =
+static const char copyright[] =
 "@(#) Copyright (c) 1983, 1993\n\
        The Regents of the University of California.  All rights reserved.\n";
 #endif /* not lint */
 
 #ifndef lint
+#if 0
 static char sccsid[] = "@(#)rmt.c      8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+       "$Id: rmt.c,v 1.3 1999/10/11 12:59:21 stelian Exp $";
 #endif /* not lint */
 
 /*
@@ -62,6 +67,12 @@ static char sccsid[] = "@(#)rmt.c    8.1 (Berkeley) 6/6/93";
 #include <string.h>
 #include <unistd.h>
 
+#ifdef __linux__
+#include <linux/ext2_fs.h>
+#include <ext2fs/ext2fs.h>
+#include <bsdcompat.h>
+#endif
+
 int    tape = -1;
 
 char   *record;
@@ -83,11 +94,9 @@ void  error __P((int));
 void    getstring __P((char *));
 
 int
-main(argc, argv)
-       int argc;
-       char **argv;
+main(int argc, char *argv[])
 {
-       int rval;
+       int rval = 0;
        char c;
        int n, i, cc;
 
@@ -111,7 +120,12 @@ top:
                getstring(device);
                getstring(mode);
                DEBUG2("rmtd: O %s %s\n", device, mode);
-               tape = open(device, atoi(mode));
+               /*
+                * 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(mode), 0666);
                if (tape < 0)
                        goto ioerror;
                goto respond;
@@ -188,6 +202,12 @@ top:
                  goto top;
                }
 
+        case 'V':               /* version */
+                getstring(op);
+                DEBUG1("rmtd: V %s\n", op);
+                rval = 2;
+                goto respond;
+
        default:
                DEBUG1("rmtd: garbage command %c\n", c);
                exit(3);
@@ -202,9 +222,7 @@ ioerror:
        goto top;
 }
 
-void
-getstring(bp)
-       char *bp;
+void getstring(char *bp)
 {
        int i;
        char *cp = bp;
@@ -219,9 +237,7 @@ getstring(bp)
 }
 
 char *
-checkbuf(record, size)
-       char *record;
-       int size;
+checkbuf(char *record, int size)
 {
 
        if (size <= maxrecsize)
@@ -241,11 +257,10 @@ checkbuf(record, size)
 }
 
 void
-error(num)
-       int num;
+error(int num)
 {
 
        DEBUG2("rmtd: E %d (%s)\n", num, strerror(num));
-       (void)sprintf(resp, "E%d\n%s\n", num, strerror(num));
+       (void)snprintf(resp, sizeof(resp), "E%d\n%s\n", num, strerror(num));
        (void)write(1, resp, strlen(resp));
 }