lint
[unix-history] / usr / src / sbin / dump / dumprmt.c
index e2cafd3..71a002b 100644 (file)
@@ -1,28 +1,66 @@
-static char *sccsid = "@(#)dumprmt.c   1.8 (Berkeley) %G%";
-
+/*-
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
+#ifndef lint
+static char sccsid[] = "@(#)dumprmt.c  5.14 (Berkeley) %G%";
+#endif /* not lint */
+
+#ifdef sunos
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/param.h>
+#include <sys/mtio.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <sys/dir.h>
+#include <sys/vnode.h>
+#include <ufs/inode.h>
+#else
 #include <sys/param.h>
 #include <sys/mtio.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/param.h>
 #include <sys/mtio.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
-#include <sys/inode.h>
+#include <sys/time.h>
+#include <ufs/ufs/dinode.h>
+#include <stdio.h>
+#endif
+#include <signal.h>
 
 #include <netinet/in.h>
 
 
 #include <netinet/in.h>
 
-#include <stdio.h>
-#include <pwd.h>
 #include <netdb.h>
 #include <netdb.h>
-#include <dumprestor.h>
+#include <protocols/dumprestore.h>
+#include <pwd.h>
+#ifdef __STDC__
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#endif
+#include "pathnames.h"
 
 #define        TS_CLOSED       0
 #define        TS_OPEN         1
 
 static int rmtstate = TS_CLOSED;
 int    rmtape;
 
 #define        TS_CLOSED       0
 #define        TS_OPEN         1
 
 static int rmtstate = TS_CLOSED;
 int    rmtape;
-int    rmtconnaborted();
+void   rmtgetconn();
+void   rmtconnaborted();
+int    rmtreply();
+int    rmtgetb();
+void   rmtgets();
+int    rmtcall();
 char   *rmtpeer;
 
 extern int ntrec;              /* blocking factor on tape */
 char   *rmtpeer;
 
 extern int ntrec;              /* blocking factor on tape */
+extern void msg();
 
 
+int
 rmthost(host)
        char *host;
 {
 rmthost(host)
        char *host;
 {
@@ -35,6 +73,7 @@ rmthost(host)
        return (1);
 }
 
        return (1);
 }
 
+void
 rmtconnaborted()
 {
 
 rmtconnaborted()
 {
 
@@ -42,6 +81,7 @@ rmtconnaborted()
        exit(1);
 }
 
        exit(1);
 }
 
+void
 rmtgetconn()
 {
        static struct servent *sp = 0;
 rmtgetconn()
 {
        static struct servent *sp = 0;
@@ -59,23 +99,26 @@ rmtgetconn()
        pw = getpwuid(getuid());
        if (pw && pw->pw_name)
                name = pw->pw_name;
        pw = getpwuid(getuid());
        if (pw && pw->pw_name)
                name = pw->pw_name;
-       rmtape = rcmd(&rmtpeer, sp->s_port, name, name, "/etc/rmt", 0);
+       rmtape = rcmd(&rmtpeer, sp->s_port, name, name, _PATH_RMT, 0);
        size = ntrec * TP_BSIZE;
        size = ntrec * TP_BSIZE;
-       if (setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)) < 0)
-               fprintf(stderr, "rdump: Warning: setsockopt buffer size failed.\n");
+       while (size > TP_BSIZE &&
+           setsockopt(rmtape, SOL_SOCKET, SO_SNDBUF, &size, sizeof (size)) < 0)
+               size -= TP_BSIZE;
 }
 
 }
 
+int
 rmtopen(tape, mode)
        char *tape;
        int mode;
 {
        char buf[256];
 
 rmtopen(tape, mode)
        char *tape;
        int mode;
 {
        char buf[256];
 
-       sprintf(buf, "O%s\n%d\n", tape, mode);
-       rmtcall(tape, buf);
+       (void)sprintf(buf, "O%s\n%d\n", tape, mode);
        rmtstate = TS_OPEN;
        rmtstate = TS_OPEN;
+       return (rmtcall(tape, buf));
 }
 
 }
 
+void
 rmtclose()
 {
 
 rmtclose()
 {
 
@@ -85,6 +128,7 @@ rmtclose()
        rmtstate = TS_CLOSED;
 }
 
        rmtstate = TS_CLOSED;
 }
 
