- along with this program; if not, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-/* The man page rmt(8) for /etc/rmt documents the remote mag tape
- protocol which rdump and rrestore use. Unfortunately, the man
- page is *WRONG*. The author of the routines I'm including originally
- wrote his code just based on the man page, and it didn't work, so he
- went to the rdump source to figure out why. The only thing he had to
- change was to check for the 'F' return code in addition to the 'E',
- and to separate the various arguments with \n instead of a space. I
- personally don't think that this is much of a problem, but I wanted to
- point it out. -- Arnold Robbins
-
- Originally written by Jeff Lee, modified some by Arnold Robbins.
- Redone as a library that can replace open, read, write, etc., by
- Fred Fish, with some additional work by Arnold Robbins.
- Modified to make all rmtXXX calls into macros for speed by Jay Fenlason.
- Use -DHAVE_NETDB_H for rexec code, courtesy of Dan Kegel, srs!dan. */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <signal.h>
-
-#ifdef HAVE_SYS_MTIO_H
-#include <sys/ioctl.h>
-#include <sys/mtio.h>
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
+
+/* The man page rmt(8) for /etc/rmt documents the remote mag tape protocol
+ which rdump and rrestore use. Unfortunately, the man page is *WRONG*.
+ The author of the routines I'm including originally wrote his code just
+ based on the man page, and it didn't work, so he went to the rdump source
+ to figure out why. The only thing he had to change was to check for the
+ 'F' return code in addition to the 'E', and to separate the various
+ arguments with \n instead of a space. I personally don't think that this
+ is much of a problem, but I wanted to point it out. -- Arnold Robbins
+
+ Originally written by Jeff Lee, modified some by Arnold Robbins. Redone
+ as a library that can replace open, read, write, etc., by Fred Fish, with
+ some additional work by Arnold Robbins. Modified to make all rmt* calls
+ into macros for speed by Jay Fenlason. Use -DWITH_REXEC for rexec
+ code, courtesy of Dan Kegel. */
+
+#include "system.h"
+
+#include "basename.h"
+#include "safe-read.h"
+
+/* Try hard to get EOPNOTSUPP defined. 486/ISC has it in net/errno.h,
+ 3B2/SVR3 has it in sys/inet.h. Otherwise, like on MSDOS, use EINVAL. */
+
+#ifndef EOPNOTSUPP
+# if HAVE_NET_ERRNO_H
+# include <net/errno.h>
+# endif
+# if HAVE_SYS_INET_H
+# include <sys/inet.h>
+# endif
+# ifndef EOPNOTSUPP
+# define EOPNOTSUPP EINVAL
+# endif