diff --git a/mediachanger/Constants.hpp b/mediachanger/Constants.hpp index e9b10397aee1e44394837c7fa86b8c1f85e8b80a..6932ba54afb2f282c968d4bedf7000ba2ecab38d 100644 --- a/mediachanger/Constants.hpp +++ b/mediachanger/Constants.hpp @@ -48,19 +48,22 @@ enum MediaChangerReplyType { * RMC (Remote SCSI media changer server) errors *------------------------------------------------------------------------ */ -#define ERMBASEOFF 2200 /* RMC error base offset */ -#define ERMCNACT ERMBASEOFF+1 /* Remote SCSI media changer server not active or service being drained */ -#define ERMCRBTERR (ERMBASEOFF+2) /* Remote SCSI media changer error */ -#define ERMCUNREC ERMCRBTERR+1 /* Remote SCSI media changer unrec. error */ -#define ERMCSLOWR ERMCRBTERR+2 /* Remote SCSI media changer error (slow retry) */ -#define ERMCFASTR ERMCRBTERR+3 /* Remote SCSI media changer error (fast retry) */ -#define ERMCDFORCE ERMCRBTERR+4 /* Remote SCSI media changer error (demount force) */ -#define ERMCDDOWN ERMCRBTERR+5 /* Remote SCSI media changer error (drive down) */ -#define ERMCOMSGN ERMCRBTERR+6 /* Remote SCSI media changer error (ops message) */ -#define ERMCOMSGS ERMCRBTERR+7 /* Remote SCSI media changer error (ops message + retry) */ -#define ERMCOMSGR ERMCRBTERR+8 /* Remote SCSI media changer error (ops message + wait) */ -#define ERMCUNLOAD ERMCRBTERR+9 /* Remote SCSI media changer error (unload + demount) */ -#define ERMMAXERR ERMBASEOFF+11 +constexpr int ERMBASEOFF = 2200; // RMC error base offset + +enum MediaChangerErrorCode { + ERMCNACT = ERMBASEOFF+1, // Remote SCSI media changer server not active or service being drained + ERMCRBTERR = ERMBASEOFF+2, // Remote SCSI media changer error + ERMCUNREC = ERMCRBTERR+1, // Remote SCSI media changer unrecoverable error + ERMCSLOWR = ERMCRBTERR+2, // Remote SCSI media changer error (slow retry) + ERMCFASTR = ERMCRBTERR+3, // Remote SCSI media changer error (fast retry) + ERMCDFORCE = ERMCRBTERR+4, // Remote SCSI media changer error (demount force) + ERMCDDOWN = ERMCRBTERR+5, // Remote SCSI media changer error (drive down) + ERMCOMSGN = ERMCRBTERR+6, // Remote SCSI media changer error (ops message) + ERMCOMSGS = ERMCRBTERR+7, // Remote SCSI media changer error (ops message + retry) + ERMCOMSGR = ERMCRBTERR+8, // Remote SCSI media changer error (ops message + wait) + ERMCUNLOAD = ERMCRBTERR+9, // Remote SCSI media changer error (unload + demount) + ERMMAXERR = ERMBASEOFF+11 +}; /** * The default TCP/IP port on which the CASTOR rmcd daemon listens for incoming diff --git a/mediachanger/librmc/Castor_limits.hpp b/mediachanger/librmc/Castor_limits.hpp deleted file mode 100644 index d3d1e0d60a6e97057552565a9c261487a3028359..0000000000000000000000000000000000000000 --- a/mediachanger/librmc/Castor_limits.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * @project The CERN Tape Archive (CTA) - * @copyright Copyright © 1999-2025 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. - */ - -#pragma once - -// maximum lengths defined below do not include the trailing null - -#define CA_MAXACLENTRIES 300 //!< maximum number of ACL entries for a file/dir -#define CA_MAXCLASNAMELEN 15 //!< maximum length for a fileclass name -#define CA_MAXCOMMENTLEN 255 //!< maximum length for user comments in metadata -#define CA_MAXDENLEN 8 //!< maximum length for a alphanumeric density -#define CA_MAXDGNLEN 6 //!< maximum length for a device group name -#define CA_MAXDVNLEN 63 //!< maximum length for a device name -#define CA_MAXDVTLEN 8 //!< maximum length for a device type -#define CA_MAXFIDLEN 17 //!< maximum length for a fid (DSN) -#define CA_MAXFSEQLEN 14 //!< maximum length for a fseq string -#define CA_MAXGRPNAMELEN 2 //!< maximum length for a group name -#define CA_MAXGUIDLEN 36 //!< maximum length for a guid -#define CA_MAXHOSTNAMELEN 63 //!< maximum length for a hostname -#define CA_MAXSVCCLASSNAMELEN 63 //!< maximum length for a svc class name -#define CA_MAXLBLTYPLEN 3 //!< maximum length for a label type -#define CA_MAXLINELEN 1023 //!< maximum length for a line in a log -#define CA_MAXMANUFLEN 12 //!< maximum length for a cartridge manufacturer -#define CA_MAXMIGPNAMELEN 15 //!< maximum length for a migration policy name -#define CA_MAXMIGRNAMELEN 15 //!< maximum length for a migrator name -#define CA_MAXMLLEN 1 //!< maximum length for a cartridge media_letter -#define CA_MAXMODELLEN 6 //!< maximum length for a cartridge model -#define CA_MAXNAMELEN 255 //!< maximum length for a pathname component -#define CA_MAXNBDRIVES 4 //!< maximum number of tape drives per server -#define CA_MAXPATHLEN 1023 //!< maximum length for a pathname -#define CA_MAXPOOLNAMELEN 15 //!< maximum length for a pool name -#define CA_MAXPROTOLEN 7 //!< maximum length for a protocol name -#define CA_MAXRBTNAMELEN 17 //!< maximum length for a robot name -#define CA_MAXRECFMLEN 3 //!< maximum length for a record format -#define CA_MAXREGEXPLEN 63 //!< Maximum length for a regular expression -#define CA_MAXCSECNAMELEN 512 //!< Maximum length for a Csec authorization id -#define CA_MAXCSECPROTOLEN 20 //!< Maximum length for a Csec mechanism -#define CA_MAXSFNLEN 1103 //!< maximum length for a replica -#define CA_MAXSHORTHOSTLEN 10 //!< maximum length for a hostname without domain -#define CA_MAXSNLEN 24 //!< maximum length for a cartridge serial nb -// CA_MAXSTGRIDLEN must be >= nb digits in CA_MAXSTGREQID + CA_MAXHOSTNAMELEN + 8 -#define CA_MAXSTGRIDLEN 77 //!< maximum length for a stager full request id -#define CA_MAXSTGREQID 999999 //!< maximum value for a stager request id -#define CA_MAXSYMLINKS 5 //!< maximum number of symbolic links -#define CA_MAXTAGLEN 255 //!< maximum length for a volume tag -#define CA_MAXTAPELIBLEN 8 //!< maximum length for a tape library name -#define CA_MAXUNMLEN 8 //!< maximum length for a drive name -#define CA_MAXUSRNAMELEN 14 //!< maximum length for a login name -#define CA_MAXVIDLEN 6 //!< maximum length for a VID -#define CA_MAXVSNLEN 6 //!< maximum length for a VSN -#define CA_MAXCKSUMNAMELEN 15 //!< maximum length for a checksum algorithm name -#define CA_MAXCKSUMLEN 32 //!< maximum length for a checksum value in an asci form -#define CA_MAXDMPROTNAMELEN 15 //!< maximum length for Disk Mover protocol name -#define CA_MAXJOBIDLEN 36 //!< Maximum length for the representation of the Cuuid -#define CA_MAXUSERTAGLEN 63 //!< Maximum length for a user tag (stage request) -#define CA_MAXRFSLINELEN 2047 //!< maximum length for the requested filesystem string - -#define CA_MAXUID 0x7FFFFFFF //!< Maximum uid -#define CA_MAXGID 0x7FFFFFFF //!< Maximum gid diff --git a/mediachanger/librmc/Cdomainname.cpp b/mediachanger/librmc/Cdomainname.cpp index f26b6b50758b1e358b2a390acdd8e28799528d3c..2fbcbfeb90e748466971b1007242dc36e31fcba2 100644 --- a/mediachanger/librmc/Cdomainname.cpp +++ b/mediachanger/librmc/Cdomainname.cpp @@ -1,4 +1,4 @@ -/* +/** * @project The CERN Tape Archive (CTA) * @copyright Copyright © 2002-2025 CERN * @license This program is free software, distributed under the terms of the GNU General Public @@ -24,13 +24,10 @@ #include #include #include -#include "Castor_limits.hpp" #include "Cnetdb.hpp" #include "serrno.hpp" #include "Cdomainname.hpp" -/* Cdomainname - get domain name */ - int Cdomainname(char* name, int namelen) { char hostname[CA_MAXHOSTNAMELEN + 1]; struct hostent* hp; diff --git a/mediachanger/librmc/Cdomainname.hpp b/mediachanger/librmc/Cdomainname.hpp index 30b825d84f111a7824244bfb1a79415ab51126e4..e409e4f2f1997eb0db55e05f4d0124695d1d449c 100644 --- a/mediachanger/librmc/Cdomainname.hpp +++ b/mediachanger/librmc/Cdomainname.hpp @@ -17,4 +17,7 @@ #pragma once -int Cdomainname(char*, int); +/** + * Get domain name + */ +int Cdomainname(char* name, int namelen); diff --git a/mediachanger/librmc/Cinitdaemon.cpp b/mediachanger/librmc/Cinitdaemon.cpp index ff045450b00dc3f14af0c4d7414038448e65e2e7..f78556ea98feb516d008485f87cbd809f0b5ecaf 100644 --- a/mediachanger/librmc/Cinitdaemon.cpp +++ b/mediachanger/librmc/Cinitdaemon.cpp @@ -25,7 +25,6 @@ #include #include #include -#include "osdep.hpp" #include "serrno.hpp" int Cinitdaemon(const char* const name, void (*const wait4child)(int)) { diff --git a/mediachanger/librmc/Cnetdb.hpp b/mediachanger/librmc/Cnetdb.hpp index a85d308891f6b89aa49a3660aa9941b03650a76c..ee71a3aca0bd0ac382ce8b4395bc7abfded8ccf1 100644 --- a/mediachanger/librmc/Cnetdb.hpp +++ b/mediachanger/librmc/Cnetdb.hpp @@ -17,9 +17,11 @@ #pragma once -#include "osdep.hpp" #include +//! Maximum length for a hostname +constexpr int CA_MAXHOSTNAMELEN = 63; + struct hostent* Cgethostbyname(const char*); struct hostent* Cgethostbyaddr(const void*, size_t, int); struct servent* Cgetservbyname(const char*, const char*); diff --git a/mediachanger/librmc/getconfent.cpp b/mediachanger/librmc/getconfent.cpp index 6a5490f4b90507f79bf8a8f3ac38ef1c544f5815..7c92b305276394e2d775eb0cc54458a7689542c3 100644 --- a/mediachanger/librmc/getconfent.cpp +++ b/mediachanger/librmc/getconfent.cpp @@ -20,37 +20,17 @@ #include #include "Cglobals.hpp" #include "serrno.hpp" -#include "Castor_limits.hpp" #include "getconfent.hpp" -#ifndef PATH_CONFIG -#define PATH_CONFIG "/etc/castor/castor.conf" -#endif /* PATH_CONFIG */ - #define strtok(X, Y) strtok_r(X, Y, &last) -static char* getconfent_r(const char*, const char*, const char*, int, char*, int); - static char* -getconfent_r(const char* filename, const char* category, const char* name, int flags, char* buffer, int bufsiz) { +getconfent_r(const char* category, const char* name, int flags, char* buffer, int bufsiz) { FILE* fp; char *p, *cp; int found = 0; - char path_config[CA_MAXPATHLEN + 1]; char* last = nullptr; - - if (filename == nullptr) { - /* Use default config file is not in the parameters */ - filename = PATH_CONFIG; - /* But give precedence to $PATH_CONFIG environment variable */ - if ((p = getenv("PATH_CONFIG")) != nullptr) { - filename = p; - } - } - - strncpy(path_config, filename, CA_MAXPATHLEN + 1); - /* Who knows */ - path_config[CA_MAXPATHLEN] = '\0'; + constexpr char const* path_config = "/etc/cta/cta-rmcd.conf"; if ((fp = fopen(path_config, "r")) == nullptr) { serrno = SENOCONFIG; @@ -110,18 +90,7 @@ getconfent_r(const char* filename, const char* category, const char* name, int f static int value_key = -1; -char* getconfent(const char* category, const char* name, int flags) { - char* value = nullptr; - - Cglobals_get(&value_key, (void**) &value, BUFSIZ + 1); - if (value == nullptr) { - return nullptr; - } - - return getconfent_r(nullptr, category, name, flags, value, BUFSIZ + 1); -} - -char* getconfent_fromfile(const char* filename, const char* category, const char* name, int flags) { +char* getconfent_fromfile(const char* category, const char* name, int flags) { char* value = nullptr; Cglobals_get(&value_key, (void**) &value, BUFSIZ + 1); @@ -129,5 +98,5 @@ char* getconfent_fromfile(const char* filename, const char* category, const char return nullptr; } - return getconfent_r(filename, category, name, flags, value, BUFSIZ + 1); + return getconfent_r(category, name, flags, value, BUFSIZ + 1); } diff --git a/mediachanger/librmc/getconfent.hpp b/mediachanger/librmc/getconfent.hpp index 0866ae3768ba2065fb9aa8b428bcdb08adbec368..fe98634f12e29cf918859f468503005f56c985f7 100644 --- a/mediachanger/librmc/getconfent.hpp +++ b/mediachanger/librmc/getconfent.hpp @@ -17,5 +17,4 @@ #pragma once -char* getconfent(const char*, const char*, int); -char* getconfent_fromfile(const char*, const char*, const char*, int); +char* getconfent_fromfile(const char* category, const char* name, int flags); diff --git a/mediachanger/librmc/marshall.hpp b/mediachanger/librmc/marshall.hpp index 80110b29fa260275fa2345e69ec631902f9d7760..68fe780b1dabe547c08cfc1c05309992c9505f4a 100644 --- a/mediachanger/librmc/marshall.hpp +++ b/mediachanger/librmc/marshall.hpp @@ -19,23 +19,30 @@ #include #include -#include "osdep.hpp" - -#define SHORT WORD -#define SHORTSIZE WORDSIZE -#define SHORTADDR WORDADDR - -#define marshall_WORD marshall_SHORT -#define unmarshall_WORD unmarshall_SHORT +enum DataRepresentation { + BYTESIZE = 1, + SHORTSIZE = 2, + LONGSIZE = 4, + QUADSIZE = 8, + HYPERSIZE = 8, + TIME_TSIZE = HYPERSIZE +}; + +using BYTE = char; +using SHORT = short; +using LONG = int; + +#define BYTEADDR(x) (((char*) &(x)) + sizeof(BYTE) - BYTESIZE) +#define SHORTADDR(x) (((char*) &(x)) + sizeof(SHORT) - SHORTSIZE) +#define LONGADDR(x) (((char*) &(x)) + sizeof(LONG) - LONGSIZE) #define INC_PTR(ptr, n) (ptr) = (char*) (ptr) + (n) -#define DIFF_PTR(ptr, base) (char*) (ptr) - (char*) (base) /* * BIT manipulation */ -#define BITSOFBYTE 8 //!< number of bits in a byte +constexpr int BITSOFBYTE = 8; //!< number of bits in a byte #define bitsof(t) sizeof(t) * BITSOFBYTE //!< number of bits in a type diff --git a/mediachanger/librmc/osdep.hpp b/mediachanger/librmc/osdep.hpp deleted file mode 100644 index 56cdb202c18204d7824829124df09d9517c7d5ad..0000000000000000000000000000000000000000 --- a/mediachanger/librmc/osdep.hpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * @project The CERN Tape Archive (CTA) - * @copyright Copyright © 1990-2025 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. - */ - -// Operating system dependencies - -#pragma once - -/* - * Data representation - */ - -#define BYTESIZE 1 -#define WORDSIZE 2 -#define LONGSIZE 4 -#define QUADSIZE 8 -#define HYPERSIZE 8 -#define TIME_TSIZE HYPERSIZE - -using U_BYTE = unsigned char; -using U_SHORT = unsigned short; -using U_LONG = unsigned int; -using BYTE = char; -using WORD = short; -using LONG = int; - -#define BYTEADDR(x) (((char*) &(x)) + sizeof(BYTE) - BYTESIZE) -#define WORDADDR(x) (((char*) &(x)) + sizeof(WORD) - WORDSIZE) -#define LONGADDR(x) (((char*) &(x)) + sizeof(LONG) - LONGSIZE) - -using signed64 = long long; -using u_signed64 = unsigned long long; - -using HYPER = signed64; -using U_HYPER = u_signed64; -using TIME_T = U_HYPER; - -#define ONE_KIB 0x400 -#define ONE_MIB 0x100000 -#define ONE_GIB 0x40000000 -#define ONE_TIB 0x10000000000LL -#define ONE_PIB 0x4000000000000LL -#define ONE_HIB 0x1000000000000000LL - -#define ONE_KB 1000 -#define ONE_MB 1000000 -#define ONE_GB 1000000000 -#define ONE_TB 1000000000000LL -#define ONE_PB 1000000000000000LL -#define ONE_HB 1000000000000000000LL - -/* - * Error reporting - */ - -#define NETERROR perror -#define OSERROR perror diff --git a/mediachanger/librmc/serrno.hpp b/mediachanger/librmc/serrno.hpp index 5239dd05b0a538632e57b3f64f810bb697e7ac2b..42e2ef097425d576a1e6576c2d910a716c9143eb 100644 --- a/mediachanger/librmc/serrno.hpp +++ b/mediachanger/librmc/serrno.hpp @@ -17,461 +17,84 @@ #pragma once -#include //!< For size_t -#include //!< For size_t on _WIN32 +#include + +constexpr int SEBASEOFF = 1000; //!< Base offset for special err + +enum Serrno { + SENOERR = SEBASEOFF, //!< No error + SENOSHOST = SEBASEOFF + 1, //!< Host not known + SENOSSERV = SEBASEOFF + 2, //!< Service unknown + SENOTRFILE = SEBASEOFF + 3, //!< Not a remote file + SETIMEDOUT = SEBASEOFF + 4, //!< Has timed out + SEBADFFORM = SEBASEOFF + 5, //!< Bad fortran format specifier + SEBADFOPT = SEBASEOFF + 6, //!< Bad fortran option specifier + SEINCFOPT = SEBASEOFF + 7, //!< Incompatible fortran options + SENAMETOOLONG = SEBASEOFF + 8, //!< File name too long + SENOCONFIG = SEBASEOFF + 9, //!< Can't open configuration file + SEBADVERSION = SEBASEOFF + 10, //!< Version ID mismatch + SEUBUF2SMALL = SEBASEOFF + 11, //!< User buffer too small + SEMSGINVRNO = SEBASEOFF + 12, //!< Invalid reply number + SEUMSG2LONG = SEBASEOFF + 13, //!< User message too long + SEENTRYNFND = SEBASEOFF + 14, //!< Entry not found + SEINTERNAL = SEBASEOFF + 15, //!< Internal error + SECONNDROP = SEBASEOFF + 16, //!< Connection closed by rem. end + SEBADIFNAM = SEBASEOFF + 17, //!< Can't get interface name + SECOMERR = SEBASEOFF + 18, //!< Communication error + SENOMAPDB = SEBASEOFF + 19, //!< Can't open mapping database + SENOMAPFND = SEBASEOFF + 20, //!< No user mapping + SERTYEXHAUST = SEBASEOFF + 21, //!< Retry count exhausted + SEOPNOTSUP = SEBASEOFF + 22, //!< Operation not supported + SEWOULDBLOCK = SEBASEOFF + 23, //!< Resource temporarily unavailable + SEINPROGRESS = SEBASEOFF + 24, //!< Operation now in progress + SECTHREADINIT = SEBASEOFF + 25, //!< Cthread initialization error + SECTHREADERR = SEBASEOFF + 26, //!< Thread interface call error + SESYSERR = SEBASEOFF + 27, //!< System error + SENOTADMIN = SEBASEOFF + 32, //!< requestor is not administrator + SEUSERUNKN = SEBASEOFF + 33, //!< User unknown + SEDUPKEY = SEBASEOFF + 34, //!< Duplicate key value + SEENTRYEXISTS = SEBASEOFF + 35, //!< Entry already exists + SEGROUPUNKN = SEBASEOFF + 36, //!< Group Unknown + SECHECKSUM = SEBASEOFF + 37, //!< Bad checksum + SESVCCLASSNFND = SEBASEOFF + 38, //!< This service class is not available for this host + SESQLERR = SEBASEOFF + 39, //!< Got SQL exception from database + SELOOP = SEBASEOFF + 40, //!< Too many symbolic links + SENOPORTINRANGE = SEBASEOFF + 41, //!< No port in range + SENOVALUE = SEBASEOFF + 42, //!< No value + SEINVALIDCONFIG = SEBASEOFF + 43, //!< Invalid configuration + SEPYTHONEXEC = SEBASEOFF + 44, //!< Failed to execute Python + SEMISSINGOPER = SEBASEOFF + 45, //!< Missing operand + SEMISMATCH = SEBASEOFF + 46, //!< Mismatch + SEREQUESTFAILED = SEBASEOFF + 47, //!< Request failed + SEINVALIDNBARGS = SEBASEOFF + 48, //!< Invalid number of arguments + SEALREADYINIT = SEBASEOFF + 49, //!< Already initialized + SECMDLNNOTPRSD = SEBASEOFF + 50, //!< Command line not parsed + SEACCPTCONNINTR = SEBASEOFF + 51, //!< Accept connection was interrupted + SEBADALLOC = SEBASEOFF + 52, //!< Failed to allocate memory + SENOTANOWNER = SEBASEOFF + 53, //!< Not an owner + SEMAXERR = SEBASEOFF + 53 //!< Maximum error number +}; -#define SEBASEOFF 1000 //!< Base offset for special err -#define EDBBASEOFF 1200 //!< CDB error base offset -#define EMSBASEOFF 1300 //!< MSG error base offset -#define ENSBASEOFF 1400 //!< NS error base offset -#define ERFBASEOFF 1500 //!< RFIO error base offset -#define ERTBASEOFF 1600 //!< RTCOPY error base offset -#define ESTBASEOFF 1700 //!< STAGE error base offset -#define ESQBASEOFF 1800 //!< SYSREQ error base offset -#define ETBASEOFF 1900 //!< TAPE error base offset -#define EVMBASEOFF 2000 //!< VMGR error base offset -#define EVQBASEOFF 2100 //!< VDQM error base offset -#define ERMBASEOFF 2200 //!< RMC error base offset -#define EMONBASEOFF 2300 //!< Monitoring Error base offset -#define EUPBASEOFF 2400 //!< UPV error base offset -#define ESECBASEOFF 2700 //!< Security error base offset -#define EDNSBASEOFF 3000 //!< DNS error base offset -#define SENOERR SEBASEOFF //!< No error -#define SENOSHOST SEBASEOFF + 1 //!< Host not known -#define SENOSSERV SEBASEOFF + 2 //!< Service unknown -#define SENOTRFILE SEBASEOFF + 3 //!< Not a remote file -#define SETIMEDOUT SEBASEOFF + 4 //!< Has timed out -#define SEBADFFORM SEBASEOFF + 5 //!< Bad fortran format specifier -#define SEBADFOPT SEBASEOFF + 6 //!< Bad fortran option specifier -#define SEINCFOPT SEBASEOFF + 7 //!< Incompatible fortran options -#define SENAMETOOLONG SEBASEOFF + 8 //!< File name too long -#define SENOCONFIG SEBASEOFF + 9 //!< Can't open configuration file -#define SEBADVERSION SEBASEOFF + 10 //!< Version ID mismatch -#define SEUBUF2SMALL SEBASEOFF + 11 //!< User buffer too small -#define SEMSGINVRNO SEBASEOFF + 12 //!< Invalid reply number -#define SEUMSG2LONG SEBASEOFF + 13 //!< User message too long -#define SEENTRYNFND SEBASEOFF + 14 //!< Entry not found -#define SEINTERNAL SEBASEOFF + 15 //!< Internal error -#define SECONNDROP SEBASEOFF + 16 //!< Connection closed by rem. end -#define SEBADIFNAM SEBASEOFF + 17 //!< Can't get interface name -#define SECOMERR SEBASEOFF + 18 //!< Communication error -#define SENOMAPDB SEBASEOFF + 19 //!< Can't open mapping database -#define SENOMAPFND SEBASEOFF + 20 //!< No user mapping -#define SERTYEXHAUST SEBASEOFF + 21 //!< Retry count exhausted -#define SEOPNOTSUP SEBASEOFF + 22 //!< Operation not supported -#define SEWOULDBLOCK SEBASEOFF + 23 //!< Resource temporarily unavailable -#define SEINPROGRESS SEBASEOFF + 24 //!< Operation now in progress -#define SECTHREADINIT SEBASEOFF + 25 //!< Cthread initialization error -#define SECTHREADERR SEBASEOFF + 26 //!< Thread interface call error -#define SESYSERR SEBASEOFF + 27 //!< System error -#define SENOTADMIN SEBASEOFF + 32 //!< requestor is not administrator -#define SEUSERUNKN SEBASEOFF + 33 //!< User unknown -#define SEDUPKEY SEBASEOFF + 34 //!< Duplicate key value -#define SEENTRYEXISTS SEBASEOFF + 35 //!< Entry already exists -#define SEGROUPUNKN SEBASEOFF + 36 //!< Group Unknown -#define SECHECKSUM SEBASEOFF + 37 //!< Bad checksum -#define SESVCCLASSNFND SEBASEOFF + 38 //!< This service class is not available for this host -#define SESQLERR SEBASEOFF + 39 //!< Got SQL exception from database -#define SELOOP SEBASEOFF + 40 //!< Too many symbolic links -#define SENOPORTINRANGE SEBASEOFF + 41 //!< No port in range -#define SENOVALUE SEBASEOFF + 42 //!< No value -#define SEINVALIDCONFIG SEBASEOFF + 43 //!< Invalid configuration -#define SEPYTHONEXEC SEBASEOFF + 44 //!< Failed to execute Python -#define SEMISSINGOPER SEBASEOFF + 45 //!< Missing operand -#define SEMISMATCH SEBASEOFF + 46 //!< Mismatch -#define SEREQUESTFAILED SEBASEOFF + 47 //!< Request failed -#define SEINVALIDNBARGS SEBASEOFF + 48 //!< Invalid number of arguments -#define SEALREADYINIT SEBASEOFF + 49 //!< Already initialized -#define SECMDLNNOTPRSD SEBASEOFF + 50 //!< Command line not parsed -#define SEACCPTCONNINTR SEBASEOFF + 51 //!< Accept connection was interrupted -#define SEBADALLOC SEBASEOFF + 52 //!< Failed to allocate memory -#define SENOTANOWNER SEBASEOFF + 53 //!< Not an owner - -#define SEMAXERR SEBASEOFF + 53 //!< Maximum error number - -#define SERRNO (serrno - SEBASEOFF) //!< User convenience -/* - * Backward compatibility - */ -#define SEFNAM2LONG SENAMETOOLONG - -/* - * Package specific error messages (don't forget to update commmon/serror.c) - */ - -/* - *------------------------------------------------------------------------ - * DB errors - *------------------------------------------------------------------------ - */ -#define EDB_A_ESESSION EDBBASEOFF + 1 //!< Cdb api : invalid session -#define EDB_A_EDB EDBBASEOFF + 2 //!< Cdb api : invalid db -#define EDB_A_EINVAL EDBBASEOFF + 3 //!< Cdb api : invalid value -#define EDB_A_RESHOST EDBBASEOFF + 4 //!< Cdb api : host res error -#define EDB_A_TOOMUCH EDBBASEOFF + 5 //!< Cdb api : data size rejected -#define EDB_AS_SOCKET EDBBASEOFF + 6 //!< Cdb api system : socket() error -#define EDB_AS_SOCKOPT EDBBASEOFF + 7 //!< Cdb api system : [set/get]sockopt() error -#define EDB_AS_MALLOC EDBBASEOFF + 8 //!< Cdb api system : malloc() error -#define EDB_A_NOERROR EDBBASEOFF + 9 //!< Cdb api : no last error -#define EDB_A_IEINVAL EDBBASEOFF + 10 //!< Cdb api : interface invalid value -#define EDB_AS_BIND EDBBASEOFF + 11 //!< Cdb api : bind() error -#define EDB_AS_LISTEN EDBBASEOFF + 12 //!< Cdb api : listen() error -#define EDB_AS_GETSOCKNAME EDBBASEOFF + 13 //!< Cdb api : getsockname() error -#define EDB_AS_ACCEPT EDBBASEOFF + 14 //!< Cdb api : accept() error -#define EDB_AS_GETPEERNAME EDBBASEOFF + 15 //!< Cdb api : getpeername() error -#define EDB_A_WHOISIT EDBBASEOFF + 16 //!< Cdb api : Connection from bad host - -#define EDB_D_EINVAL EDBBASEOFF + 20 //!< Cdb daemon : invalid value -#define EDB_D_EAGAIN EDBBASEOFF + 21 //!< Cdb daemon : yet done -#define EDB_D_AUTH EDBBASEOFF + 22 //!< Cdb daemon : unauthorized -#define EDB_D_LOGIN EDBBASEOFF + 23 //!< Cdb daemon : login refused -#define EDB_D_PWDCORR EDBBASEOFF + 24 //!< Cdb daemon : pwd file corrupted -#define EDB_D_ANA EDBBASEOFF + 25 //!< Cdb daemon : db analysis error -#define EDB_D_HASHSIZE EDBBASEOFF + 26 //!< Cdb daemon : bad hash size -#define EDB_D_UNKNOWN EDBBASEOFF + 27 //!< Cdb daemon : unkn. db/table/key -#define EDB_D_NOLOCK EDBBASEOFF + 28 //!< Cdb daemon : lock is required -#define EDB_D_CORRUPT EDBBASEOFF + 29 //!< Cdb daemon : probably corrupted -#define EDB_D_TOOMUCH EDBBASEOFF + 30 //!< Cdb daemon : data size rejected -#define EDB_D_ENOENT EDBBASEOFF + 31 //!< Cdb daemon : no entry -#define EDB_D_ETYPE EDBBASEOFF + 32 //!< Cdb daemon : unknown member type -#define EDB_D_EVALUE EDBBASEOFF + 33 //!< Cdb daemon : unknown member val -#define EDB_D_NULLVALUE EDBBASEOFF + 34 //!< Cdb daemon : null member value -#define EDB_D_LOCK EDBBASEOFF + 35 //!< Cdb daemon : cannot gain lock -#define EDB_D_FREE EDBBASEOFF + 36 //!< Cdb daemon : unsafe free attempt -#define EDB_D_SHUTDOWN EDBBASEOFF + 37 //!< Cdb daemon : shutdown in progress -#define EDB_D_DEADLOCK EDBBASEOFF + 38 //!< Cdb daemon : deadlock detected -#define EDB_D_EXIST EDBBASEOFF + 39 //!< Cdb daemon : yet exists -#define EDB_D_NOSPC EDBBASEOFF + 40 //!< Cdb daemon : no more space -#define EDB_D_DUMPEND EDBBASEOFF + 41 //!< Cdb daemon : end of dump -#define EDB_D_UNIQUE EDBBASEOFF + 42 //!< Cdb daemon : uniqued key yet exist -#define EDB_D_LISTEND EDBBASEOFF + 43 //!< Cdb daemon : end of list -#define EDB_D_NOTDUMP EDBBASEOFF + 44 //!< Cdb daemon : not in dump mode -#define EDB_D_DNSCHECK EDBBASEOFF + 45 //!< Cdb daemon : double DNS check error -#define EDB_D_REJECTED EDBBASEOFF + 46 //!< Cdb daemon : Connection rejected (not authorised) -#define EDB_D_INIT EDBBASEOFF + 47 //!< Cdb daemon : init in progress -#define EDB_D_INCONST EDBBASEOFF + 48 //!< Cdb daemon : inconsistent request - //!< (unstop and no previous stop, unfreeze and no previous freeze) -#define EDB_D_FREEHASHSIZE EDBBASEOFF + 49 //!< Cdb daemon : bad free hash size -#define EDB_DS_MALLOC EDBBASEOFF + 50 //!< Cdb daemon system : malloc() error -#define EDB_DS_CALLOC EDBBASEOFF + 51 //!< Cdb daemon system : calloc() error -#define EDB_DS_REALLOC EDBBASEOFF + 52 //!< Cdb daemon system : realloc() error -#define EDB_DS_OPEN EDBBASEOFF + 53 //!< Cdb daemon system : open() error -#define EDB_DS_FSTAT EDBBASEOFF + 54 //!< Cdb daemon system : fstat() error -#define EDB_DS_LSEEK EDBBASEOFF + 55 //!< Cdb daemon system : lseek() error -#define EDB_DS_READ EDBBASEOFF + 56 //!< Cdb daemon system : read() error -#define EDB_DS_WRITE EDBBASEOFF + 57 //!< Cdb daemon system : write() error -#define EDB_DS_RENAME EDBBASEOFF + 58 //!< Cdb daemon system : rename() error -#define EDB_DS_FTRUNC EDBBASEOFF + 59 //!< Cdb daemon system : ftruncate() error -#define EDB_DS_TMPNAM EDBBASEOFF + 60 //!< Cdb daemon system : tmpnam() error -#define EDB_DS_FCNTL EDBBASEOFF + 61 //!< Cdb daemon system : fcntl() error -#define EDB_DS_MKDIR EDBBASEOFF + 62 //!< Cdb daemon system : mkdir() error -#define EDB_DS_TIMES EDBBASEOFF + 63 //!< Cdb daemon system : times() error -#define EDB_DS_SYSCONF EDBBASEOFF + 64 //!< Cdb daemon system : sysconf() err/unav -#define EDB_DS_GETHOSTNAME EDBBASEOFF + 65 //!< Cdb daemon system : gethostname() error -#define EDB_DS_GETPEERNAME EDBBASEOFF + 66 //!< Cdb daemon system : getpeername() error -#define EDB_DS_INET_NTOA EDBBASEOFF + 67 //!< Cdb daemon system : getpeername() error -#define EDB_DS_REMOVE EDBBASEOFF + 68 //!< Cdb daemon system : remove() error -#define EDB_DS_SIGACTION EDBBASEOFF + 69 //!< Cdb daemon system : sigaction() error -#define EDB_DS_GETSOCKNAME EDBBASEOFF + 70 //!< Cdb daemon system : getsockname() error -#define EDB_DS_BIND EDBBASEOFF + 71 //!< Cdb daemon system : bind() error -#define EDB_DS_LISTEN EDBBASEOFF + 72 //!< Cdb daemon system : listen() error -#define EDB_DS_CONNECT EDBBASEOFF + 73 //!< Cdb daemon system : connect() error -#define EDB_DS_SOCKET EDBBASEOFF + 74 //!< Cdb daemon system : socket() error -#define EDB_DS_SOCKOPT EDBBASEOFF + 75 //!< Cdb daemon system : [set/get]sockopt() error -#define EDB_D_RESHOST EDBBASEOFF + 76 //!< Cdb daemon : host res error -#define EDB_D_REQSIZE EDBBASEOFF + 77 //!< Cdb daemon : request too big - -#define EDB_C_EINVAL EDBBASEOFF + 80 //!< Cdb config : invalid value -#define EDB_C_ENOENT EDBBASEOFF + 81 //!< Cdb config : configuration error -#define EDB_C_TOOMUCH EDBBASEOFF + 82 //!< Cdb config : conf. size rejected -#define EDB_CS_GETHOSTNAME EDBBASEOFF + 83 //!< Cdb config system : gethostname() error - -#define EDB_NOMOREDB EDBBASEOFF + 90 //!< Cdb : nomoredb - -#define EDBMAXERR EDBBASEOFF + 90 - -/* - *------------------------------------------------------------------------ - * MSG daemon errors - *------------------------------------------------------------------------ - */ -#define EMSMSGU2REP EMSBASEOFF + 1 //!< msg daemon unable to reply -#define EMSMSGSYERR EMSBASEOFF + 2 //!< msg daemon system error -#define EMSNOPERM EMSBASEOFF + 3 //!< Permission denied -#define EMSMAXERR EMSBASEOFF + 3 //!< Maximum error number of MSG -/* - * Backward compatibility - */ -#define SEMSGU2REP EMSMSGU2REP -#define SEMSGSYERR EMSMSGSYERR -#define SENOPERM EMSNOPERM - -/* - *------------------------------------------------------------------------ - * NS (Name Server) errors - *------------------------------------------------------------------------ - */ -#define ENSNACT ENSBASEOFF + 1 //!< Name server not active -#define ENSFILECHG ENSBASEOFF + 2 //!< File has been overwritten, request ignored -#define ENSNOSEG ENSBASEOFF + 3 //!< Segment had been deleted -#define ENSISLINK ENSBASEOFF + 4 //!< Is a link -#define ENSCLASSNOSEGS ENSBASEOFF + 5 //!< File class does not allow a copy on tape -#define ENSTOOMANYSEGS ENSBASEOFF + 6 //!< Too many copies on tape -#define ENSOVERWHENREP ENSBASEOFF + 7 //!< Cannot overwrite valid segment when replacing -#define ENHOSTNOTSET ENSBASEOFF + 8 //!< CNS HOST not set -#define ENSMAXERR ENSBASEOFF + 8 - -/* - *------------------------------------------------------------------------ - * RFIO errors - *------------------------------------------------------------------------ - */ -#define ERFNORCODE ERFBASEOFF + 1 //!< RFIO communication error -#define ERFHOSTREFUSED ERFBASEOFF + 2 //!< RFIO rejected connect attempt -#define ERFXHOST ERFBASEOFF + 3 //!< Cross-host link (rename()) -#define ERFPROTONOTSUP ERFBASEOFF + 4 //!< RFIO protocol not supported -#define ERFMAXERR ERFBASEOFF + 4 //!< Maximum error number of RFIO -/* - * Backward compatibility - */ -#define SENORCODE ERFNORCODE -#define SEHOSTREFUSED ERFHOSTREFUSED -#define SEXHOST ERFXHOST -#define SEPROTONOTSUP ERFPROTONOTSUP - -/* - *------------------------------------------------------------------------ - * RTCOPY errors - *------------------------------------------------------------------------ - */ -#define ERTTMSERR ERTBASEOFF + 1 //!< TMS call failed -#define ERTBLKSKPD ERTBASEOFF + 2 //!< Blocks were skipped in file -#define ERTTPE_LSZ ERTBASEOFF + 3 //!< Blocks skipped and file truncated -#define ERTMNYPARY ERTBASEOFF + 4 //!< Too many skipped blocks -#define ERTLIMBYSZ ERTBASEOFF + 5 //!< File limited by size -#define ERTUSINTR ERTBASEOFF + 6 //!< Request interrupted by user -#define ERTOPINTR ERTBASEOFF + 7 //!< Request interrupted by operator -#define ERTNOTCLIST ERTBASEOFF + 8 //!< Request list is not circular -#define ERTBADREQ ERTBASEOFF + 9 //!< Bad request structure -#define ERTMORETODO ERTBASEOFF + 10 //!< Request partially processed -#define ERTDBERR ERTBASEOFF + 11 //!< Catalogue DB error -#define ERTZEROSIZE ERTBASEOFF + 12 //!< Zero sized file -#define ERTWRONGSIZE ERTBASEOFF + 13 //!< Recalled file size incorrect -#define ERTWRONGFSEQ ERTBASEOFF + 14 //!< Inconsistent FSEQ in VMGR and Cns -#define ERTMAXERR ERTBASEOFF + 14 - -/* - *------------------------------------------------------------------------ - * STAGE errors - *------------------------------------------------------------------------ - */ -#define ESTCLEARED ESTBASEOFF + 1 //!< aborted -#define ESTENOUGHF ESTBASEOFF + 2 //!< enough free space -#define ESTLNKNCR ESTBASEOFF + 3 //!< symbolic link not created -#define ESTLNKNSUP ESTBASEOFF + 4 //!< symbolic link not supported -#define ESTNACT ESTBASEOFF + 5 //!< Stager not active -#define ESTGROUP ESTBASEOFF + 6 //!< Your group is invalid -#define ESTGRPUSER ESTBASEOFF + 7 //!< No GRPUSER in configuration -#define ESTUSER ESTBASEOFF + 8 //!< Invalid user -#define ESTHSMHOST ESTBASEOFF + 9 //!< HSM HOST not specified -#define ESTTMSCHECK ESTBASEOFF + 10 //!< tmscheck error -#define ESTLINKNAME ESTBASEOFF + 11 //!< User link name processing error -#define ESTWRITABLE ESTBASEOFF + 12 //!< User path in a non-writable directory -#define ESTKILLED ESTBASEOFF + 13 //!< aborted by kill -#define ESTMEM ESTBASEOFF + 14 //!< request too long (api) -#define ESTCONF ESTBASEOFF + 15 //!< Stage configuration error -#define ESTSEGNOACC ESTBASEOFF + 16 //!< Unreadable file on tape (segments not all accessible) -#define ESTREPLFAILED ESTBASEOFF + 17 //!< File replication failed -#define ESTNOTAVAIL ESTBASEOFF + 18 //!< File is currently not available -#define ESTJOBKILLED ESTBASEOFF + 19 //!< Job killed by service administrator -#define ESTJOBTIMEDOUT ESTBASEOFF + 20 //!< Job timed out while waiting to be scheduled -#define ESTSCHEDERR ESTBASEOFF + 21 //!< Scheduler error -#define ESTSVCCLASSNOFS ESTBASEOFF + 22 //!< No filesystems available in service class -#define ESTNOSEGFOUND ESTBASEOFF + 23 //!< File has no copy on tape and no diskcopies are accessible -#define ESTTAPEOFFLINE ESTBASEOFF + 24 //!< File is on an offline tape -#define ESTREQCANCELED ESTBASEOFF + 25 //!< Request canceled while queuing -#define ESTTCNOTFOUND ESTBASEOFF + 26 //!< Tape-copy not found -#define ESTNOTAPEROUTE ESTBASEOFF + 27 //!< The file cannot be routed to tape -#define ESTMAXERR ESTBASEOFF + 27 - -/* - *------------------------------------------------------------------------ - * SYSREQ errors - *------------------------------------------------------------------------ - */ -#define ESQTMSNOTACT ESQBASEOFF + 1 //!< TMS not active -#define ESQMAXERR ESQBASEOFF + 1 //!< Maximum error number of SYSREQ -/* - * Backward compatibility - */ -#define SETMSNOTACT ESQTMSNOTACT - -/* - *------------------------------------------------------------------------ - * TAPE errors - *------------------------------------------------------------------------ - */ -#define ETDNP ETBASEOFF + 1 //!< daemon not available -#define ETSYS ETBASEOFF + 2 //!< system error -#define ETPRM ETBASEOFF + 3 //!< bad parameter -#define ETRSV ETBASEOFF + 4 //!< reserv already issued -#define ETNDV ETBASEOFF + 5 //!< too many drives requested -#define ETIDG ETBASEOFF + 6 //!< invalid device group name -#define ETNRS ETBASEOFF + 7 //!< reserv not done -#define ETIDN ETBASEOFF + 8 //!< no drive with requested characteristics -#define ETLBL ETBASEOFF + 9 //!< bad label structure -#define ETFSQ ETBASEOFF + 10 //!< bad file sequence number -#define ETINTR ETBASEOFF + 11 //!< interrupted by user -#define ETEOV ETBASEOFF + 12 //!< EOV found in multivolume set -#define ETRLSP ETBASEOFF + 13 //!< release pending -#define ETBLANK ETBASEOFF + 14 //!< blank tape -#define ETCOMPA ETBASEOFF + 15 //!< compatibility problem -#define ETHWERR ETBASEOFF + 16 //!< device malfunction -#define ETPARIT ETBASEOFF + 17 //!< parity error -#define ETUNREC ETBASEOFF + 18 //!< unrecoverable media error -#define ETNOSNS ETBASEOFF + 19 //!< no sense -#define ETRSLT ETBASEOFF + 20 //!< reselect server -#define ETVBSY ETBASEOFF + 21 //!< volume busy or inaccessible -#define ETDCA ETBASEOFF + 22 //!< drive currently assigned -#define ETNRDY ETBASEOFF + 23 //!< drive not ready -#define ETABSENT ETBASEOFF + 24 //!< volume absent -#define ETARCH ETBASEOFF + 25 //!< volume archived -#define ETHELD ETBASEOFF + 26 //!< volume held or disabled -#define ETNXPD ETBASEOFF + 27 //!< file not expired -#define ETOPAB ETBASEOFF + 28 //!< operator cancel -#define ETVUNKN ETBASEOFF + 29 //!< volume unknown -#define ETWLBL ETBASEOFF + 30 //!< wrong label type -#define ETWPROT ETBASEOFF + 31 //!< cartridge write protected -#define ETWVSN ETBASEOFF + 32 //!< wrong vsn -#define ETBADMIR ETBASEOFF + 33 //!< Tape has a bad MIR -#define ETNETACCEPTINTR ETBASEOFF + 34 //!< castor::tape::net::acceptConnection interrupted -#define ETNOLBLINFO ETBASEOFF + 35 //!< Label information not found in memory -#define ETMLTDRVRSV ETBASEOFF + 36 //!< Multi-drive reservations are not supported -#define ETNOLBLINFOMEM ETBASEOFF + 37 //!< No memory available for label information -#define ETSESSIONERROR ETBASEOFF + 38 //!< Tape-session error -#define ETINVALIDTFSEQ ETBASEOFF + 39 //!< Invalid tape-file sequence-number -#define ETINVALIDTFSIZE ETBASEOFF + 40 //!< Invalid tape-file file-size -#define ETMOUNTFAILED ETBASEOFF + 41 //!< Failed to mount volume -#define ETDISMOUNTFAILED ETBASEOFF + 42 //!< Failed to dismount volume -#define ETQUERYVOLFAILED ETBASEOFF + 43 //!< Failed to query volume -#define ETFDISMOUNTFAILED ETBASEOFF + 44 //!< Failed to force dismount volume -#define ETDRVNOTREADYFORMNT ETBASEOFF + 45 //!< Drive not ready for mount -#define ETMAXERR ETBASEOFF + 45 - -/* - *------------------------------------------------------------------------ - * VMGR (Volume Manager) errors - *------------------------------------------------------------------------ - */ -#define EVMGRNACT EVMBASEOFF + 1 //!< volume manager not active or service being drained -#define EVMGRNOHOST EVMBASEOFF + 2 //!< VMGR HOST not set -#define EVMMAXERR EVMBASEOFF + 2 - -/* - *------------------------------------------------------------------------ - * UPV (User Privilege Validator) errors - *------------------------------------------------------------------------ - */ -#define ECUPVNACT EUPBASEOFF + 1 //!< User Privilege Validator not active or service being drained -#define EUPMAXERR EUPBASEOFF + 1 - -/* - *------------------------------------------------------------------------ - * DNS errors - See netdb.h for details - *------------------------------------------------------------------------ - */ -#define EDNSHOSTNOTFOUND EDNSBASEOFF + 1 //!< Authoritative Answer Host not found. -#define EDNSTRYAGAIN EDNSBASEOFF + 2 //!< Non-Authoritative Host not found, or SERVERFAIL -#define EDNSNORECOVERY EDNSBASEOFF + 3 //!< Non recoverable errors, FORMERR, REFUSED, NOTIMP. -#define EDNSNODATA EDNSBASEOFF + 4 //!< Valid name, no data record of requested type. -#define EDNSNOADDRESS EDNSBASEOFF + 5 //!< No address, look for MX record. -#define EDNSMAXERR EDNSBASEOFF + 6 - -/* - *------------------------------------------------------------------------ - * VDQM (Volume & Drive Queue Manager) errors - *------------------------------------------------------------------------ - */ -#define EVQSYERR EVQBASEOFF + 1 //!< Failed system call -#define EVQINCONSIST EVQBASEOFF + 2 //!< Internal DB inconsistency -#define EVQREPLICA EVQBASEOFF + 3 //!< DB replication failed -#define EVQNOVOL EVQBASEOFF + 4 //!< No volume request queued -#define EVQNODRV EVQBASEOFF + 5 //!< No free drive available -#define EVQNOSVOL EVQBASEOFF + 6 //!< Specified vol. req. not found -#define EVQNOSDRV EVQBASEOFF + 7 //!< Specified drv. req. not found -#define EVQALREADY EVQBASEOFF + 8 //!< Specified vol. req. already exists -#define EVQUNNOTUP EVQBASEOFF + 9 //!< Unit not up -#define EVQBADSTAT EVQBASEOFF + 10 //!< Bad unit status request -#define EVQBADID EVQBASEOFF + 11 //!< Incorrect vol.req or job ID -#define EVQBADJOBID EVQBASEOFF + 12 //!< Incorrect job ID -#define EVQNOTASS EVQBASEOFF + 13 //!< Unit not assigned -#define EVQBADVOLID EVQBASEOFF + 14 //!< Attempt to mount with wrong VOLID -#define EVQREQASS EVQBASEOFF + 15 //!< Attempt to delete an assigned req -#define EVQDGNINVL EVQBASEOFF + 16 //!< Vol. req. for non-existing DGN -#define EVQPIPEFULL EVQBASEOFF + 17 //!< Replication pipe is full -#define EVQHOLD EVQBASEOFF + 18 //!< Server is held -#define EVQEOQREACHED EVQBASEOFF + 19 //!< End of query reached - -#define EVQMAXERR EVQBASEOFF + 19 - -/* - *------------------------------------------------------------------------ +/** * RMC (Remote SCSI media changer server) errors - *------------------------------------------------------------------------ - */ -#define ERMCNACT ERMBASEOFF + 1 //!< Remote SCSI media changer server not active or service being drained -#define ERMCRBTERR (ERMBASEOFF + 2) //!< Remote SCSI media changer error -#define ERMCUNREC ERMCRBTERR + 1 //!< Remote SCSI media changer unrec. error -#define ERMCSLOWR ERMCRBTERR + 2 //!< Remote SCSI media changer error (slow retry) -#define ERMCFASTR ERMCRBTERR + 3 //!< Remote SCSI media changer error (fast retry) -#define ERMCDFORCE ERMCRBTERR + 4 //!< Remote SCSI media changer error (demount force) -#define ERMCDDOWN ERMCRBTERR + 5 //!< Remote SCSI media changer error (drive down) -#define ERMCOMSGN ERMCRBTERR + 6 //!< Remote SCSI media changer error (ops message) -#define ERMCOMSGS ERMCRBTERR + 7 //!< Remote SCSI media changer error (ops message + retry) -#define ERMCOMSGR ERMCRBTERR + 8 //!< Remote SCSI media changer error (ops message + wait) -#define ERMCUNLOAD ERMCRBTERR + 9 //!< Remote SCSI media changer error (unload + demount) -#define ERMMAXERR ERMBASEOFF + 11 - -/* - *------------------------------------------------------------------------ - * MONITORING ERRORS - *------------------------------------------------------------------------ - */ - -#define EMON_SYSTEM EMONBASEOFF + 1 //!< When a system error causes the monitoring to stop -#define EMON_NO_HOST EMONBASEOFF + 2 //!< No monitoring host defined in the configuration -#define EMON_NO_PORT EMONBASEOFF + 3 //!< No monitoring port defined in the configuration -#define EMON_NO_CLIENTPORT EMONBASEOFF + 4 //!< No port for client requests defined in the configuration - -#define EMONMAXERR EMONBASEOFF + 4 - -/* - *------------------------------------------------------------------------ - * SECURITY ERRORS - *------------------------------------------------------------------------ - */ -#define ESEC_SYSTEM ESECBASEOFF + 1 //!< System error in the security package -#define ESEC_BAD_CREDENTIALS ESECBASEOFF + 2 //!< Bad credentials -#define ESEC_NO_CONTEXT ESECBASEOFF + 3 //!< Could not establish context -#define ESEC_BAD_MAGIC ESECBASEOFF + 4 //!< Bad magic number -#define ESEC_NO_USER ESECBASEOFF + 5 //!< Could not map username to uid/gid -#define ESEC_NO_PRINC ESECBASEOFF + 6 //!< Could not map principal to username -#define ESEC_NO_SECMECH ESECBASEOFF + 7 //!< Could not load security mechanism -#define ESEC_CTX_NOT_INITIALIZED ESECBASEOFF + 8 //!< Context not initialized -#define ESEC_PROTNOTSUPP ESECBASEOFF + 9 //!< Security protocol not supported -#define ESEC_NO_SVC_NAME ESECBASEOFF + 10 //!< Service name not set -#define ESEC_NO_SVC_TYPE ESECBASEOFF + 11 //!< Service type not set -#define ESEC_NO_SECPROT ESECBASEOFF + 12 //!< Could not lookup security protocol -#define ESEC_BAD_CSEC_VERSION ESECBASEOFF + 13 //!< Csec incompatability -#define ESEC_BAD_PEER_RESP ESECBASEOFF + 14 //!< Unexpected response from peer -#define ESECMAXERR ESECBASEOFF + 14 - -/* - *------------------------------------------------------------------------ - * End of package specific error messages - *------------------------------------------------------------------------ */ +constexpr int ERMBASEOFF = 2200; //!< RMC error base offset + +enum RMCError { + ERMCNACT = ERMBASEOFF + 1, //!< Remote SCSI media changer server not active or service being drained + ERMCRBTERR = ERMBASEOFF + 2, //!< Remote SCSI media changer error + ERMCUNREC = ERMCRBTERR + 1, //!< Remote SCSI media changer unrec. error + ERMCSLOWR = ERMCRBTERR + 2, //!< Remote SCSI media changer error (slow retry) + ERMCFASTR = ERMCRBTERR + 3, //!< Remote SCSI media changer error (fast retry) + ERMCDFORCE = ERMCRBTERR + 4, //!< Remote SCSI media changer error (demount force) + ERMCDDOWN = ERMCRBTERR + 5, //!< Remote SCSI media changer error (drive down) + ERMCOMSGN = ERMCRBTERR + 6, //!< Remote SCSI media changer error (ops message) + ERMCOMSGS = ERMCRBTERR + 7, //!< Remote SCSI media changer error (ops message + retry) + ERMCOMSGR = ERMCRBTERR + 8, //!< Remote SCSI media changer error (ops message + wait) + ERMCUNLOAD = ERMCRBTERR + 9, //!< Remote SCSI media changer error (unload + demount) + ERMMAXERR = ERMBASEOFF + 11 +}; /* * Multi-thread (MT) environment diff --git a/mediachanger/librmc/serror.cpp b/mediachanger/librmc/serror.cpp index a0b755dd4617ec8220d74d944f3f42c0c8424623..2b647d7c5f9eb33a0477905941fc996721fe106c 100644 --- a/mediachanger/librmc/serror.cpp +++ b/mediachanger/librmc/serror.cpp @@ -82,319 +82,6 @@ const char* sys_serrlist[SEMAXERR - SEBASEOFF + 2] = {"Error 0", * Package specific error messages (don't forget to update h/serrno.h) */ -/* - *------------------------------------------------------------------------ - * DB specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_dberrlist[EDBMAXERR - EDBBASEOFF + 2] = { - "Error 0", - "Cdb api : invalid Cdb_sess_t parameter", - "Cdb api : invalid Cdb_db_t parameter", - "Cdb api : invalid value", - "Cdb api : Cdb server hostname resolution error (Cgethostbyname)", - "Cdb api : data size rejected (exceeds theorical value)", - "Cdb api system : socket() error", - "Cdb api system : [set/get]sockopt() error", - "Cdb api system : malloc() error", - "Cdb api : no last error", - "Cdb api : interface invalid value", - "Cdb api system : bind() error", - "Cdb api system : listen() error", - "Cdb api system : getsockname() error", - "Cdb api system : accept() error", - "Cdb api system : getpeername() error", - "Cdb api : connection back from bad host", - "Error 17", - "Error 18", - "Error 19", - "Cdb daemon : invalid value", - "Cdb daemon : yet done", - "Cdb daemon : unauthorized", - "Cdb daemon : login refused", - "Cdb daemon : password file corrupted", - "Cdb daemon : database description analysis error", - "Cdb daemon : bad hash size", - "Cdb daemon : unknown database/table/key", - "Cdb daemon : a lock is required", - "Cdb daemon : datatabase (probably) corrupted", - "Cdb daemon : data size rejected (exceeds theorical value)", - "Cdb daemon : no entry", - "Cdb daemon : unknown record member type", - "Cdb daemon : unknown record member val", - "Cdb daemon : null record member value", - "Cdb daemon : lock deny", - "Cdb daemon : attempt to free something Cdb claims it is of zero size", - "Cdb daemon : shutdown in progress", - "Cdb daemon : deadlock detected", - "Cdb daemon : yet exists", - "Cdb daemon : no more space", - "Cdb daemon : end of dump", - "Cdb daemon : uniqued key yet exists", - "Cdb daemon : end of list", - "Cdb daemon : not in dump mode", - "Cdb daemon : double DNS check error", - "Cdb daemon : Connection rejected (not authorised)", - "Cdb daemon : init in progress", - "Cdb daemon : inconsistent request (unstop and no previous stop, unfreeze and no previous freeze)", - "Cdb daemon : bad free hash size", - "Cdb daemon system : malloc() error", - "Cdb daemon system : calloc() error", - "Cdb daemon system : realloc() error", - "Cdb daemon system : open() error", - "Cdb daemon system : fstat() error", - "Cdb daemon system : lseek() error", - "Cdb daemon system : read() error", - "Cdb daemon system : write() error", - "Cdb daemon system : rename() error", - "Cdb daemon system : ftruncate() error", - "Cdb daemon system : tmpnam() error", - "Cdb daemon system : fcntl() error", - "Cdb daemon system : mkdir() error", - "Cdb daemon system : times() error", - "Cdb daemon system : sysconf() err/unav", - "Cdb daemon system : Cdb client hostname resolution error (Cgethostbyname)", - "Cdb daemon system : getpeername() error", - "Cdb daemon system : inet_ntoa() error", - "Cdb daemon system : remove() error", - "Cdb daemon system : sigaction() error", - "Cdb daemon system : getsockname() error", - "Cdb daemon system : bind() error", - "Cdb daemon system : listen() error", - "Cdb daemon system : connect() error", - "Cdb daemon system : socket() error", - "Cdb daemon system : [set/get]socketopt() error", - "Cdb daemon : Host resolution error", - "Cdb daemon : Request too big", - "Error 78", - "Error 79", - "Cdb config : invalid configuration value", - "Cdb config : configuration error", - "Cdb config : configuration value rejected (exceeds maximum size)", - "Cdb config system : gethostname() error", - "Error 84", - "Error 85", - "Error 86", - "Error 87", - "Error 88", - "Error 89", - "Cdb : nomoredb", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * MSG daemon specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_mserrlist[EMSMAXERR - EMSBASEOFF + 2] = {"Error 0", - "Message daemon unable to reply", - "Message daemon system error", - "Permission denied", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * NS (Name Server) specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_nserrlist[ENSMAXERR - ENSBASEOFF + 2] = {"Error 0", - "Name server not active", - "File has been overwritten, request ignored", - "Segment had been deleted", - "Is a link", - "File class does not allow a copy on tape", - "Too many copies on tape", - "Cannot overwrite valid segment when replacing", - "CNS HOST not set", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * RFIO specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_rferrlist[ERFMAXERR - ERFBASEOFF + 2] = {"Error 0", - "Host did not return error number", - "Host is not on local network and no mapping found", - "Cannot create linked file across hosts", - "Protocol not supported", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * RTCOPY specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_rterrlist[ERTMAXERR - ERTBASEOFF + 2] = {"Error 0", - "TMS error", - "Blocks skipped in file", - "Blocks skipped and file limited by size", - "Too many skipped blocks", - "File limited by size", - "Request interrupted by user", - "Request interrupted by operator", - "Request list is not circular", - "Bad request structure", - "Request partially processed", - "Catalogue DB error", - "Zero sized file", - "Recalled file size incorrect", - "Inconsistent FSEQ in VMGR and Cns", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * STAGE specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_sterrlist[ESTMAXERR - ESTBASEOFF + 2] = {"Error 0", - "Aborted", - "Enough free space", - "Symbolic link not created", - "Symbolic link not supported", - "Stager not active", - "Your group is invalid", - "No GRPUSER in configuration", - "Invalid user", - "HSM HOST not specified", - "tmscheck error", - "User link name processing error", - "User path in a non-writable directory", - "Request killed", - "Request too long (socket buffer size)", - "Stage configuration error", - "Unreadable file on tape (segments not all accessible)", - "File replication failed", - "File is currently not available", - "Job killed by service administrator", - "Job timed out while waiting to be scheduled", - "Scheduler error", - "No filesystems available in service class", - "File has no copy on tape and no diskcopies are accessible", - "File is on an offline tape", - "Request canceled while queuing", - "Tape-copy not found", - "The file cannot be routed to tape", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * SYSREQ specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_sqerrlist[ESQMAXERR - ESQBASEOFF + 2] = {"Error 0", "TMS not active", "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * TAPE specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_terrlist[ETMAXERR - ETBASEOFF + 2] = {"Error 0", - "Tape daemon not available", - "System error", - "Bad parameter", - "Reserve already issued", - "Too many drives requested", - "Invalid device group name", - "Reserve not done", - "No drive with requested name/characteristics", - "Bad label structure", - "Bad file sequence number", - "Interrupted by user", - "EOV found in multivolume set", - "Release pending", - "Blank tape", - "Compatibility problem", - "Device malfunction", - "Parity error", - "Unrecoverable media error", - "No sense", - "Reselect server", - "Volume busy or inaccessible", - "Drive currently assigned", - "Drive not ready", - "Volume absent", - "Volume archived", - "Volume held or disabled", - "File not expired", - "Operator cancel", - "Volume unknown", - "Wrong label type", - "Cartridge write protected", - "Wrong vsn", - "Tape has a bad MIR", - "castor::tape::net::acceptConnection interrupted", - "Label information not found in memory", - "Multi-drive reservations are not supported", - "No memory available for label information", - "Tape-session error", - "Invalid tape-file sequence-number", - "Invalid tape-file file-size", - "Failed to mount volume", - "Failed to dismount volume", - "Failed to query volume", - "Failed to force dismount volume", - "Drive not ready for mount", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * VAL (Volume Allocator) specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_vaerrlist[EVMMAXERR - EVMBASEOFF + 2] = {"Error 0", - "Volume manager not active", - "VMGR HOST not set", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * UPV (User Privilege Validator) specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_uperrlist[EUPMAXERR - EUPBASEOFF + 2] = {"Error 0", "UPV not active", "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * DNS specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_dnserrlist[EDNSMAXERR - EDNSBASEOFF + 2] = { - "Error 0", - "The specified host is unknown", - "A temporary error occurred on an authoritative name server. Try again later", - "A non-recoverable name server error occurred", - "The requested name is valid but does not have an IP address", - "The requested name is valid but does not have an IP address", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * VDQM (Volume & Drive Queue Manager) specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_vqerrlist[EVQMAXERR - EVQBASEOFF + 2] = {"Error 0", - "Failed system call", - "Internal DB inconsistency", - "DB replication failed", - "No volume request queued", - "No free drive available", - "Specified vol. req. not found", - "Specified drv. req. not found", - "Specified vol. req. already exists", - "Unit not up", - "Bad unit status request", - "Incorrect vol.req or job ID", - "Incorrect job ID", - "Unit not assigned", - "Attempt to mount with wrong VOLID", - "Attempt to delete an assigned request", - "Request for non-existing DGN", - "Replication pipe is full", - "Server is held", - "End of query reached", - "BAD ERROR NUMBER"}; - /* *------------------------------------------------------------------------ * RMC (Remote SCSI Media Changer server) specific error messages @@ -414,46 +101,6 @@ const char* sys_rmerrlist[ERMMAXERR - ERMBASEOFF + 2] = {"Error 0", "Remote SCSI media changer error (unload + demount)", "BAD ERROR NUMBER"}; -/* - *------------------------------------------------------------------------ - * Monitor specific error messages - *------------------------------------------------------------------------ - */ -const char* sys_monerrlist[EMONMAXERR - EMONBASEOFF + 2] = {"Error 0", - "System Error", - "Monitor Host not specified", - "Monitor Port not specified", - "Client port not specified", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * Security package errors - *------------------------------------------------------------------------ - */ -const char* sys_secerrlist[ESECMAXERR - ESECBASEOFF + 2] = {"Error 0", - "System error", - "Bad credentials", - "Could not establish context", - "Bad magic number", - "Could not map username to uid/gid", - "Could not map principal to username", - "Could not load security mechanism", - "Context not initialized", - "Security protocol not supported", - "Service name not set", - "Service type not set", - "Could not lookup security protocol", - "Csec incompatibility", - "Unexpected response from peer", - "BAD ERROR NUMBER"}; - -/* - *------------------------------------------------------------------------ - * End of package specific error messages - *------------------------------------------------------------------------ - */ - int sstrerror_r(const int n, char* const buf, const size_t buflen) { const char* tmpstr; char strerror_r_buf[100]; @@ -468,89 +115,13 @@ int sstrerror_r(const int n, char* const buf, const size_t buflen) { tmpstr = nullptr; if ((n > SEBASEOFF) && (n <= SEMAXERR)) { - /* - * COMMON error messages - */ + // COMMON error messages tmpstr = sys_serrlist[n - SEBASEOFF]; - } else if ((n > EDBBASEOFF) && (n <= EDBMAXERR)) { - /* - * DB specific error messages - */ - tmpstr = sys_dberrlist[n - EDBBASEOFF]; - } else if ((n > EMSBASEOFF) && (n <= EMSMAXERR)) { - /* - * MSG specific error messages - */ - tmpstr = sys_mserrlist[n - EMSBASEOFF]; - } else if ((n > ENSBASEOFF) && (n <= ENSMAXERR)) { - /* - * NS (Name server) specific error messages - */ - tmpstr = sys_nserrlist[n - ENSBASEOFF]; - } else if ((n > ERFBASEOFF) && (n <= ERFMAXERR)) { - /* - * RFIO specific error messages - */ - tmpstr = sys_rferrlist[n - ERFBASEOFF]; - } else if ((n > ERTBASEOFF) && (n <= ERTMAXERR)) { - /* - * RTCOPY specific error messages - */ - tmpstr = sys_rterrlist[n - ERTBASEOFF]; - } else if ((n > ESTBASEOFF) && (n <= ESTMAXERR)) { - /* - * STAGE specific error messages - */ - tmpstr = sys_sterrlist[n - ESTBASEOFF]; - } else if ((n > ESQBASEOFF) && (n <= ESQMAXERR)) { - /* - * SYSREQ specific error messages - */ - tmpstr = sys_sqerrlist[n - ESQBASEOFF]; - } else if ((n > ETBASEOFF) && (n <= ETMAXERR)) { - /* - * TAPE specific error messages - */ - tmpstr = sys_terrlist[n - ETBASEOFF]; - } else if ((n > EVMBASEOFF) && (n <= EVMMAXERR)) { - /* - * VMGR (Volume manager) specific error messages - */ - tmpstr = sys_vaerrlist[n - EVMBASEOFF]; - } else if ((n > EUPBASEOFF) && (n <= EUPMAXERR)) { - /* - * UPV specific error messages - */ - tmpstr = sys_uperrlist[n - EUPBASEOFF]; - } else if ((n > EDNSBASEOFF) && (n <= EDNSMAXERR)) { - /* - * DNS specific error messages - */ - tmpstr = sys_dnserrlist[n - EDNSBASEOFF]; - } else if ((n > EVQBASEOFF) && (n <= EVQMAXERR)) { - /* - * VDQM (Volume & Drive Queue Manager) specific error messages - */ - tmpstr = sys_vqerrlist[n - EVQBASEOFF]; } else if ((n > ERMBASEOFF) && (n <= ERMMAXERR)) { - /* - * RMC (Remote SCSI media changer server) specific error messages - */ + // RMC (Remote SCSI media changer server) specific error messages tmpstr = sys_rmerrlist[n - ERMBASEOFF]; - } else if ((n > EMONBASEOFF) && (n <= EMONMAXERR)) { - /* - * Monitor specific error messages - */ - tmpstr = sys_monerrlist[n - EMONBASEOFF]; - } else if ((n > ESECBASEOFF) && (n <= ESECMAXERR)) { - /* - * Security specific error messages - */ - tmpstr = sys_secerrlist[n - ESECBASEOFF]; } else if (n > 0) { - /* - * SYSTEM error messages - */ + // SYSTEM error messages const int strerror_r_wrapper_rc = strerror_r_wrapper(n, strerror_r_buf, sizeof(strerror_r_buf)); if (strerror_r_wrapper_rc) { tmpstr = "Unknown error because call to strerror_r_wrapper() failed"; @@ -563,9 +134,7 @@ int sstrerror_r(const int n, char* const buf, const size_t buflen) { strncpy(buf, tmpstr, buflen); buf[buflen - 1] = '\0'; } else { - /* - * Unknown error message - */ + // Unknown error message snprintf(buf, buflen, "%*s: %10d", (int) buflen - 14, sys_serrlist[SEMAXERR + 1 - SEBASEOFF], n); } return 0; diff --git a/mediachanger/librmc/smc_struct.hpp b/mediachanger/librmc/smc_struct.hpp index 00c123430f7603d912df27f699954ab5d98b4fe2..1c71a17b1a10eb09b76ad8a2f7d3b9f1d9728fb8 100644 --- a/mediachanger/librmc/smc_struct.hpp +++ b/mediachanger/librmc/smc_struct.hpp @@ -16,7 +16,8 @@ */ #pragma once -#include "Castor_limits.hpp" +//! maximum length for a robot name +constexpr int CA_MAXRBTNAMELEN = 17; struct robot_info { char inquiry[32]; diff --git a/mediachanger/rmcd/rbtsubr_constants.hpp b/mediachanger/rmcd/rbtsubr_constants.hpp index 3a89e36c514e71d3b6c4e9ba8d33b21bb0ba6444..12f42fe1b230b1d00a003e109cbe06d9378ca698 100644 --- a/mediachanger/rmcd/rbtsubr_constants.hpp +++ b/mediachanger/rmcd/rbtsubr_constants.hpp @@ -17,15 +17,15 @@ #pragma once -// rbtsubr return codes - -#define RBT_OK 0 //!< Ok or error should be ignored -#define RBT_NORETRY 1 //!< Unrecoverable error (just log it) -#define RBT_SLOW_RETRY 2 //!< Should release drive & retry in 600 seconds -#define RBT_FAST_RETRY 3 //!< Should retry in 60 seconds -#define RBT_DMNT_FORCE 4 //!< Should do first a demount force -#define RBT_CONF_DRV_DN 5 //!< Should configure the drive down -#define RBT_OMSG_NORTRY 6 //!< Should send a msg to operator and exit -#define RBT_OMSG_SLOW_R 7 //!< Ops msg (nowait) + release drive + slow retry -#define RBT_OMSGR 8 //!< Should send a msg to operator and wait -#define RBT_UNLD_DMNT 9 //!< Should unload the tape and retry demount +enum RbtSubrReturnCode { + RBT_OK = 0, //!< Ok or error should be ignored + RBT_NORETRY = 1, //!< Unrecoverable error (just log it) + RBT_SLOW_RETRY = 2, //!< Should release drive & retry in 600 seconds + RBT_FAST_RETRY = 3, //!< Should retry in 60 seconds + RBT_DMNT_FORCE = 4, //!< Should do first a demount force + RBT_CONF_DRV_DN = 5, //!< Should configure the drive down + RBT_OMSG_NORTRY = 6, //!< Should send a msg to operator and exit + RBT_OMSG_SLOW_R = 7, //!< Ops msg (nowait) + release drive + slow retry + RBT_OMSGR = 8, //!< Should send a msg to operator and wait + RBT_UNLD_DMNT = 9 //!< Should unload the tape and retry demount +}; diff --git a/mediachanger/rmcd/rmc_constants.hpp b/mediachanger/rmcd/rmc_constants.hpp index 6a6c1b6d13ff7c1dcb9d7c080eb2076de5f76c99..e6f47052c22a129b63275820f8b71dd4745c5ff6 100644 --- a/mediachanger/rmcd/rmc_constants.hpp +++ b/mediachanger/rmcd/rmc_constants.hpp @@ -17,55 +17,56 @@ #pragma once -#define RMC_CHECKI 5 //!< max interval to check for work to be done -#define RMC_PRTBUFSZ 180 -#define RMC_REPBUFSZ 524288 //!< must be >= max media changer server reply size -#define RMC_REQBUFSZ 256 //!< must be >= max media changer server request size -#define RMC_MAGIC 0x120D0301 -#define RMC_TIMEOUT 5 //!< netread timeout while receiving a request -#define RMC_RETRYI 60 -#define RMC_LOGBUFSZ 1024 +//! maximum length for a VID +constexpr int CA_MAXVIDLEN = 6; -#define REQ_DATA_SIZE (RMC_REQBUFSZ - 3 * LONGSIZE) //!< Size of buffer pointed to by rqst_context.req_data +enum RMCConstant { + RMC_CHECKI = 5, //!< max interval to check for work to be done + RMC_PRTBUFSZ = 180, + RMC_REPBUFSZ = 524288, //!< must be >= max media changer server reply size + RMC_REQBUFSZ = 256, //!< must be >= max media changer server request size + RMC_MAGIC = 0x120D0301, + RMC_TIMEOUT = 5, //!< netread timeout while receiving a request + RMC_RETRYI = 60, + RMC_LOGBUFSZ = 1024, + RMC_PORT = 5014 +}; -#define RMC_PORT 5014 +#define REQ_DATA_SIZE (RMC_REQBUFSZ - 3 * LONGSIZE) //!< Size of buffer pointed to by rqst_context.req_data -#define RMC_MAXRQSTATTEMPTS 10 //!< Maximum number of attempts a retriable RMC request should be issued +enum SMCExitCode { + USERR = 1, //!< user error + SYERR = 2, //!< system error + CONFERR = 4 //!< configuration error +}; -// SCSI media changer utilities exit codes +enum RMCRequestType { + RMC_GETGEOM = 1, //!< Get robot geometry + RMC_FINDCART = 2, //!< Find cartridge(s) + RMC_READELEM = 3, //!< Read element status + RMC_MOUNT = 4, //!< Mount request + RMC_UNMOUNT = 5, //!< Unmount request + RMC_EXPORT = 6, //!< Export tape request + RMC_IMPORT = 7, //!< Import tape request + RMC_GENERICMOUNT = 8, //!< Generic (SCSI or ACS) mount request + RMC_GENERICUNMOUNT = 9 //!< Generic (SCSI or ACS) mount request +}; -#define USERR 1 //!< user error -#define SYERR 2 //!< system error -#define CONFERR 4 //!< configuration error +enum SMCReplyType { + MSG_ERR = 1, + MSG_DATA = 2, + RMC_RC = 3 +}; -// Request types - -#define RMC_GETGEOM 1 //!< Get robot geometry -#define RMC_FINDCART 2 //!< Find cartridge(s) -#define RMC_READELEM 3 //!< Read element status -#define RMC_MOUNT 4 //!< Mount request -#define RMC_UNMOUNT 5 //!< Unmount request -#define RMC_EXPORT 6 //!< Export tape request -#define RMC_IMPORT 7 //!< Import tape request -#define RMC_GENERICMOUNT 8 //!< Generic (SCSI or ACS) mount request -#define RMC_GENERICUNMOUNT 9 //!< Generic (SCSI or ACS) mount request - -// SCSI media changer server reply types - -#define MSG_ERR 1 -#define MSG_DATA 2 -#define RMC_RC 3 - -// SCSI media changer server messages - -#define RMC00 "RMC00 - SCSI media changer server not available on %s\n" -#define RMC01 "RMC01 - robot parameter is mandatory\n" -#define RMC02 "RMC02 - %s error : %s\n" -#define RMC03 "RMC03 - illegal function %d\n" -#define RMC04 "RMC04 - error getting request, netread = %d\n" -#define RMC05 "RMC05 - cannot allocate enough memory\n" -#define RMC06 "RMC06 - invalid value for %s\n" -#define RMC09 "RMC09 - fatal configuration error: %s %s\n" -#define RMC46 "RMC46 - request too large (max. %d)\n" -#define RMC92 "RMC92 - %s request by %d,%d from %s\n" -#define RMC98 "RMC98 - %s\n" +//! SCSI media changer server messages +constexpr const char* RMC00 = "RMC00 - SCSI media changer server not available on %s\n"; +constexpr const char* RMC01 = "RMC01 - robot parameter is mandatory\n"; +constexpr const char* RMC02 = "RMC02 - %s error : %s\n"; +constexpr const char* RMC03 = "RMC03 - illegal function %d\n"; +constexpr const char* RMC04 = "RMC04 - error getting request, netread = %d\n"; +constexpr const char* RMC05 = "RMC05 - cannot allocate enough memory\n"; +constexpr const char* RMC06 = "RMC06 - invalid value for %s\n"; +constexpr const char* RMC09 = "RMC09 - fatal configuration error: %s %s\n"; +constexpr const char* RMC46 = "RMC46 - request too large (max. %d)\n"; +constexpr const char* RMC92 = "RMC92 - %s request by %d,%d from %s\n"; +constexpr const char* RMC98 = "RMC98 - %s\n"; diff --git a/mediachanger/rmcd/rmc_marshall_element.cpp b/mediachanger/rmcd/rmc_marshall_element.cpp index 3ace5dcb891e293b1230af30430e6b13851b3a5d..39c81cf40b9a7fb4a2ced32d6a07514632c3f4b2 100644 --- a/mediachanger/rmcd/rmc_marshall_element.cpp +++ b/mediachanger/rmcd/rmc_marshall_element.cpp @@ -21,13 +21,13 @@ int rmc_marshall_element(char** const sbpp, const struct smc_element_info* const element_info) { char* sbp = *sbpp; - marshall_WORD(sbp, element_info->element_address); + marshall_SHORT(sbp, element_info->element_address); marshall_BYTE(sbp, element_info->element_type); marshall_BYTE(sbp, element_info->state); marshall_BYTE(sbp, element_info->asc); marshall_BYTE(sbp, element_info->ascq); marshall_BYTE(sbp, element_info->flags); - marshall_WORD(sbp, element_info->source_address); + marshall_SHORT(sbp, element_info->source_address); marshall_STRING(sbp, element_info->name); *sbpp = sbp; return 0; diff --git a/mediachanger/rmcd/rmc_procreq.cpp b/mediachanger/rmcd/rmc_procreq.cpp index 050fa1a300a6ac17c7d78fdc0db86d3e3b397a1d..02dc6fe76c5c30a976b95fcc4b82ff4568624a04 100644 --- a/mediachanger/rmcd/rmc_procreq.cpp +++ b/mediachanger/rmcd/rmc_procreq.cpp @@ -25,8 +25,6 @@ #include #include #include -#include "mediachanger/librmc/Castor_limits.hpp" -#include "mediachanger/librmc/osdep.hpp" #include "mediachanger/librmc/marshall.hpp" #include "mediachanger/librmc/serrno.hpp" #include "mediachanger/librmc/smc_struct.hpp" @@ -296,8 +294,8 @@ int rmc_srv_mount(const struct rmc_srv_rqst_context* const rqst_context) { rmc_logit(func, "returns %d\n", ERMCUNREC); return ERMCUNREC; } - unmarshall_WORD(rbp, invert); - unmarshall_WORD(rbp, drvord); + unmarshall_SHORT(rbp, invert); + unmarshall_SHORT(rbp, drvord); snprintf(logbuf, CA_MAXVIDLEN + 64, "mount %s/%d on drive %d", vid, invert, drvord); rmc_logreq(func, logbuf); @@ -433,8 +431,8 @@ int rmc_srv_unmount(const struct rmc_srv_rqst_context* const rqst_context) { rmc_logit(func, "returns %d\n", ERMCUNREC); return ERMCUNREC; } - unmarshall_WORD(rbp, drvord); - unmarshall_WORD(rbp, force); + unmarshall_SHORT(rbp, drvord); + unmarshall_SHORT(rbp, force); snprintf(logbuf, CA_MAXVIDLEN + 64, "unmount %s %d %d", vid, drvord, force); rmc_logreq(func, logbuf); diff --git a/mediachanger/rmcd/rmc_send_scsi_cmd.cpp b/mediachanger/rmcd/rmc_send_scsi_cmd.cpp index 9f9cb50eba8f1f308062c5d9386ebc8901b0d075..7937f3b3361da3e18f4fe67fecdf5624e8f1fbbe 100644 --- a/mediachanger/rmcd/rmc_send_scsi_cmd.cpp +++ b/mediachanger/rmcd/rmc_send_scsi_cmd.cpp @@ -15,16 +15,6 @@ * submit itself to any jurisdiction. */ -/* rmc_send_scsi_cmd - Send a SCSI command to a device */ -/* return -5 if not supported on this platform (serrno = SEOPNOTSUP) - * -4 if SCSI error (serrno = EIO) - * -3 if CAM error (serrno = EIO) - * -2 if ioctl fails with errno (serrno = errno) - * -1 if open/stat fails with errno (message fully formatted) - * 0 if successful with no data transfer - * >0 number of bytes transferred - */ - #include #include #include @@ -44,10 +34,10 @@ #include "scsictl.hpp" #include "rmc_send_scsi_cmd.hpp" -#define RMC_ERR_MSG_BUFSZ 132 -#define ST_DEV_BUFSZ 64 -#define SYSPATH_BUFSZ 256 -#define SGPATH_BUFSZ 80 +constexpr int RMC_ERR_MSG_BUFSZ = 132; +constexpr int ST_DEV_BUFSZ = 64; +constexpr int SYSPATH_BUFSZ = 256; +constexpr int SGPATH_BUFSZ = 80; static char rmc_err_msgbuf[RMC_ERR_MSG_BUFSZ]; static const char* sk_msg[] = { @@ -70,18 +60,6 @@ static const char* sk_msg[] = { }; static void find_sgpath(char* const sgpath, const int maj, const int min) { - /* - Find the sg device for a pair of major and minor device IDs - of a tape device. The match is done by - - . identifying the tape's st device node - . getting the device's unique ID from sysfs - . searching the sg device with the same ID (in sysfs) - - If no match is found, the returned sg path will be an empty - string. - */ - char systape[] = "/sys/class/scsi_tape"; char sysgen[] = "/sys/class/scsi_generic"; char syspath[SYSPATH_BUFSZ]; @@ -224,7 +202,7 @@ int rmc_send_scsi_cmd(const int tapefd, sg_big_buff_val - sizeof(struct sg_header) - cdblen); *msgaddr = rmc_err_msgbuf; serrno = EINVAL; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } if ((int) sizeof(struct sg_header) + cdblen + buflen > sg_bufsiz) { if (sg_bufsiz > 0) { @@ -234,7 +212,7 @@ int rmc_send_scsi_cmd(const int tapefd, serrno = errno; snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "cannot get memory"); *msgaddr = rmc_err_msgbuf; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } sg_bufsiz = sizeof(struct sg_header) + cdblen + buflen; } @@ -246,7 +224,7 @@ int rmc_send_scsi_cmd(const int tapefd, snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "path exceeds maximum length"); *msgaddr = rmc_err_msgbuf; serrno = ENOBUFS; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } } else { struct stat sbufa; @@ -257,7 +235,7 @@ int rmc_send_scsi_cmd(const int tapefd, snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "%s : stat error : %s\n", path, strerror(errno)); rmc_err_msgbuf[sizeof(rmc_err_msgbuf) - 1] = '\0'; *msgaddr = rmc_err_msgbuf; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } /* Find the first available sg device and use its major number for comparison with the provided major number. If they are the same we can use the sgpath provided directly */ @@ -290,7 +268,7 @@ int rmc_send_scsi_cmd(const int tapefd, snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "path exceeds maximum length"); *msgaddr = rmc_err_msgbuf; serrno = ENOBUFS; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } } else { /* Otherwise, look up the path using the (major,minor) device ID. If no match is found, @@ -303,14 +281,14 @@ int rmc_send_scsi_cmd(const int tapefd, snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "%s : open error : %s\n", sgpath, strerror(errno)); rmc_err_msgbuf[RMC_ERR_MSG_BUFSZ - 1] = '\0'; *msgaddr = rmc_err_msgbuf; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } } if (sg_buffer == nullptr) { serrno = EFAULT; snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "sg_buffer points to NULL"); *msgaddr = rmc_err_msgbuf; - return -1; + return RMC_SEND_SCSI_ERR_OPEN; } /* set the sg timeout (in jiffies) */ @@ -336,7 +314,7 @@ int rmc_send_scsi_cmd(const int tapefd, if (!do_not_open) { close(fd); } - return -2; + return RMC_SEND_SCSI_ERR_IOCTL; } if ((n = read(fd, sg_buffer, sizeof(struct sg_header) + ((flags & SCSI_IN) ? buflen : 0))) < 0) { *msgaddr = (char*) strerror(errno); @@ -347,7 +325,7 @@ int rmc_send_scsi_cmd(const int tapefd, if (!do_not_open) { close(fd); } - return -2; + return RMC_SEND_SCSI_ERR_IOCTL; } if (!do_not_open) { close(fd); @@ -374,14 +352,14 @@ int rmc_send_scsi_cmd(const int tapefd, snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "%s : scsi error : %s\n", sgpath, tmp_msgbuf); rmc_err_msgbuf[sizeof(rmc_err_msgbuf) - 1] = '\0'; *msgaddr = rmc_err_msgbuf; - return -4; + return RMC_SEND_SCSI_ERR_SCSI; } else if (sg_hd->result) { *msgaddr = (char*) strerror(sg_hd->result); serrno = sg_hd->result; snprintf(rmc_err_msgbuf, RMC_ERR_MSG_BUFSZ, "%s : read error : %s\n", sgpath, *msgaddr); rmc_err_msgbuf[sizeof(rmc_err_msgbuf) - 1] = '\0'; *msgaddr = rmc_err_msgbuf; - return -2; + return RMC_SEND_SCSI_ERR_IOCTL; } if (n) { n -= sizeof(struct sg_header) + resid; diff --git a/mediachanger/rmcd/rmc_send_scsi_cmd.hpp b/mediachanger/rmcd/rmc_send_scsi_cmd.hpp index 3d379364fcf77a10a824b892d1a591ba2ffcf908..72d62746f916289ae7d79167ed4ece45b6ece69f 100644 --- a/mediachanger/rmcd/rmc_send_scsi_cmd.hpp +++ b/mediachanger/rmcd/rmc_send_scsi_cmd.hpp @@ -17,6 +17,28 @@ #pragma once +enum RMCSendScsiCmdReturn { + // Return value >= 0 is number of bytes transferred + RMC_SEND_SCSI_ERR_OPEN = -1, //!< Open/stat fails with errno (message fully formatted) + RMC_SEND_SCSI_ERR_IOCTL = -2, //!< ioctl fails with errno (serrno = errno) + RMC_SEND_SCSI_ERR_CAM = -3, //!< CAM error (serrno = EIO) + RMC_SEND_SCSI_ERR_SCSI = -4, //!< SCSI error (serrno = EIO) + RMC_SEND_SCSI_ERR_NOTSUP = -5, //!< Not supported on this platform (serrno = SEOPNOTSUP) +}; + +/** + * Send a SCSI command to a device + * + * Finds the sg device for the (major,minor) device IDs of a tape device. + * + * The match is done by: + * + * . identifying the tape's st device node + * . getting the device's unique ID from sysfs + * . searching the sg device with the same ID (in sysfs) + * + * If no match is found, the returned sg path will be an empty string. + */ int rmc_send_scsi_cmd(const int tapefd, const char* const path, const int do_not_open, diff --git a/mediachanger/rmcd/rmc_serv.cpp b/mediachanger/rmcd/rmc_serv.cpp index f801168b7ef22be28f76d5bbf6d99e7bd50bb2a5..1a2017f3c99a05c3133edc17b1933a9c7061ab3f 100644 --- a/mediachanger/rmcd/rmc_serv.cpp +++ b/mediachanger/rmcd/rmc_serv.cpp @@ -33,12 +33,12 @@ #include #include "mediachanger/librmc/smc_struct.hpp" +#include "mediachanger/librmc/Cnetdb.hpp" #include "mediachanger/librmc/Cdomainname.hpp" #include "mediachanger/librmc/net.hpp" #include "mediachanger/librmc/getconfent.hpp" #include "mediachanger/librmc/marshall.hpp" #include "mediachanger/librmc/serrno.hpp" -#include "mediachanger/librmc/osdep.hpp" #include "rmc_logit.hpp" #include "rmc_constants.hpp" #include "rmc_smcsubr.hpp" @@ -46,8 +46,6 @@ #include "Cinit.hpp" #include "rmc_procreq.hpp" -#define PATH_CONF "/etc/cta/cta-rmcd.conf" - /* Forward declaration */ static int rmc_getreq(const int s, int* const req_type, char* const req_data, char** const clienthost); static void rmc_procreq(const int rpfd, const int req_type, char* const req_data, char* const clienthost); @@ -175,7 +173,7 @@ int rmc_main(const char* const robot) { const char* p; p = getenv("RMC_PORT"); if (!p) { - p = getconfent_fromfile(PATH_CONF, "RMC", "PORT", 0); + p = getconfent_fromfile("RMC", "PORT", 0); } if (p) { diff --git a/mediachanger/rmcd/rmc_smcsubr.cpp b/mediachanger/rmcd/rmc_smcsubr.cpp index 627034037987fe5d0dc5b981912b96d2bfece057..31bb271a4ea9751e348c9be5928633acb064f41a 100644 --- a/mediachanger/rmcd/rmc_smcsubr.cpp +++ b/mediachanger/rmcd/rmc_smcsubr.cpp @@ -34,8 +34,8 @@ #include "smc_constants.hpp" #include "rmc_smcsubr.hpp" -#define RBT_XTRA_PROC 10 -#define ERR_MSG_BUFSZ 132 +constexpr int RBT_XTRA_PROC = 10; +constexpr int ERR_MSG_BUFSZ = 132; static struct smc_status smc_status; static const char* smc_msgaddr; diff --git a/mediachanger/rmcd/scsictl.hpp b/mediachanger/rmcd/scsictl.hpp index 7b071f198268f3b9ebdf036b36f30aa81e0ab993..ec227bbee2488e1b59d454f48af20ae2fba45b32 100644 --- a/mediachanger/rmcd/scsictl.hpp +++ b/mediachanger/rmcd/scsictl.hpp @@ -17,64 +17,15 @@ #pragma once -#define MAXSENSE 255 +constexpr int MAXSENSE = 255; -// Values of the 'flags' field for function send_cmd -#define SCSI_IN 1 -#define SCSI_OUT 2 -#define SCSI_IN_OUT 4 -#define SCSI_NONE 8 -#define SCSI_SEL_WITH_ATN 16 -#define SCSI_SYNC 32 -#define SCSI_WIDE 64 - -// SCSI status values -#define SCSI_STATUS_GOOD 0x00 -#define SCSI_STATUS_CHECK_CONDITION 0x02 -#define SCSI_STATUS_CONDITION_MET_GOOD 0x04 -#define SCSI_STATUS_BUSY 0x08 -#define SCSI_STATUS_INTERMEDIATE_GOOD 0x10 -#define SCSI_STATUS_INTERMEDIATE_CONDITION_MET 0x14 -#define SCSI_STATUS_RESERVATION_CONFLICT 0x18 -#define SCSI_STATUS_COMMAND_TERMINATED 0x22 -#define SCSI_STATUS_QUEUE_FULL 0x28 - -// Generic SCSI driver status -#define CAM_OK 0 //!< No error at the CAM level -#define CAM_TIMEOUT 1 //!< Command timeout -#define CAM_ERROR 2 //!< Error at the CAM level -#define CAM_NODEVICE 3 //!< Device doesn't respond (inexistant device) - -// SCSI 3 Sense key -#define SCSI_SENSEKEY_NO_SENSE 0 -#define SCSI_SENSEKEY_RECOVERED_ERROR 1 -#define SCSI_SENSEKEY_NOT_READY 2 -#define SCSI_SENSEKEY_MEDIUM_ERROR 3 -#define SCSI_SENSEKEY_HARDWARE_ERROR 4 -#define SCSI_SENSEKEY_ILLEGAL_REQUEST 5 -#define SCSI_SENSEKEY_UNIT_ATTENTION 6 -#define SCSI_SENSEKEY_DATA_PROTECT 7 -#define SCSI_SENSEKEY_BLANK_CHECK 8 -#define SCSI_SENSEKEY_VENDOR_SPECIFIC 9 -#define SCSI_SENSEKEY_COPY_ABORTED 10 -#define SCSI_SENSEKEY_ABORTED_COMMAND 11 -#define SCSI_SENSEKEY_EQUAL 12 -#define SCSI_SENSEKEY_VOLUME_OVERFLOW 13 -#define SCSI_SENSEKEY_MISCOMPARE 14 -#define SCSI_SENSEKEY_RESERVED 15 - -// SCSI 3 Peripheric device types -#define SCSI_PERIPH_DIRECT_ACCESS 0 -#define SCSI_PERIPH_SEQUENTIAL_ACCESS 1 -#define SCSI_PERIPH_PRINTER 2 -#define SCSI_PERIPH_PROCESSOR 3 -#define SCSI_PERIPH_WORM 4 -#define SCSI_PERIPH_CDROM 5 -#define SCSI_PERIPH_SCANNER 6 -#define SCSI_PERIPH_OPTICAL 7 -#define SCSI_PERIPH_AUTOCHANGER 8 -#define SCSI_PERIPH_COMMUNICATION 9 -#define SCSI_PERIPH_ASC1 10 -#define SCSI_PERIPH_ASC2 11 -#define SCSI_PERIPH_RAID 12 -#define SCSI_PERIPH_UNKNOWN 31 +// Value of the 'flags' field for send_cmd function +enum SendCmdFlags { + SCSI_IN = 1, + SCSI_OUT = 2, + SCSI_IN_OUT = 4, + SCSI_NONE = 8, + SCSI_SEL_WITH_ATN = 16, + SCSI_SYNC = 32, + SCSI_WIDE = 64 +}; diff --git a/mediachanger/smc/rmc_api.hpp b/mediachanger/smc/rmc_api.hpp index 4964eb1db3db04eaa5f7deb9a53435efeb291504..fdaba9e9686fbfee6413c6cb4d4b4f15806626b5 100644 --- a/mediachanger/smc/rmc_api.hpp +++ b/mediachanger/smc/rmc_api.hpp @@ -19,8 +19,6 @@ #include "mediachanger/librmc/smc_struct.hpp" #include "mediachanger/rmcd/rmc_constants.hpp" -#include "mediachanger/rmcd/smc_constants.hpp" -#include "mediachanger/rmcd/rbtsubr_constants.hpp" int rmc_dismount(const char* const server, const char* const vid, const int drvord, const int force); diff --git a/mediachanger/smc/rmc_dismount.cpp b/mediachanger/smc/rmc_dismount.cpp index f84d561b31c4faa1732108ce9512aa624550a2ad..1d68f46f9cbb8ac7786ebdcf573234a97b9925f4 100644 --- a/mediachanger/smc/rmc_dismount.cpp +++ b/mediachanger/smc/rmc_dismount.cpp @@ -53,8 +53,8 @@ int rmc_dismount(const char* const server, const char* const vid, const int drvo 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); + marshall_SHORT(sbp, drvord); + marshall_SHORT(sbp, force); msglen = sbp - sendbuf; marshall_LONG(q, msglen); /* update length field */ diff --git a/mediachanger/smc/rmc_find_cartridge.cpp b/mediachanger/smc/rmc_find_cartridge.cpp index 55ccc854117a6befeea3f31a4a7772ac957e4554..c075b812920e9d4890ffd005695b5b790645559c 100644 --- a/mediachanger/smc/rmc_find_cartridge.cpp +++ b/mediachanger/smc/rmc_find_cartridge.cpp @@ -74,13 +74,13 @@ int rmc_find_cartridge(const char* const server, rbp = repbuf; unmarshall_LONG(rbp, c); for (i = 0, elemp = element_info; i < c; i++, elemp++) { - unmarshall_WORD(rbp, elemp->element_address); + unmarshall_SHORT(rbp, elemp->element_address); unmarshall_BYTE(rbp, elemp->element_type); unmarshall_BYTE(rbp, elemp->state); unmarshall_BYTE(rbp, elemp->asc); unmarshall_BYTE(rbp, elemp->ascq); unmarshall_BYTE(rbp, elemp->flags); - unmarshall_WORD(rbp, elemp->source_address); + unmarshall_SHORT(rbp, elemp->source_address); unmarshall_STRING(rbp, elemp->name); } } diff --git a/mediachanger/smc/rmc_mount.cpp b/mediachanger/smc/rmc_mount.cpp index eeae7bb2a405eeadfcdf5ee1c4323fb692a69ab3..70f1d56fad169236369855633c2e77494523bfc9 100644 --- a/mediachanger/smc/rmc_mount.cpp +++ b/mediachanger/smc/rmc_mount.cpp @@ -53,8 +53,8 @@ int rmc_mount(const char* const server, const char* const vid, const int side, c marshall_LONG(sbp, gid); marshall_STRING(sbp, ""); /* loader field is no longer used */ marshall_STRING(sbp, vid); - marshall_WORD(sbp, side); - marshall_WORD(sbp, drvord); + marshall_SHORT(sbp, side); + marshall_SHORT(sbp, drvord); msglen = sbp - sendbuf; marshall_LONG(q, msglen); /* update length field */ diff --git a/mediachanger/smc/rmc_read_elem_status.cpp b/mediachanger/smc/rmc_read_elem_status.cpp index 43dfeb99d8bd81763394402b34ddae9c44f2e48f..181ae313ded61a11857a8feda38de293bcd336f2 100644 --- a/mediachanger/smc/rmc_read_elem_status.cpp +++ b/mediachanger/smc/rmc_read_elem_status.cpp @@ -73,13 +73,13 @@ int rmc_read_elem_status(const char* const server, rbp = repbuf; unmarshall_LONG(rbp, c); for (i = 0, elemp = element_info; i < c; i++, elemp++) { - unmarshall_WORD(rbp, elemp->element_address); + unmarshall_SHORT(rbp, elemp->element_address); unmarshall_BYTE(rbp, elemp->element_type); unmarshall_BYTE(rbp, elemp->state); unmarshall_BYTE(rbp, elemp->asc); unmarshall_BYTE(rbp, elemp->ascq); unmarshall_BYTE(rbp, elemp->flags); - unmarshall_WORD(rbp, elemp->source_address); + unmarshall_SHORT(rbp, elemp->source_address); unmarshall_STRING(rbp, elemp->name); } } diff --git a/mediachanger/smc/send2rmc.cpp b/mediachanger/smc/send2rmc.cpp index 14f61e7a053d4a7771c2d4fab157d62b78d68b75..ebcd248a7a66c623ff521df046b38a00211f4e5e 100644 --- a/mediachanger/smc/send2rmc.cpp +++ b/mediachanger/smc/send2rmc.cpp @@ -30,8 +30,6 @@ #include "mediachanger/librmc/marshall.hpp" #include "rmc_api.hpp" -#define PATH_CONF "/etc/cta/cta-rmcd.conf" - /* send2tpd - send a request to the SCSI media changer server and wait for the reply */ int send2rmc(const char* const host, @@ -56,7 +54,7 @@ int send2rmc(const char* const host, sin.sin_family = AF_INET; p = getenv("RMC_PORT"); if (!p) { - p = getconfent_fromfile(PATH_CONF, "RMC", "PORT", 0); + p = getconfent_fromfile("RMC", "PORT", 0); } if (p) { @@ -103,7 +101,7 @@ int send2rmc(const char* const host, if ((n = netwrite(s, reqp, reql)) <= 0) { if (n == 0) { - rmc_errmsg(func, RMC02, "send", sys_serrlist[SERRNO]); + rmc_errmsg(func, RMC02, "send", sys_serrlist[serrno-SEBASEOFF]); } else { rmc_errmsg(func, RMC02, "send", neterror()); } @@ -122,7 +120,7 @@ int send2rmc(const char* const host, while (1) { if ((n = netread(s, repbuf, 3 * LONGSIZE)) <= 0) { if (n == 0) { - rmc_errmsg(func, RMC02, "recv", sys_serrlist[SERRNO]); + rmc_errmsg(func, RMC02, "recv", sys_serrlist[serrno-SEBASEOFF]); } else { rmc_errmsg(func, RMC02, "recv", neterror()); } @@ -144,7 +142,7 @@ int send2rmc(const char* const host, } if ((n = netread(s, repbuf, c)) <= 0) { if (n == 0) { - rmc_errmsg(func, RMC02, "recv", sys_serrlist[SERRNO]); + rmc_errmsg(func, RMC02, "recv", sys_serrlist[serrno-SEBASEOFF]); } else { rmc_errmsg(func, RMC02, "recv", neterror()); } diff --git a/mediachanger/smc/smc.cpp b/mediachanger/smc/smc.cpp index 9dce2f532f44daf4dd2304dbf2dc15ff99e6d992..b6571453fbbbe136ef435795bf1012db05923428 100644 --- a/mediachanger/smc/smc.cpp +++ b/mediachanger/smc/smc.cpp @@ -22,21 +22,22 @@ #include #include #include +#include #include "mediachanger/librmc/spectra_like_libs.hpp" #include "mediachanger/librmc/serrno.hpp" -//#include "rbtsubr_constants.hpp" -//#include "smc_constants.hpp" -//#include "getconfent.hpp" +#include "mediachanger/rmcd/rmc_constants.hpp" +#include "mediachanger/rmcd/rbtsubr_constants.hpp" +#include "mediachanger/rmcd/smc_constants.hpp" #include "rmc_api.hpp" -#include -/* exit codes */ +extern char* optarg; -#define USERR 1 -#define TEXT_RED "\x1b[31;1m" -#define TEXT_NORMAL "\x1b[0m" +void printf_red(const char* str) { + constexpr const char* TEXT_RED = "\x1b[31;1m"; + constexpr const char* TEXT_NORMAL = "\x1b[0m"; -extern char* optarg; + printf("%s%s%s\n", TEXT_RED, str, TEXT_NORMAL); +} static void smc_str_upper(char* const s) { char* c = nullptr; @@ -75,7 +76,7 @@ void smc_qdrive_humanPrint(const struct robot_info* const robot_info, const int useSpectraLib) { const char* pstatus; int i; - printf(TEXT_RED "Drive Ordinal\tElement Addr.\t Status Vid" TEXT_NORMAL "\n"); + printf_red("Drive Ordinal\tElement Addr.\t Status Vid"); for (i = 0; i < numberOfElements; i++) { if (((element_info + i)->state & 0x1) == 0) { pstatus = "free"; @@ -201,7 +202,7 @@ static int smc_qlib(const struct robot_info* const robot_info, const int isJsonE void smc_qport_humanPrint(const struct smc_element_info* const element_info, const int numberOfElements) { const char* pstatus; int i; - printf(TEXT_RED "Element Addr.\tVid\tImpExp" TEXT_NORMAL "\n"); + printf_red("Element Addr.\tVid\tImpExp"); for (i = 0; i < numberOfElements; i++) { if (((element_info + i)->state & 0x1) == 0) { pstatus = ""; @@ -266,7 +267,7 @@ smc_qport(const char* const rmchost, const int fd, const struct robot_info* cons void smc_qslot_humanPrint(const struct smc_element_info* element_info, const int numberOfElements) { int i; - printf(TEXT_RED "Element Addr.\tVid" TEXT_NORMAL "\n"); + printf_red("Element Addr.\tVid"); for (i = 0; i < numberOfElements; i++) { printf(" %4d\t%s\n", element_info[i].element_address, element_info[i].name); } @@ -328,7 +329,7 @@ void smc_qvid_humanPrint(const struct smc_element_info* const element_info, cons int i; const char* ptype; char ptypes[5][6] = {"", "hand", "slot", "port", "drive"}; - printf(TEXT_RED "Vid\tElement Addr.\tElement Type" TEXT_NORMAL "\n"); + printf_red("Vid\tElement Addr.\tElement Type"); for (i = 0; i < numberOfElements; i++) { ptype = ptypes[(element_info + i)->element_type]; if ((element_info + i)->element_type == 3) {