+int
 rmtread(buf, count)
        char *buf;
        int count;
 rmtread(buf, count)
        char *buf;
        int count;
@@ -93,7 +137,7 @@ rmtread(buf, count)
        int n, i, cc;
        extern errno;
 
        int n, i, cc;
        extern errno;
 
-       sprintf(line, "R%d\n", count);
+       (void)sprintf(line, "R%d\n", count);
        n = rmtcall("read", line);
        if (n < 0) {
                errno = n;
        n = rmtcall("read", line);
        if (n < 0) {
                errno = n;
@@ -108,27 +152,30 @@ rmtread(buf, count)
        return (n);
 }
 
        return (n);
 }
 
+int
 rmtwrite(buf, count)
        char *buf;
        int count;
 {
        char line[30];
 
 rmtwrite(buf, count)
        char *buf;
        int count;
 {
        char line[30];
 
-       sprintf(line, "W%d\n", count);
+       (void)sprintf(line, "W%d\n", count);
        write(rmtape, line, strlen(line));
        write(rmtape, buf, count);
        return (rmtreply("write"));
 }
 
        write(rmtape, line, strlen(line));
        write(rmtape, buf, count);
        return (rmtreply("write"));
 }
 
+void
 rmtwrite0(count)
        int count;
 {
        char line[30];
 
 rmtwrite0(count)
        int count;
 {
        char line[30];
 
-       sprintf(line, "W%d\n", count);
+       (void)sprintf(line, "W%d\n", count);
        write(rmtape, line, strlen(line));
 }
 
        write(rmtape, line, strlen(line));
 }
 
+void
 rmtwrite1(buf, count)
        char *buf;
        int count;
 rmtwrite1(buf, count)
        char *buf;
        int count;
@@ -137,19 +184,20 @@ rmtwrite1(buf, count)
        write(rmtape, buf, count);
 }
 
        write(rmtape, buf, count);
 }
 
+int
 rmtwrite2()
 {
 rmtwrite2()
 {
-       int i;
 
        return (rmtreply("write"));
 }
 
 
        return (rmtreply("write"));
 }
 
+int
 rmtseek(offset, pos)
        int offset, pos;
 {
        char line[80];
 
 rmtseek(offset, pos)
        int offset, pos;
 {
        char line[80];
 
-       sprintf(line, "L%d\n%d\n", offset, pos);
+       (void)sprintf(line, "L%d\n%d\n", offset, pos);
        return (rmtcall("seek", line));
 }
 
        return (rmtcall("seek", line));
 }
 
@@ -169,6 +217,7 @@ rmtstatus()
        return (&mts);
 }
 
        return (&mts);
 }
 
+int
 rmtioctl(cmd, count)
        int cmd, count;
 {
 rmtioctl(cmd, count)
        int cmd, count;
 {
@@ -176,10 +225,11 @@ rmtioctl(cmd, count)
 
        if (count < 0)
                return (-1);
 
        if (count < 0)
                return (-1);
-       sprintf(buf, "I%d\n%d\n", cmd, count);
+       (void)sprintf(buf, "I%d\n%d\n", cmd, count);
        return (rmtcall("ioctl", buf));
 }
 
        return (rmtcall("ioctl", buf));
 }
 
+int
 rmtcall(cmd, buf)
        char *cmd, *buf;
 {
 rmtcall(cmd, buf)
        char *cmd, *buf;
 {
@@ -189,10 +239,10 @@ rmtcall(cmd, buf)
        return (rmtreply(cmd));
 }
 
        return (rmtreply(cmd));
 }
 
+int
 rmtreply(cmd)
        char *cmd;
 {
 rmtreply(cmd)
        char *cmd;
 {
-       register int c;
        char code[30], emsg[BUFSIZ];
 
        rmtgets(code, sizeof (code));
        char code[30], emsg[BUFSIZ];
 
        rmtgets(code, sizeof (code));
@@ -213,6 +263,7 @@ rmtreply(cmd)
        return (atoi(code + 1));
 }
 
        return (atoi(code + 1));
 }
 
+int
 rmtgetb()
 {
        char c;
 rmtgetb()
 {
        char c;
@@ -222,6 +273,7 @@ rmtgetb()
        return (c);
 }
 
        return (c);
 }
 
+void
 rmtgets(cp, len)
        char *cp;
        int len;
 rmtgets(cp, len)
        char *cp;
        int len;