Commit b38715e6 authored by Steven Murray's avatar Steven Murray
Browse files

Deleted mediachanger dir from castor dir

parent e506b2ac
......@@ -18,13 +18,16 @@
*
*
*
*
* @author Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/messages/AcsProxy.hpp"
#pragma once
namespace cta {
const int CA_MAXVIDLEN = 6; // maximum length for a VID
} // namespace cta
//-----------------------------------------------------------------------------
// destructor
//-----------------------------------------------------------------------------
castor::messages::AcsProxy::~AcsProxy() {
}
......@@ -60,16 +60,16 @@ set (MEDIACHANGER_LIB_SRC_FILES
ZmqSocketMT.cpp
ZmqSocketST.cpp)
add_library (ctamediachanger2 SHARED
add_library (ctamediachanger SHARED
${MEDIACHANGER_LIB_SRC_FILES})
target_link_libraries (ctamediachanger2
target_link_libraries (ctamediachanger
ctacommon
protobuf
ssl
zmq)
install (TARGETS ctamediachanger2 DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
install (TARGETS ctamediachanger DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
set (MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES
AcsLibrarySlotTest.cpp
......@@ -83,37 +83,37 @@ set (MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES
MountCmdLineTest.cpp
ScsiLibrarySlotTest.cpp)
add_library (ctamediachangerunittests2 SHARED
add_library (ctamediachangerunittests SHARED
${MEDIACHANGER_UNIT_TESTS_LIB_SRC_FILES})
target_link_libraries (ctamediachangerunittests2
ctamediachanger2)
target_link_libraries (ctamediachangerunittests
ctamediachanger)
install (TARGETS ctamediachangerunittests2 DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
install (TARGETS ctamediachangerunittests DESTINATION usr/${CMAKE_INSTALL_LIBDIR})
set (MEDIA_CHANGER_MOUNT_SRC_FILES
MountCmd.cpp
MountCmdLine.cpp
MountCmdMain.cpp)
add_executable (cta-mediachanger-mount2 ${MEDIA_CHANGER_MOUNT_SRC_FILES})
set_target_properties (cta-mediachanger-mount2 PROPERTIES
add_executable (cta-mediachanger-mount ${MEDIA_CHANGER_MOUNT_SRC_FILES})
set_target_properties (cta-mediachanger-mount PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
target_link_libraries (cta-mediachanger-mount2
target_link_libraries (cta-mediachanger-mount
ctacommon
ctamediachanger2)
install (TARGETS cta-mediachanger-mount2 DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-mount2.1cta DESTINATION /usr/share/man/man1)
ctamediachanger)
install (TARGETS cta-mediachanger-mount DESTINATION /usr/bin)
install (FILES ${CMAKE_CURRENT_SOURCE_DIR}/cta-mediachanger-mount.1cta DESTINATION /usr/share/man/man1)
set (MEDIA_CHANGER_DISMOUNT_SRC_FILES
DismountCmd.cpp
DismountCmdLine.cpp
DismountCmdMain.cpp)
add_executable (cta-mediachanger-dismount2
add_executable (cta-mediachanger-dismount
${MEDIA_CHANGER_DISMOUNT_SRC_FILES})
set_target_properties (cta-mediachanger-dismount2 PROPERTIES
set_target_properties (cta-mediachanger-dismount PROPERTIES
COMPILE_FLAGS -I/usr/include/CDK
COMPILE_DEFINITIONS LINUX)
target_link_libraries (cta-mediachanger-dismount2
target_link_libraries (cta-mediachanger-dismount
ctacommon
ctamediachanger2)
ctamediachanger)
......@@ -34,8 +34,6 @@ const size_t HOSTNAMEBUFLEN = 256;
const int LISTENBACKLOG = 2;
const size_t SERVICENAMEBUFLEN = 256;
const int CA_MAXVIDLEN = 6; // maximum length for a VID
enum ProtocolType {
PROTOCOL_TYPE_NONE,
PROTOCOL_TYPE_TAPE
......
......@@ -23,7 +23,7 @@
#pragma once
#include "mediachanger/Constants.hpp"
#include "common/Constants.hpp"
#include <stdint.h>
......
......@@ -23,7 +23,7 @@
#pragma once
#include "mediachanger/Constants.hpp"
#include "common/Constants.hpp"
#include <stdint.h>
......
......@@ -20,7 +20,6 @@ cmake_minimum_required (VERSION 2.6)
add_subdirectory (io)
add_subdirectory (legacymsg)
add_subdirectory (mediachanger)
add_subdirectory (messages)
add_subdirectory (tape)
add_subdirectory (utils)
......@@ -5,8 +5,6 @@ include_directories(${PROJECT_SOURCE_DIR}/tapeserver/h)
add_library (ctalegacymsg
TapeLabelRqstMsgBody.cpp
RmcProxyTcpIp.cpp
RmcMarshal.cpp
GenericMarshal.cpp
MessageHeader.cpp
legacymsg.cpp
......@@ -17,11 +15,7 @@ add_library (ctalegacymsg
TapeStatRequestMsgBody.cpp
GenericErrorReplyMsgBody.cpp
GenericReplyMsgBody.cpp
TapeStatDriveEntry.cpp
RmcProxy.cpp
RmcMountMsgBody.cpp
RmcUnmountMsgBody.cpp
RmcProxyDummy.cpp)
TapeStatDriveEntry.cpp)
add_library (ctalegacymsgunittests SHARED
CommonMarshalTest.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 Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/io/io.hpp"
#include "castor/legacymsg/RmcMarshal.hpp"
#include "rmc_constants.h"
#include <string.h>
//-----------------------------------------------------------------------------
// marshal
//-----------------------------------------------------------------------------
size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen, const RmcMountMsgBody &src) {
const char *task = "marshal RmcMountMsgBody";
if(dst == NULL) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Pointer to destination buffer is NULL";
throw ex;
}
// Calculate the length of the message body
const uint32_t bodyLen =
sizeof(src.uid) +
sizeof(src.gid) +
strlen(src.unusedLoader) + 1 +
strlen(src.vid) + 1 +
sizeof(src.side) +
sizeof(src.drvOrd);
// Calculate the total length of the message (header + body)
const uint32_t totalLen =
sizeof(uint32_t) + // magic
sizeof(uint32_t) + // reqType
sizeof(uint32_t) + // len
bodyLen;
// Check that the message buffer is big enough
if(totalLen > dstLen) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Buffer too small: required=" << totalLen << " actual=" << dstLen;
throw ex;
}
// Marshal message header
char *p = dst;
try {
const uint32_t magic = RMC_MAGIC;
const uint32_t reqType = RMC_MOUNT;
io::marshalUint32(magic , p);
io::marshalUint32(reqType, p);
io::marshalUint32(totalLen, p);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal header: "
<< ne.getMessage().str();
throw ex;
}
// Marshal message body
try {
io::marshalUint32(src.uid, p);
io::marshalUint32(src.gid, p);
io::marshalString(src.unusedLoader, p);
io::marshalString(src.vid, p);
io::marshalUint16(src.side, p);
io::marshalUint16(src.drvOrd, p);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal body: "
<< ne.getMessage().str();
throw ex;
}
// Calculate the number of bytes actually marshalled
const size_t nbBytesMarshalled = p - dst;
// Check that the number of bytes marshalled was what was expected
if(totalLen != nbBytesMarshalled) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Mismatch between expected total length and actual"
": expected=" << totalLen << " actual=" << nbBytesMarshalled;
throw ex;
}
return totalLen;
}
//-----------------------------------------------------------------------------
// unmarshal
//-----------------------------------------------------------------------------
void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, RmcMountMsgBody &dst) {
try {
io::unmarshalUint32(src, srcLen, dst.uid);
io::unmarshalUint32(src, srcLen, dst.gid);
io::unmarshalString(src, srcLen, dst.unusedLoader);
io::unmarshalString(src, srcLen, dst.vid);
io::unmarshalUint16(src, srcLen, dst.side);
io::unmarshalUint16(src, srcLen, dst.drvOrd);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to unmarshal RmcMountMsgBody: " <<
ne.getMessage().str();
throw ex;
}
}
//-----------------------------------------------------------------------------
// marshal
//-----------------------------------------------------------------------------
size_t castor::legacymsg::marshal(char *const dst, const size_t dstLen, const RmcUnmountMsgBody &src) {
const char *const task = "marshal RmcUnmountMsgBody";
if(dst == NULL) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Pointer to destination buffer is NULL";
throw ex;
}
// Calculate the length of the message body
const uint32_t bodyLen =
sizeof(src.uid) +
sizeof(src.gid) +
strlen(src.unusedLoader) + 1 +
strlen(src.vid) + 1 +
sizeof(src.drvOrd) +
sizeof(src.force);
// Calculate the total length of the message (header + body)
const uint32_t totalLen =
sizeof(uint32_t) + // magic
sizeof(uint32_t) + // reqType
sizeof(uint32_t) + // len
bodyLen;
// Check that the message buffer is big enough
if(totalLen > dstLen) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Buffer too small: required=" << totalLen << " actual=" << dstLen;
throw ex;
}
// Marshal message header
char *p = dst;
try {
const uint32_t magic = RMC_MAGIC;
const uint32_t reqType = RMC_UNMOUNT;
io::marshalUint32(magic , p);
io::marshalUint32(reqType, p);
io::marshalUint32(totalLen, p);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal header: "
<< ne.getMessage().str();
throw ex;
}
// Marshal message body
try {
io::marshalUint32(src.uid, p);
io::marshalUint32(src.gid, p);
io::marshalString(src.unusedLoader, p);
io::marshalString(src.vid, p);
io::marshalUint16(src.drvOrd, p);
io::marshalUint16(src.force, p);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task << ": Failed to marshal body: "
<< ne.getMessage().str();
throw ex;
}
// Calculate the number of bytes actually marshalled
const size_t nbBytesMarshalled = p - dst;
// Check that the number of bytes marshalled was what was expected
if(totalLen != nbBytesMarshalled) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to " << task <<
": Mismatch between expected total length and actual"
": expected=" << totalLen << " actual=" << nbBytesMarshalled;
throw ex;
}
return totalLen;
}
//-----------------------------------------------------------------------------
// unmarshal
//-----------------------------------------------------------------------------
void castor::legacymsg::unmarshal(const char * &src, size_t &srcLen, RmcUnmountMsgBody &dst) {
try {
io::unmarshalUint32(src, srcLen, dst.uid);
io::unmarshalUint32(src, srcLen, dst.gid);
io::unmarshalString(src, srcLen, dst.unusedLoader);
io::unmarshalString(src, srcLen, dst.vid);
io::unmarshalUint16(src, srcLen, dst.drvOrd);
io::unmarshalUint16(src, srcLen, dst.force);
} catch(cta::exception::Exception &ne) {
cta::exception::Exception ex;
ex.getMessage() << "Failed to unmarshal RmcUnmountMsgBody: " <<
ne.getMessage().str();
throw ex;
}
}
/******************************************************************************
*
* 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 Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "castor/legacymsg/RmcMountMsgBody.hpp"
#include "castor/legacymsg/RmcUnmountMsgBody.hpp"
#include "common/exception/Exception.hpp"
namespace castor {
namespace legacymsg {
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param dstLen The length of the destination buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
size_t marshal(char *const dst, const size_t dstLen, const RmcMountMsgBody &src) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
template<int n> size_t marshal(char (&dst)[n], const RmcMountMsgBody &src) {
return marshal(dst, n, src);
}
/**
* Unmarshals a message body with the specified destination structure type
* from the specified source buffer.
*
* @param src In/out parameter, before invocation points to the source
* buffer where the message body should be unmarshalled from and on return
* points to the byte in the source buffer immediately after the
* unmarshalled message body.
* @param srcLen In/out parameter, before invocation is the length of the
* source buffer from where the message body should be unmarshalled and on
* return is the number of bytes remaining in the source buffer.
* @param dst The destination message body structure.
*/
void unmarshal(const char * &src, size_t &srcLen, RmcMountMsgBody &dst) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param dstLen The length of the destination buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
size_t marshal(char *const dst, const size_t dstLen, const RmcUnmountMsgBody &src) ;
/**
* Marshals the specified source message body structure and its implicit
* header into the specified destination buffer.
*
* @param dst The destination message buffer.
* @param src The source structure.
* @return The total length of the message (header + body).
*/
template<int n> size_t marshal(char (&dst)[n], const RmcUnmountMsgBody &src) {
return marshal(dst, n, src);
}
/**
* Unmarshals a message body with the specified destination structure type
* from the specified source buffer.
*
* @param src In/out parameter, before invocation points to the source
* buffer where the message body should be unmarshalled from and on return
* points to the byte in the source buffer immediately after the
* unmarshalled message body.
* @param srcLen In/out parameter, before invocation is the length of the
* source buffer from where the message body should be unmarshalled and on
* return is the number of bytes remaining in the source buffer.
* @param dst The destination message body structure.
*/
void unmarshal(const char * &src, size_t &srcLen, RmcUnmountMsgBody &dst) ;
} // namespace legacymsg
} // namespace castor
/******************************************************************************
*
* 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 Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#include "castor/legacymsg/RmcMountMsgBody.hpp"
#include <string.h>
//------------------------------------------------------------------------------
// constructor
//------------------------------------------------------------------------------
castor::legacymsg::RmcMountMsgBody::RmcMountMsgBody() throw():
uid(0),
gid(0),
side(0),
drvOrd(0) {
memset(unusedLoader, '\0', sizeof(unusedLoader));
memset(vid, '\0', sizeof(vid));
}
/******************************************************************************
*
* 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 Castor Dev team, castor-dev@cern.ch
*****************************************************************************/
#pragma once
#include "tapeserver/h/Castor_limits.h"
#include <stdint.h>
namespace castor {
namespace legacymsg {
/**
* The body of an RMC_SCSI_MOUNT message.
*/
struct RmcMountMsgBody {
uint32_t uid;
uint32_t gid;
char unusedLoader[1]; // Should always be set to the emtpy string
char vid[CA_MAXVIDLEN + 1];
uint16_t side;
uint16_t drvOrd;
/**
* Constructor.
*
* Sets all integer member-variables to 0 and all string member-variables to
* the empty string.
*/
RmcMountMsgBody() throw();
}; // struct RmcMountMsgBody
} // namespace legacymsg
} // namespace castor
/******************************************************************************
*
* 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