RMTSTATUS(3L)
π RMTSTATUS β Schily's LIBRARY FUNCTIONS edition (section 3L, bestie)
Okay so today we're learning about rmtstatus, rmtxstatus, _mtg2rmtg and _rmtg2mtg β the little squad that requests MTIOCGET on a connection to a remote tape server (-lrmt). Yes that's a lot of consonants. Breathe. We got this. π
β¨ NAME β¨
rmtstatus, rmtxstatus, _mtg2rmtg, _rmtg2mtg β they request MTIOCGET on a connection to a remote tape server (-lrmt). That's the whole vibe of this page, bestie. π¦
β¨ SYNOPSIS β¨
#include <schily/librmt.h>
#include <schily/rmtio.h>
int rmtstatus(int remfd, struct mtget *mtp);
int rmtxstatus(int remfd, struct rmtget *mtp);
void _rmtg2mtg(struct mtget *mtp, struct rmtget *rmtp);
int _mtg2rmtg(struct rmtget *rmtp, struct mtget *mtp);
πΈ DESCRIPTION πΈ
π rmtstatus() and rmtxstatus()
So these two literally perform an MTIOCGET request to the remote server. Let me break it down:
remfdis a file descriptor you got earlier from a call tormtgetconn(3)β like, you can't just show up with a random fd, there's a whole process πstruct mtgetis the local magnetic tape status structurestruct rmtgetis the enhanced magnetic tape status structure from librmt
Big important note: rmtstatus(3) and rmtxstatus(3) will fail if there was no previous successful rmtopen(3) before. No skipping steps, bestie, it's giving "you must do the reading first."
They also take care of using RMT protocol VERSION 1 if the remote side implements support for protocol version 1. Adaptive queen behavior. β¨
β οΈ Now the tea:rmtstatus(3)is outdated and should be avoided, because the results instruct mtgetwill be the least common denominator of the local and remote variants of the structure. Like, it'll work but it's giving compromise. Usermtxstatus(3)instead. Please. π
The member mt_xflags in struct rmtget contains a bitmap that indicates which members of the structure contain valid values. See mtio(4) for more info β that's where the lore lives.
π _rmtg2mtg()
Converts a struct rmtget into a struct mtget. Glow-down. Simple, iconic.
π _mtg2rmtg()
Converts a struct mtget into a struct rmtget, and sets the member mt_xflags in struct rmtget to contain a bitmap that indicates which members of struct mtget are present in the local implementation. Glow-up with receipts. π
β RETURN VALUES β
π rmtstatus() and rmtxstatus()
They return a value >= 0 if the remote ioctl(f, MTIOCGET, struct mtget *) succeeds. That's the win condition, no cap.
π ERRORS π
π«Ά rmtstatus() and rmtxstatus()
They return -1 on error and set errno to the errno value retrieved from the remote server. So the error came from across the network. Long distance heartbreak. π
π«Ά _mtg2rmtg()
Returns -1 if no value from the local struct mtget could be converted to the abstract struct rmtget.
π₯ EXAMPLES π₯
Actual code, look at it, it's beautiful:
int remfd;
char *remfn;
char host[256];
int iosize = 10240; /* socket send/receive size to set up */
struct rmtget rmtg;
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 (rmtxstatus(remfd, &rmtg) < 0)
comerr("Cannot retrieve magnetic tape status from '%s'.\n", remfn);
rmtclose(remfd);
Note the /* errno not valid !! */ comment up in there β that's not decoration, bestie, that's a whole mood. π
π¦ 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)
The whole friend group. Go read them too. π
π BUGS π
π¨ If local and remote errno values do not match, programs may get confused. Yes, confused. Same. Relatable honestly.
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.
π§ AUTHORS π§
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. A legacy. A moment in history. We stan. π
π 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.
β¨ and that's the page, bestie β¨ β written by Joerg Schilling, dated 2022/10/06, from RMTSTATUS(3L), Schily's LIBRARY FUNCTIONS. You're welcome, go read your tape status. πππ¦
π¦ 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