Commit 83dfd422 authored by Steven Murray's avatar Steven Murray
Browse files

Skeleton version of castor-tape-mount no compiles

parent 76ea646b
......@@ -38,6 +38,7 @@ castor/tape/rechandler/rechandlerd
castor/tape/rmc/castor-tape-acs-dismount
castor/tape/rmc/castor-tape-acs-mount
castor/tape/rmc/castor-tape-acs-queryvolume
castor/tape/rmc/castor-tape-mount
castor/tape/tapebridge/tapebridged
castor/tape/tapegateway/tapegatewayd
castor/tape/tpcp/dumptp
......
......@@ -32,8 +32,7 @@
//------------------------------------------------------------------------------
castor::tape::rmc::AcsCmd::AcsCmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream, Acs &acs) throw():
m_in(inStream), m_out(outStream), m_err(errStream), m_acs(acs),
m_debugBuf(outStream), m_dbg(&m_debugBuf) {
Cmd(inStream, outStream, errStream), m_acs(acs) {
}
//------------------------------------------------------------------------------
......@@ -45,25 +44,9 @@ castor::tape::rmc::AcsCmd::~AcsCmd() throw() {
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::AcsCmd::bool2Str(bool &value) const
std::string castor::tape::rmc::AcsCmd::bool2Str(const BOOLEAN value) const
throw() {
if(value) {
return "TRUE";
} else {
return "FALSE";
}
}
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::AcsCmd::bool2Str(BOOLEAN &value) const
throw() {
if(value) {
return "TRUE";
} else {
return "FALSE";
}
return value ? "TRUE" : "FALSE";
}
//------------------------------------------------------------------------------
......
......@@ -29,7 +29,7 @@
#include "castor/exception/Mismatch.hpp"
#include "castor/exception/RequestFailed.hpp"
#include "castor/tape/rmc/Acs.hpp"
#include "castor/tape/rmc/DebugBuf.hpp"
#include "castor/tape/rmc/Cmd.hpp"
#include <istream>
#include <ostream>
......@@ -48,7 +48,7 @@ namespace rmc {
* Abstract class implementing common code and data structures for command-line
* tools that interact with ACLS compatible tape libraries.
*/
class AcsCmd {
class AcsCmd: public Cmd {
public:
/**
* Constructor.
......@@ -68,49 +68,17 @@ public:
protected:
/**
* Standard input stream.
*/
std::istream &m_in;
/**
* Standard output stream.
*/
std::ostream &m_out;
/**
* Standard error stream.
*/
std::ostream &m_err;
/**
* Wrapper around the ACSLS C-API.
*/
Acs &m_acs;
/**
* Debug stream buffer that inserts a standard debug preamble before each
* message-line written to it.
*/
DebugBuf m_debugBuf;
/**
* Stream used to write debug messages.
*
* This stream will insert a standard debug preamble before each message-line
* written to it.
*/
std::ostream m_dbg;
/**
* Returns the string representation of the specfied boolean value.
*/
std::string bool2Str(bool &value) const throw();
/**
* Returns the string representation of the specfied boolean value.
*
* @param value The boolean value.
*/
std::string bool2Str(BOOLEAN &value) const throw();
std::string bool2Str(const BOOLEAN value) const throw();
/**
* Requests responses from ACSLS in a loop until the RT_FINAL response is
......
/******************************************************************************
* castor/tape/rmc/Cmd.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, 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.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/tape/rmc/Cmd.hpp"
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::tape::rmc::Cmd::Cmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream) throw():
m_in(inStream), m_out(outStream), m_err(errStream), m_debugBuf(outStream),
m_dbg(&m_debugBuf) {
}
//------------------------------------------------------------------------------
// destructor
//------------------------------------------------------------------------------
castor::tape::rmc::Cmd::~Cmd() throw() {
}
//------------------------------------------------------------------------------
// bool2Str
//------------------------------------------------------------------------------
std::string castor::tape::rmc::Cmd::bool2Str(const bool value) const throw() {
return value ? "TRUE" : "FALSE";
}
/******************************************************************************
* castor/tape/rmc/Cmd.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, 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.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#ifndef CASTOR_TAPE_RMC_CMD_HPP
#define CASTOR_TAPE_RMC_CMD_HPP 1
#include "castor/tape/rmc/DebugBuf.hpp"
#include <istream>
#include <ostream>
#include <string>
namespace castor {
namespace tape {
namespace rmc {
/**
* Abstract class implementing common code and data structures for a
* command-line tool.
*/
class Cmd {
public:
/**
* Constructor.
*
* @param inStream Standard input stream.
* @param outStream Standard output stream.
* @param errStream Standard error stream.
*/
Cmd(std::istream &inStream, std::ostream &outStream, std::ostream &errStream)
throw();
/**
* Pure-virtual destructor to guarantee this class is abstract.
*/
virtual ~Cmd() throw() = 0;
protected:
/**
* Standard input stream.
*/
std::istream &m_in;
/**
* Standard output stream.
*/
std::ostream &m_out;
/**
* Standard error stream.
*/
std::ostream &m_err;
/**
* Debug stream buffer that inserts a standard debug preamble before each
* message-line written to it.
*/
DebugBuf m_debugBuf;
/**
* Stream used to write debug messages.
*
* This stream will insert a standard debug preamble before each message-line
* written to it.
*/
std::ostream m_dbg;
/**
* Returns the string representation of the specfied boolean value.
*
* @param value The boolean value.
*/
std::string bool2Str(const bool value) const throw();
}; // class Cmd
} // namespace rmc
} // namespace tape
} // namespace castor
#endif // CASTOR_TAPE_RMC_CMD_HPP
......@@ -33,7 +33,7 @@
//------------------------------------------------------------------------------
castor::tape::rmc::MountCmd::MountCmd(std::istream &inStream,
std::ostream &outStream, std::ostream &errStream) throw():
m_defaultTimeout(600) {
Cmd(inStream, outStream, errStream), m_defaultTimeout(600) {
}
//------------------------------------------------------------------------------
......@@ -106,9 +106,6 @@ castor::tape::rmc::MountCmdLine castor::tape::rmc::MountCmd::parseCmdLine(
MountCmdLine cmdLine;
char c;
// Set the query option to the default value
cmdLine.queryInterval = m_defaultQueryInterval;
// Set timeout option to the default value
cmdLine.timeout = m_defaultTimeout;
......@@ -125,7 +122,7 @@ castor::tape::rmc::MountCmdLine castor::tape::rmc::MountCmd::parseCmdLine(
cmdLine.help = true;
break;
case 'r':
cmdLine.readOnly = TRUE;
cmdLine.readOnly = true;
break;
case 't':
cmdLine.timeout = atoi(optarg);
......
......@@ -28,7 +28,7 @@
#include "castor/exception/Internal.hpp"
#include "castor/exception/InvalidArgument.hpp"
#include "castor/exception/MissingOperand.hpp"
#include "castor/exception/MountFailed.hpp"
#include "castor/tape/rmc/Cmd.hpp"
#include "castor/tape/rmc/MountCmdLine.hpp"
#include <stdint.h>
......@@ -40,7 +40,7 @@ namespace rmc {
/**
* The class implementing the mount command.
*/
class MountCmd {
class MountCmd: public Cmd {
public:
/**
......@@ -101,6 +101,7 @@ private:
* success or failure.
*/
const int m_defaultTimeout;
}; // class MountCmd
} // namespace rmc
......
/******************************************************************************
* castor/tape/rmc/MountCmdLine.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, 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.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*
*
* @author Steven.Murray@cern.ch
*****************************************************************************/
#include "castor/tape/rmc/MountCmdLine.hpp"
//-----------------------------------------------------------------------------
// constructor
//-----------------------------------------------------------------------------
castor::tape::rmc::MountCmdLine::MountCmdLine() throw():
debug(false),
help(false),
readOnly(false),
timeout(0) {
}
......@@ -38,7 +38,7 @@ struct MountCmdLine {
/**
* Constructor.
*
* Initialises all BOOLEAN member-variables to FALSE, all integer
* Initialises all bool member-variables to false, all integer
* member-variables to 0 and the volume identifier to an empty string.
*/
MountCmdLine() throw();
......@@ -56,7 +56,7 @@ struct MountCmdLine {
/**
* True if the tape is to be mount for read-only access.
*/
BOOLEAN readOnly;
bool readOnly;
/**
* Time in seconds to wait for the mount to conclude.
......
......@@ -31,7 +31,6 @@
//------------------------------------------------------------------------------
int main(const int argc, char *const *const argv) {
castor::tape::rmc::AcsImpl acs;
castor::tape::rmc::MountCmd cmd(std::cin, std::cout, std::cerr);
return cmd.main(argc, argv);
......
......@@ -154,6 +154,7 @@ debian/castor/usr/share/man/man3/rmc_find_cartridge.3castor.gz
debian/castor/usr/share/man/man3/rmc_get_geometry.3castor.gz
debian/castor/usr/share/man/man3/rmc_import.3castor.gz
debian/castor/usr/share/man/man3/rmc_mount.3castor.gz
debian/castor/usr/share/man/man3/rmc_mnt.3castor.gz
debian/castor/usr/share/man/man3/rmc_read_elem_status.3castor.gz
debian/castor/usr/share/man/man3/rmc_seterrbuf.3castor.gz
debian/castor/usr/share/man/man3/rwndtape.3castor.gz
......
%attr(6755,root,root) usr/bin/castor-tape-mount
%attr(6755,root,root) usr/bin/smc
debian/castor/usr/share/man/man1/castor-tape-mount.1castor.gz
debian/castor/usr/share/man/man1/smc.1castor.gz
......@@ -61,7 +61,7 @@ int rmc_mnt(
case RMC_LOADER_TYPE_SMC:
return rmc_smc_mnt(server, vid, drive);
default:
errno = ERMCUNREC;
errno = ERMCUKNLDRTYPE; /* Unknown loader type */
serrno = errno;
return -1;
}
......@@ -88,25 +88,29 @@ static int rmc_acs_mnt(
char rmc_host[CA_MAXHOSTNAMELEN+1];
struct rmc_acs_drive_id drive_id = {0, 0, 0, 0};
/* Consider the function arguments invalid if the total size of the */
/* request message would be greater than RMC_REQBUFSZ */
if(msglen > RMC_REQBUFSZ) {
errno = ERMCUNREC;
if(CA_MAXVIDLEN < strlen(vid)) {
errno = ERMCVIDTOOLONG; /* VID is too long */
serrno = errno;
return -1;
}
if(CA_MAXVIDLEN < strlen(vid)) {
errno = ERMCUNREC;
if(rmc_get_rmc_host_of_drive(drive, rmc_host, sizeof(rmc_host))) {
errno = ERMCPARSERMCHOST; /* Failed to parse RMC host */
serrno = errno;
return -1;
}
if(rmc_get_rmc_host_of_drive(drive, rmc_host, sizeof(rmc_host))) {
if(rmc_get_acs_drive_id(drive, &drive_id)) {
errno = ERMCPARSEACSDRV; /* Failed to parse ACS drive id */
serrno = errno;
return -1;
}
if(rmc_get_acs_drive_id(drive, &drive_id)) {
/* It is an internal error if the total size of the request message */
/* would be greater than RMC_REQBUFSZ */
if(msglen > RMC_REQBUFSZ) {
errno = SEINTERNAL;
serrno = errno;
return -1;
}
......
......@@ -48,12 +48,12 @@ mount, or -1 if the operation failed. In the latter case,
.B serrno
is set appropriately.
.SH ERRORS
.TP 1.2i
.TP 1.8i
.B SECOMERR
Communication error.
.TP
.B ERMCUNREC
Unknown host or invalid drive or vid too long or requester does not have
Unknown host or invalid drive or requester does not have
TP_SYSTEM privilege in the Cupv database.
.TP
.B ERMCFASTR
......@@ -61,6 +61,21 @@ Unit attention.
.TP
.B ERMCOMSGR
Hardware error or Medium Removal Prevented.
.TP
.B ERMCUKNLDRTYPE
Unknown loader type.
.TP
.B ERMCVIDTOOLONG
VID is too long.
.TP
.B ERMCPARSERMCHOST
Failed to parse RMC host.
.TP
.B ERMCPARSEACSDRV
Failed to parse ACS drive id.
.TP
.B SEINTERNAL
Internal error.
.SH SEE ALSO
.BR Cupvlist(1) ,
.SH AUTHOR
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment