#include <rmt.h> #include <sys/stat.h> /* MUST come after <rmt.h> */ int isrmt (fd) int fd; int rmtaccess (file, mode) char *file; int mode; int rmtclose (fd) int fd; int rmtcreat (file, mode) char *file; int mode; int rmtdup (fd) int fd; int rmtfcntl (fd, cmd, arg) int fd, cmd, arg; int rmtfstat (fd, buf) int fd; struct stat *buf; int rmtioctl (fd, request, argp) int fd, request; char *argp; int rmtisatty (fd) int fd; long rmtlseek (fd, offset, whence) int fd, whence; long offset; int rmtlstat (file, buf) char *file; struct stat *buf; int rmtopen (file, flags [, mode]) char *file; int flags, mode; int rmtread (fd, buf, nbytes) int fd, nbytes; char *buf; int rmtstat (file, buf) char *file; struct stat *buf; int rmtwrite (fd, buf, nbytes) int fd, nbytes; char *buf;
A remote tape drive file name has the form
where system is the remote system, /dev/??? is the particular drive on the remote system (raw, blocked, rewinding, non-rewinding, etc.), and the optional user is the login name to be used on the remote system, if different from the current user's login name.
The library source code may be optionally compiled to recognize the old, 4.2 BSD, remote syntax
By default, only the first form (introduced in 4.3 BSD) is recognized.
For transparency, the user should include the file <rmt.h>, which has the following defines in it:
#define access rmtaccess #define close rmtclose #define creat rmtcreat #define dup rmtdup #define fcntl rmtfcntl #define fstat rmtfstat #define ioctl rmtioctl #define isatty rmtisatty #define lseek rmtlseek #define lstat rmtlstat #define open rmtopen #define read rmtread #define stat rmtstat #define write rmtwrite
This allows the programmer to use open, close, read, write, etc. in their normal fashion, with the rmtops routines taking care of differentiating between local and remote files. This file should be included before including the file <sys/stat.h>, since it redefines the identifier ``stat,'' which is used to declare objects of type struct stat.
The routines differentiate between local and remote file descriptors by adding a bias (currently 128) to the file descriptor of the pipe. The programmer, if he or she must know if a file is remote, should use the isrmt function.
There is no way to use remote tape drives with the stdio(3) package, short of recompiling it entirely to use these routines.
The rmt(8) protocol is not very capable. In particular, it relies on TCP/IP sockets for error free transmission, and does no data validation of its own.
By default, the library opens two pipes to rsh(1). It may optionally be compiled to use rexec(3), instead. Doing so requires the use of a .netrc file in the user's home directory, or that the application designer be willing to have rexec prompt the user for a login name and password on the remote host.
Fred Fish (unisoft!fnf) redid them into a general purpose library.
Arnold Robbins (formerly gatech!arnold, now emory!arnold) added the ability to specify a user name on the remote system, the <rmt.h> include file, this man page, cleaned up the library a little, and made the appropriate changes for 4.3 BSD.
Dan Kegel (srs!dan) contributed the code to use rexec(3) library routine.