Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/bareos/bareos.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rogge <andreas.rogge@bareos.com>2022-10-10 15:16:47 +0300
committerAndreas Rogge <andreas.rogge@bareos.com>2022-11-07 19:37:29 +0300
commitef44197e0986ecc0dc7de8730ddb7a35924fcd4a (patch)
treebeef5880a074489d0aa00e346d28297536ec3292
parent529ff83cfe47ee3c6bb434a717dfcfb25c541d48 (diff)
stored: cleanup unused backend interfaces
This patch removes now unused parts of the old storage backend interface.
-rw-r--r--core/src/stored/CMakeLists.txt1
-rw-r--r--core/src/stored/btape.cc4
-rw-r--r--core/src/stored/sd_backends.cc188
-rw-r--r--core/src/stored/sd_backends.h23
-rw-r--r--core/src/stored/stored.cc4
-rw-r--r--core/src/stored/stored_conf.cc4
-rw-r--r--core/src/tests/sd_backend.cc3
-rw-r--r--core/src/tests/sd_reservation.cc7
8 files changed, 2 insertions, 232 deletions
diff --git a/core/src/stored/CMakeLists.txt b/core/src/stored/CMakeLists.txt
index 0555c150a..60f5d284c 100644
--- a/core/src/stored/CMakeLists.txt
+++ b/core/src/stored/CMakeLists.txt
@@ -66,7 +66,6 @@ set(LIBBAREOSSD_SRCS
record.cc
reserve.cc
scan.cc
- sd_backends.cc
sd_device_control_record.cc
sd_plugins.cc
sd_stats.cc
diff --git a/core/src/stored/btape.cc b/core/src/stored/btape.cc
index 9a1c63a1a..39ae5ca7c 100644
--- a/core/src/stored/btape.cc
+++ b/core/src/stored/btape.cc
@@ -359,10 +359,6 @@ static void TerminateBtape(int status)
if (dev) { delete dev; }
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
-
if (configfile) { free(configfile); }
if (my_config) {
diff --git a/core/src/stored/sd_backends.cc b/core/src/stored/sd_backends.cc
deleted file mode 100644
index f19d88c97..000000000
--- a/core/src/stored/sd_backends.cc
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- BAREOSĀ® - Backup Archiving REcovery Open Sourced
-
- Copyright (C) 2014-2014 Planets Communications B.V.
- Copyright (C) 2014-2022 Bareos GmbH & Co. KG
-
- This program is Free Software; you can redistribute it and/or
- modify it under the terms of version three of the GNU Affero General Public
- License as published by the Free Software Foundation and included
- in the file LICENSE.
-
- 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
- Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- 02110-1301, USA.
-*/
-// Marco van Wieringen, June 2014
-/**
- * @file
- * Dynamic loading of SD backend plugins.
- */
-
-#include "include/bareos.h"
-
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-
-# include "stored/stored.h"
-# include "sd_backends.h"
-
-# include <cstdlib>
-# include <dlfcn.h>
-# include <map>
-# include <memory>
-# include <stdexcept>
-# include <vector>
-
-namespace storagedaemon {
-
-struct BackendDeviceLibraryDescriptor {
- public:
- std::string device_type{};
-
- private:
- void* dynamic_library_handle{};
- BackendInterface* backend_interface{};
-
- public:
- BackendDeviceLibraryDescriptor(const std::string& t_device_type,
- void* t_dynamic_library_handle,
- BackendInterface* t_backend_interface)
- : device_type(t_device_type)
- , dynamic_library_handle(t_dynamic_library_handle)
- , backend_interface(t_backend_interface)
- {
- }
-
- ~BackendDeviceLibraryDescriptor()
- {
- delete backend_interface;
- dlclose(dynamic_library_handle);
- }
-
- BackendDeviceLibraryDescriptor(const BackendDeviceLibraryDescriptor& other)
- = delete;
- BackendDeviceLibraryDescriptor& operator=(
- const BackendDeviceLibraryDescriptor& other)
- = delete;
- BackendDeviceLibraryDescriptor(BackendDeviceLibraryDescriptor&& other)
- = default;
- BackendDeviceLibraryDescriptor& operator=(
- BackendDeviceLibraryDescriptor&& other)
- = default;
-
- Device* GetDevice() { return backend_interface->GetDevice(); }
-};
-
-static std::vector<std::unique_ptr<BackendDeviceLibraryDescriptor>>
- loaded_backends;
-static std::vector<std::string> backend_directories;
-
-void SetBackendDeviceDirectories(
- std::vector<std::string>&& new_backend_directories)
-{
- backend_directories = new_backend_directories;
-}
-
-static inline const char* get_dlerror()
-{
- const char* error = dlerror();
- return error != nullptr ? error : "";
-}
-
-Device* InitBackendDevice(JobControlRecord* jcr, const std::string& device_type)
-{
- if (backend_directories.empty()) {
- Jmsg(jcr, M_ERROR_TERM, 0, _("storage backend dir not configured.\n"));
- // does not return
- }
-
- const char* interface_name = device_type.c_str();
-
- for (const auto& b : loaded_backends) {
- if (b->device_type == device_type) { return b->GetDevice(); }
- }
-
- t_backend_base GetBackend{nullptr};
- void* dynamic_library_handle{nullptr};
-
- for (const auto& backend_dir : backend_directories) {
- if (dynamic_library_handle != nullptr) { break; }
-
- std::string shared_library_name = backend_dir + "/libbareossd-";
- shared_library_name += interface_name;
- shared_library_name += DYN_LIB_EXTENSION;
-
- Dmsg3(100, "InitBackendDevice: checking backend %s/libbareossd-%s%s\n",
- backend_dir.c_str(), interface_name, DYN_LIB_EXTENSION);
-
- struct stat st;
- if (stat(shared_library_name.c_str(), &st) != 0) {
- Dmsg3(100,
- "InitBackendDevice: backend does not exist %s/libbareossd-%s%s\n",
- backend_dir.c_str(), interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
-
- dynamic_library_handle = dlopen(shared_library_name.c_str(), RTLD_NOW);
-
- if (dynamic_library_handle == nullptr) {
- const char* error = get_dlerror();
- Jmsg(jcr, M_ERROR, 0, _("Unable to load shared library: %s ERR=%s\n"),
- shared_library_name.c_str(), error);
- Dmsg2(100, _("Unable to load shared library: %s ERR=%s\n"),
- shared_library_name.c_str(), error);
- continue;
- }
-
- GetBackend = reinterpret_cast<t_backend_base>(
- dlsym(dynamic_library_handle, "GetBackend"));
-
- if (GetBackend == nullptr) {
- const char* error = get_dlerror();
- Jmsg(jcr, M_ERROR, 0,
- _("Lookup of GetBackend in shared library %s failed: "
- "ERR=%s\n"),
- shared_library_name.c_str(), error);
- Dmsg2(100,
- _("Lookup of GetBackend in shared library %s failed: "
- "ERR=%s\n"),
- shared_library_name.c_str(), error);
- dlclose(dynamic_library_handle);
- dynamic_library_handle = nullptr;
- continue;
- }
- }
-
- if (dynamic_library_handle == nullptr) {
- Jmsg(jcr, M_ERROR_TERM, 0,
- _("Unable to load any shared library for libbareossd-%s%s\n"),
- interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
- if (!GetBackend) {
- Jmsg(jcr, M_ERROR_TERM, 0,
- _("Unable to locate GetBackend() function in shared backend library "
- "for libbareossd-%s%s\n"),
- interface_name, DYN_LIB_EXTENSION);
- return nullptr;
- }
-
- auto b = std::make_unique<BackendDeviceLibraryDescriptor>(
- device_type, dynamic_library_handle, GetBackend());
-
- Device* d = b->GetDevice();
- loaded_backends.push_back(std::move(b));
- return d;
-}
-
-void FlushAndCloseBackendDevices() { loaded_backends.clear(); }
-
-} /* namespace storagedaemon */
-
-#endif /* HAVE_DYNAMIC_SD_BACKENDS */
diff --git a/core/src/stored/sd_backends.h b/core/src/stored/sd_backends.h
index 2ecc69e6a..71b8c7108 100644
--- a/core/src/stored/sd_backends.h
+++ b/core/src/stored/sd_backends.h
@@ -45,28 +45,7 @@ template <typename T> class Backend : public BackendInterface {
template <typename T> BackendInterface* BackendFactory(void) { return new T(); }
-extern "C" {
-typedef BackendInterface* (*t_backend_base)(void);
-BackendInterface* GetBackend(void);
-}
-
-#if defined(HAVE_WIN32)
-# define DYN_LIB_EXTENSION ".dll"
-#elif defined(HAVE_DARWIN_OS)
-/* cmake MODULE creates a .so files; cmake SHARED creates .dylib */
-// #define DYN_LIB_EXTENSION ".dylib"
-# define DYN_LIB_EXTENSION ".so"
-#else
-# define DYN_LIB_EXTENSION ".so"
-#endif
-
#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-# include <map>
-void SetBackendDeviceDirectories(std::vector<std::string>&& new_backend_dirs);
-Device* InitBackendDevice(JobControlRecord* jcr,
- const std::string& device_type);
-void FlushAndCloseBackendDevices();
-
bool LoadStorageBackend(const std::string& dev_type,
const std::vector<std::string>& backend_directories);
#endif
@@ -76,6 +55,6 @@ bool LoadStorageBackend(const std::string& dev_type,
= PluginRegistry<BackendInterface>::Add( \
#backend_name, BackendFactory<Backend<backend_class>>);
-} /* namespace storagedaemon */
+} // namespace storagedaemon
#endif // BAREOS_STORED_SD_BACKENDS_H_
diff --git a/core/src/stored/stored.cc b/core/src/stored/stored.cc
index 1c329549d..57e19939c 100644
--- a/core/src/stored/stored.cc
+++ b/core/src/stored/stored.cc
@@ -663,10 +663,6 @@ static
}
}
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
-
if (configfile) {
free(configfile);
configfile = nullptr;
diff --git a/core/src/stored/stored_conf.cc b/core/src/stored/stored_conf.cc
index 4e00244ef..990f25101 100644
--- a/core/src/stored/stored_conf.cc
+++ b/core/src/stored/stored_conf.cc
@@ -617,10 +617,6 @@ bool ParseSdConfig(const char* configfile, int exit_code)
configfile);
return retval;
}
-
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- SetBackendDeviceDirectories(std::move(me->backend_directories));
-#endif
}
return retval;
diff --git a/core/src/tests/sd_backend.cc b/core/src/tests/sd_backend.cc
index 701382b04..454fe7333 100644
--- a/core/src/tests/sd_backend.cc
+++ b/core/src/tests/sd_backend.cc
@@ -93,9 +93,6 @@ void sd::TearDown()
}
}
}
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
if (configfile) { free(configfile); }
if (my_config) { delete my_config; }
diff --git a/core/src/tests/sd_reservation.cc b/core/src/tests/sd_reservation.cc
index 1e651106c..748dc8886 100644
--- a/core/src/tests/sd_reservation.cc
+++ b/core/src/tests/sd_reservation.cc
@@ -47,9 +47,7 @@
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/wait.h"
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
-# include "stored/sd_backends.h"
-#endif
+#include "stored/sd_backends.h"
#include "bsock_mock.h"
@@ -99,9 +97,6 @@ void ReservationTest::TearDown()
}
}
}
-#if defined(HAVE_DYNAMIC_SD_BACKENDS)
- FlushAndCloseBackendDevices();
-#endif
if (configfile) { free(configfile); }
if (my_config) { delete my_config; }