RMTOPEN(3L)

πŸ“¦
version 2022.10.16 Β· 2 versions
, in opensuse-leap 16.0

🌸 RMTOPEN(3L) β€” Schily's LIBRARY FUNCTIONS 🌸

okay bestie, gather round, because this is the manual page for RMTOPEN(3L) from Schily's LIBRARY FUNCTIONS and it's literally all about talking to a remote tape server over the -lrmt life. no cap, this is the group chat for rmtopen, rmtclose, rmtread, rmtwrite, rmtseek, and rmtioctl. let's get into it πŸ’…


✨ NAME ✨

rmtopen, rmtclose, rmtread, rmtwrite, rmtseek, rmtioctl β€” operate on a connection to a remote tape server (-lrmt) πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <schily/librmt.h>
#include <schily/rmtio.h>

int rmtopen(int remfd, char *pathname, int fmode);

int rmtclose(int remfd);

int rmtread(int remfd, char *buf, int count);

int rmtwrite(int remfd, char *buf, int count);

int rmtseek(int remfd, off_t offset, int whence);

int rmtioctl(int remfd, int cmd, int count);

πŸ’– DESCRIPTION πŸ’–

rmtopen()

sends an open request to the remote server. remfd is a file descriptor you previously got from a call to rmtgetconn(3), pathname is a path to be opened on the server side, and fmode is the same as the third argument for open(2). 🫢

if the remote server does not support the GNU open flag enhancements, only the lowest two bits in the open flags can be sent to the remote server. (yes, only two bits, tragic but true.)

if the open request succeeds, rmtopen(3) takes care of telling the remote side to switch to RMT protocol VERSION 1. slay.

rmtclose()

sends a close request to the remote server. remfd is a file descriptor previously obtained from a call to rmtgetconn(3). bye bestie πŸ‘‹

rmtread()

sends a read request to the remote server. remfd is a file descriptor previously obtained from a call to rmtgetconn(3). the other parameters are the same as for a local read(2) call. rmtread(3) will fail if there was no previous successful rmtopen(3) before. so like, open first, read second. main character energy requires setup. 😭

rmtwrite()

sends a write request to the remote server. remfd is a file descriptor previously obtained from a call to rmtgetconn(3). the other parameters are the same as for a local write(2) call. rmtwrite(3) will fail if there was no previous successful rmtopen(3) before. same vibe, write responsibly. ✨

rmtseek()

sends a seek request to the remote server. remfd is a file descriptor previously obtained from a call to rmtgetconn(3). the other parameters are the same as for a local lseek(2) call. rmtseek(3) will fail if there was no previous successful rmtopen(3) before. no open, no seek, no exceptions. πŸ’€

rmtioctl()

sends a MTIOCTOP request to the remote server. cmd and count are the values that should be filled into struct mtop. see mtio(4) for more information. iconic ioctl behavior, honestly. πŸŽ€


🌈 RETURN VALUES 🌈

rmtopen()

returns a value >= 0 if the remote open succeeds. 🟒

rmtclose()

returns a value >= 0 if the remote close succeeds. 🟒

rmtread()

returns the return value obtained the remote read(2) request.

rmtwrite()

returns the return value obtained by the remote write(2) request.

rmtseek()

returns the return value obtained by the remote lseek(2) request.

rmtioctl()

returns the return value obtained by the remote ioctl(f, MTIOCTOP, struct mtop *) call.


πŸ’€ ERRORS πŸ’€

all functions return -1 on error and set errno to the errno value retrieved from the remote server. periodt. if you see -1, check errno like your life depends on it.


πŸ“ EXAMPLES πŸ“

       int  remfd;
       char *remfn;
       char host[256];
       int  iosize = 10240;     /* socket send/receive size to set up */

       if ((remfn = rmtfilename(filename)) != NULL) {
            rmthostname(host, sizeof (host), filename);

            if ((remfd = rmtgetconn(host, iosize, 0)) < 0)
                 comerrno(EX_BAD, "Cannot get connection to '%s'.\n",
                      /* errno not valid !! */      host);
       }

       if (rmtopen(remfd, remfn, mode) < 0)
            comerr("Cannot open '%s'.\n", remfn);

       if (rmtread(remfd, buf, sizeof(buf)) < 0)
            comerr("Read error on '%s'.\n", remfn);

       rmtclose(remfd);

πŸ”₯ SEE ALSO πŸ”₯


🌸 NOTES 🌸

while all other known rmt implementations limit the size of a single rmt command to 64 bytes, this implementation limits all standard command lines to 80 bytes and the file name to 4096 bytes. we love a generous queen. πŸ‘‘

note that this may cause problems if the remote rmt server implementation is directly derived from the historic BSD server code. this is true for all BSD systems, for SunOS up to 5.9 and even for the GNU rmt server. so like, be aware. 🫠

as some of the other rmt servers do not even implement bound checking, be prepared that other server implementations may dump core or at least stop honoring the rmt protocol. not me warning you about core dumps in a cute way but here we are. πŸ’€

if you like to use long file names, make sure that you also use the schily rmt server. that's the vibe check. βœ…


πŸ› BUGS πŸ›

if local and remote errno values do not match, programs may get confused. honestly same.

mail other bugs and suggestions to schilytools@mlists.in-berlin.de or open a ticket at https://codeberg.org/schilytools/schilytools/issues.

the mailing list archive may be found at:

https://mlists.in-berlin.de/mailman/listinfo/schilytools-mlists.in-berlin.de.


πŸ‘‘ AUTHOR πŸ‘‘

librmt has been written in 1990 by Joerg Schilling. in 1995, support for RMT VERSION 1 has been added. librmt is now maintained by the schilytools project authors. legends only. πŸ’œ


🧚 SOURCE DOWNLOAD 🧚

the source code for librmt is included in the schilytools project and may be retrieved from the schilytools project at Codeberg at

https://codeberg.org/schilytools/schilytools.

the download directory is

https://codeberg.org/schilytools/schilytools/releases.


big kisses, this page was brought to you by Joerg Schilling on 2022/10/06 β€” it's RMTOPEN(3L) and it ate. πŸ’…βœ¨πŸŽ€

πŸ“¦ where this page comes from