/* * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2002-2022 CERN * @license This program is free software, distributed under the terms of the GNU General Public * Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". You can * redistribute it and/or modify it under the terms of the GPL Version 3, or (at your * option) any later version. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * PARTICULAR PURPOSE. See the GNU General Public License for more details. * * In applying this licence, CERN does not waive the privileges and immunities * granted to it by virtue of its status as an Intergovernmental Organization or * submit itself to any jurisdiction. */ /* rmc_dismount - dismount a cartridge from a drive */ #include #include #include #include #include "marshall.h" #include "rmc_api.h" #include "rmc_constants.h" #include "serrno.h" int rmc_dismount( const char *const server, const char *const vid, const int drvord, const int force) { int c; gid_t gid; int msglen; char *q; char repbuf[1]; char *sbp; char sendbuf[RMC_REQBUFSZ]; uid_t uid; uid = getuid(); gid = getgid(); /* Build request header */ sbp = sendbuf; marshall_LONG (sbp, RMC_MAGIC); marshall_LONG (sbp, RMC_UNMOUNT); q = sbp; /* save pointer. The next field will be updated */ msglen = 3 * LONGSIZE; marshall_LONG (sbp, msglen); /* Build request body */ marshall_LONG (sbp, uid); marshall_LONG (sbp, gid); marshall_STRING (sbp, ""); /* loader field is no longer used */ marshall_STRING (sbp, vid); marshall_WORD (sbp, drvord); marshall_WORD (sbp, force); msglen = sbp - sendbuf; marshall_LONG (q, msglen); /* update length field */ while ((c = send2rmc (server, sendbuf, msglen, repbuf, sizeof(repbuf))) && serrno == ERMCNACT) sleep (RMC_RETRYI); return (c); }