1.\" $OpenBSD: rmt.8,v 1.13 2015/09/20 10:05:48 halex Exp $ 2.\" 3.\" Copyright (c) 1983, 1991 The Regents of the University of California. 4.\" All rights reserved. 5.\" 6.\" Redistribution and use in source and binary forms, with or without 7.\" modification, are permitted provided that the following conditions 8.\" are met: 9.\" 1. Redistributions of source code must retain the above copyright 10.\" notice, this list of conditions and the following disclaimer. 11.\" 2. Redistributions in binary form must reproduce the above copyright 12.\" notice, this list of conditions and the following disclaimer in the 13.\" documentation and/or other materials provided with the distribution. 14.\" 3. Neither the name of the University nor the names of its contributors 15.\" may be used to endorse or promote products derived from this software 16.\" without specific prior written permission. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 19.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 22.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28.\" SUCH DAMAGE. 29.\" 30.\" from: @(#)rmt.8 6.5 (Berkeley) 3/16/91 31.\" 32.Dd $Mdocdate: September 20 2015 $ 33.Dt RMT 8 34.Os 35.Sh NAME 36.Nm rmt 37.Nd remote magtape protocol module 38.Sh SYNOPSIS 39.Nm 40.Op Fl r | w 41.Op Fl d Ar directory 42.Sh DESCRIPTION 43.Nm 44is a program used by the remote dump and restore programs 45through an interprocess communication connection. 46Traditionally it is used for manipulating a magnetic tape drive but it may 47be used for regular file access as well. 48.Nm 49is normally started up with an 50.Xr rcmd 3 51or 52.Xr rcmdsh 3 53call. 54.Pp 55The options are as follows: 56.Bl -tag -width Ds 57.It Fl d Ar directory 58Confine file access to 59.Ar directory . 60Forward slashes in filenames are disallowed and symlinks are not followed. 61.It Fl r 62Read-only mode, suitable for use with 63.Xr rrestore 8 . 64.It Fl w 65File write mode, suitable for use with 66.Xr rdump 8 67for dumping to regular files. 68Creates missing files and refuses to open existing ones. 69The file permission bits are set to readonly. 70.El 71.Pp 72The 73.Nm 74program accepts requests specific to the manipulation of 75magnetic tapes, performs the commands, then responds with 76a status indication. 77All responses are in ASCII and in one of two forms. 78Successful commands have responses of: 79.Pp 80.D1 Sy A Ns Ar number Ns \en 81.Pp 82.Ar number 83is an ASCII representation of a decimal number. 84Unsuccessful commands are responded to with: 85.Bd -filled -offset indent 86.Sm off 87.Sy E Ar error-number No \en Ar error-message No \en 88.Sm on 89.Ed 90.Pp 91.Ar error-number 92is one of the possible error 93numbers described in 94.Xr intro 2 95and 96.Ar error-message 97is the corresponding error string as printed 98from a call to 99.Xr perror 3 . 100The protocol is comprised of the 101following commands, which are sent as indicated - no spaces are supplied 102between the command and its arguments, or between its arguments, and 103.Ql \en 104indicates that a newline should be supplied: 105.Bl -tag -width Ds 106.Sm off 107.It Xo Ic \&O Ar device 108.No \en Ar mode No \en 109.Xc 110.Sm on 111Open the specified 112.Ar device 113using the indicated 114.Ar mode . 115.Ar device 116is a full pathname and 117.Ar mode 118is an ASCII representation of a decimal 119number suitable for passing to 120.Xr open 2 . 121If a device had already been opened, it is 122closed before a new open is performed. 123.It Ic C Ns Ar device Ns \en 124Close the currently open device. 125The 126.Ar device 127specified is ignored. 128.Sm off 129.It Xo Ic L 130.Ar offset No \en 131.Ar whence No \en 132.Xc 133.Sm on 134Perform an 135.Xr lseek 2 136operation using the specified parameters. 137The response value is that returned from the 138.Xr lseek 2 139call. 140.It Ic W Ns Ar count Ns \en 141Write data onto the open device. 142.Nm 143reads 144.Ar count 145bytes from the connection, aborting if 146a premature end-of-file is encountered. 147The response value is that returned from 148the 149.Xr write 2 150call. 151.It Ic R Ns Ar count Ns \en 152Read 153.Ar count 154bytes of data from the open device. 155If 156.Ar count 157exceeds the size of the data buffer (10 kilobytes), it is 158truncated to the data buffer size. 159.Nm 160then performs the requested 161.Xr read 2 162and responds with 163.Sy A Ns Ar count-read Ns \en 164if the read was 165successful; otherwise an error in the 166standard format is returned. 167If the read was successful, the data read is then sent. 168.Sm off 169.It Xo Ic I Ar operation 170.No \en Ar count No \en 171.Xc 172.Sm on 173Perform an 174.Dv MTIOCOP 175.Xr ioctl 2 176command using the specified parameters. 177The parameters are interpreted as the 178ASCII representations of the decimal values 179to place in the 180.Ar mt_op 181and 182.Ar mt_count 183fields of the structure used in the 184.Xr ioctl 2 185call. 186The return value is the 187.Ar count 188parameter when the operation is successful. 189.It Ic S 190Return the status of the open device, as 191obtained with a 192.Dv MTIOCGET 193.Xr ioctl 2 194call. 195If the operation was successful, an 196.Dq ack 197is sent with the size of the status buffer, then the status buffer is 198sent (in binary). 199.El 200.Pp 201Any other command causes 202.Nm 203to exit. 204.Sh DIAGNOSTICS 205All responses are of the form described above. 206.Sh SEE ALSO 207.Xr rcmd 3 , 208.Xr rcmdsh 3 , 209.Xr mtio 4 , 210.Xr rdump 8 , 211.Xr rrestore 8 212.Sh HISTORY 213The 214.Nm 215command appeared in 216.Bx 4.2 . 217.Sh BUGS 218People tempted to use this for a remote file access protocol 219are discouraged. 220