RMTOPEN(3L)
πΈ RMTOPEN(3L) β the remote tape squad π
Hey bestie, so this whole page is from Schily's LIBRARY FUNCTIONS (section 3L of the manual, iykyk) and it's literally all about rmtopen, rmtclose, rmtread, rmtwrite, rmtseek and rmtioctl β the six icons that let you operate on a connection to a remote tape server (that's the -lrmt thing π). Group-chat energy only, but every single flag stays, fr fr.
β¨ NAME β¨
rmtopen, rmtclose, rmtread, rmtwrite, rmtseek, rmtioctl β operate on a connection to a remote tape server (-lrmt) π¦
π SYNOPSIS π
okay so first you gotta include the headers, no skipping bestie:
#include <schily/librmt.h>
#include <schily/rmtio.h>
then the whole squad, signatures exactly as they are:
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 already got from a call to rmtgetconn(3) (don't just make one up π), pathname is the path to be opened on the server side, and fmode is literally the same as the third argument for open(2).
β οΈ heads up: if the remote server does not support the GNU open flag enhancements, only the lowest two bits in the open flags can be send to the remote server. That's the rule, no cap.
and if the open request succeeds, rmtopen(3) takes care of telling the remote side to switch to RMT protocol VERSION 1 β main character behaviour honestly π
π¦ rmtclose()
sends a close request to the remote server. remfd is a file descriptor previously obtained from a call to rmtgetconn(3). Say 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. And listen β rmtread(3) will fail if there was no previous successful rmtopen(3) before. Order matters, periodt.
π 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. Same deal: rmtwrite(3) will fail if there was no previous successful rmtopen(3) before. No skipping steps π
β 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. And yep β rmtseek(3) will fail if there was no previous successful rmtopen(3) before. It's giving consistency β¨
π§ rmtioctl()
sends a MTIOCTOP request to the remote server. cmd and count are the values that should be filled into struct mtop. Peep mtio(4) for more information π
π RETURN VALUES π
rmtopen()β returns a value>= 0if the remote open succeeds πrmtclose()β returns a value>= 0if the remote close succeeds π«Άrmtread()β returns the return value obtained the remoteread(2)request (yes, that's the original wording, she stays πΈ)rmtwrite()β returns the return value obtained by the remotewrite(2)requestrmtseek()β returns the return value obtained by the remotelseek(2)requestrmtioctl()β returns the return value obtained by the remoteioctl(f, MTIOCTOP, struct mtop *)call
π ERRORS π
All functions return -1 on error and set errno to the errno value retrieved from the remote server. So when it goes wrong, it goes wrong remotely, and that's the vibe π
π₯ EXAMPLES π₯
okay bestie here's the actual code, copied exactly, do not touch it:
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 how she gets the connection, opens, reads, then closes? chef's kiss π©βπ³π
π SEE ALSO π
rmt(1), rsh(1), ssh(1), rcmd(3), rmtinit(3), rmtdebug(3), rmtrmt(3), rmtrsh(3), rmthostname(3), rmtfilename(3), rmtgetconn(3), rmtopen(3), rmtioctl(3), rmtclose(3), rmtread(3), rmtwrite(3), rmtseek(3), rmtxstatus(3), rmtstatus(3), _mtg2rmtg(3), _rmtg2mtg(3), errmsgno(3), mtio(4)
(yes, the page links to itself, she's confident like that π )
π NOTES π
okay so here's the tea β β 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. Iconic, but read the next bit.
β οΈ 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. π
And 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. Like, genuinely be prepared π
If you like to use long file names, make sure that you also use the schily rmt server. No substitutions, bestie π
π BUGS π
If local and remote errno values do not match, programs may get confused. Honestly relatable but still a bug π
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. we stan a long-running legacy β¨
π 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.
π«Ά that's the whole page bestie, go forth and tape remotely.
Joerg Schilling Β· 2022/10/06 Β· RMTOPEN(3L) β mwah, see u in the next manpage ππ
π¦ where this page comes from
- opensuse-leap 16.0: librmt-devel-doc 2022.10.16-160000.2.2 Β· CDDL-1.0
- Copyright 2002 J. Schilling
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms