diff --git a/objectstore/BackendVFS.cpp b/objectstore/BackendVFS.cpp index e3b92ec87b26818b9ad26e7601602bf080ff0261..f75ac995fe77d0068aae325abb5b210c51d88b17 100644 --- a/objectstore/BackendVFS.cpp +++ b/objectstore/BackendVFS.cpp @@ -27,7 +27,8 @@ #include <stdio.h> #include <memory> #include <unistd.h> - +#include <sys/socket.h> +#include <sys/stat.h> namespace cta { namespace objectstore { @@ -161,10 +162,9 @@ void BackendVFS::remove(std::string name) { bool BackendVFS::exists(std::string name) { std::string path = m_root + "/" + name; - std::string lockPath = m_root + "/." + name + ".lock"; - if (::access(path.c_str(), F_OK) || ::access(lockPath.c_str(), F_OK)) - return false; - return true; + std::string lockPath = m_root + "/." + name + ".lock"; + struct stat buffer; + return (stat(path.c_str(), &buffer)==0 && stat(lockPath.c_str(), &buffer)==0); } @@ -186,7 +186,7 @@ BackendVFS::ScopedLock * BackendVFS::lockHelper( std::string name, int type) { std::string path = m_root + "/." + name + ".lock"; std::unique_ptr<ScopedLock> ret(new ScopedLock); - ret->set(::open(path.c_str(), O_RDONLY, S_IRWXU)); + ret->set(::open(path.c_str(), O_RDONLY)); cta::exception::Errnum::throwOnMinusOne(ret->m_fd, "In BackendStoreVFS::lockHelper, failed to open the lock file."); cta::exception::Errnum::throwOnMinusOne(::flock(ret->m_fd, LOCK_EX), diff --git a/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp b/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp index 9c3d7ef12ded8ecda0d21141801900a2f20d09cd..854373d471016774a4e5a5bade2a5a301b649023 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/ProcessForker.cpp @@ -556,7 +556,9 @@ castor::tape::tapeserver::daemon::Session::EndOfSessionAction zmqContext.get()); /************BEGIN: boilerplate code to prepare the objectstoreDB object**************/ - cta::objectstore::BackendVFS g_backend; + cta::objectstore::BackendVFS g_backend(m_config.objectStoreBackendPath); + // Make sure we will not delete the contents of objectstore when deleting the object + g_backend.noDeleteOnExit(); class BackendPopulator { public: diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.cpp b/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.cpp index 57bbe464b276f6e6da7f4e9afebfd0a7bf4d7b38..2040ad126977f922aedf47b120329b9bb0ca6ad1 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.cpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.cpp @@ -53,6 +53,7 @@ castor::tape::tapeserver::daemon::TapeDaemonConfig config.cupvHost = castorConf.getConfEntString("UPV" , "HOST", log); config.vdqmHost = castorConf.getConfEntString("VDQM", "HOST", log); config.vmgrHost = castorConf.getConfEntString("VMGR", "HOST", log); + config.objectStoreBackendPath = castorConf.getConfEntString("TapeServer", "ObjectStoreBackendPath", log); config.rmcPort = castorConf.getConfEntInt("RMC", "PORT", (unsigned short)RMC_PORT, log); config.rmcMaxRqstAttempts = castorConf.getConfEntInt("RMC", diff --git a/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp b/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp index 38e4f5c37541480d5cde2b72891b67d89df4566a..749a92ec982694a50689b3af7a1c18395fc1e924 100644 --- a/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp +++ b/tapeserver/castor/tape/tapeserver/daemon/TapeDaemonConfig.hpp @@ -46,6 +46,11 @@ struct TapeDaemonConfig { * The CASTOR configuration parameters used by the Catalogue. */ CatalogueConfig catalogueConfig; + + /** + * This is the path to the objectstore backend + */ + std::string objectStoreBackendPath; /** * The network name of the host on which the cupv daemon is running.