From e73db91485f29180961be6f16bcd308d7afec48e Mon Sep 17 00:00:00 2001 From: SamuelBoerlin <11892708+SamuelBoerlin@users.noreply.github.com> Date: Fri, 30 Jun 2023 18:21:38 +0200 Subject: [PATCH] refactor: rename AutoXflateMode --- .../stored/autoxflate/autoxflate-sd.cc | 32 +++++++++---------- core/src/stored/dev.h | 4 +-- core/src/stored/device_control_record.h | 6 ++-- core/src/stored/device_resource.cc | 1 - core/src/stored/device_resource.h | 12 +++---- .../stored/{autoxflate.h => io_direction.h} | 16 +++++----- core/src/stored/mac.cc | 24 +++++++------- core/src/stored/reserve.cc | 10 +++--- core/src/stored/stored_conf.cc | 22 ++++++------- 9 files changed, 63 insertions(+), 64 deletions(-) rename core/src/stored/{autoxflate.h => io_direction.h} (81%) diff --git a/core/src/plugins/stored/autoxflate/autoxflate-sd.cc b/core/src/plugins/stored/autoxflate/autoxflate-sd.cc index f579febb97a..3098d8e3e7a 100644 --- a/core/src/plugins/stored/autoxflate/autoxflate-sd.cc +++ b/core/src/plugins/stored/autoxflate/autoxflate-sd.cc @@ -113,17 +113,17 @@ static int const debuglevel = 200; // Does the mode contain OUT -static bool AutoxflateModeContainsOut(AutoXflateMode mode) +static bool AutoxflateModeContainsOut(IODirection mode) { - return (mode == AutoXflateMode::IO_DIRECTION_OUT - || mode == AutoXflateMode::IO_DIRECTION_INOUT); + return (mode == IODirection::WRITE + || mode == IODirection::READ_WRITE); } // Does the mode contain IN -static bool AutoxflateModeContainsIn(AutoXflateMode mode) +static bool AutoxflateModeContainsIn(IODirection mode) { - return (mode == AutoXflateMode::IO_DIRECTION_IN - || mode == AutoXflateMode::IO_DIRECTION_INOUT); + return (mode == IODirection::READ + || mode == IODirection::READ_WRITE); } // what streams can be decompressed by the plugin @@ -312,8 +312,8 @@ static bRC setup_record_translation(PluginContext* ctx, void* value) && dcr->jcr->is_JobType(JT_RESTORE) && (AutoxflateModeContainsIn(dcr->autodeflate) || !AutoxflateModeContainsIn(dcr->autoinflate))) { - dcr->autoinflate = AutoXflateMode::IO_DIRECTION_IN; - dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE; + dcr->autoinflate = IODirection::READ; + dcr->autodeflate = IODirection::NONE; Jmsg(ctx, M_INFO, _("autoxflate-sd: overriding settings on %s for NDMP restore\n"), dcr->dev_name); @@ -321,19 +321,19 @@ static bRC setup_record_translation(PluginContext* ctx, void* value) // Give jobmessage info what is configured switch (dcr->autodeflate) { - case AutoXflateMode::IO_DIRECTION_NONE: + case IODirection::NONE: deflate_in = SETTING_NO; deflate_out = SETTING_NO; break; - case AutoXflateMode::IO_DIRECTION_IN: + case IODirection::READ: deflate_in = SETTING_YES; deflate_out = SETTING_NO; break; - case AutoXflateMode::IO_DIRECTION_OUT: + case IODirection::WRITE: deflate_in = SETTING_NO; deflate_out = SETTING_YES; break; - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::READ_WRITE: deflate_in = SETTING_YES; deflate_out = SETTING_YES; break; @@ -345,19 +345,19 @@ static bRC setup_record_translation(PluginContext* ctx, void* value) } switch (dcr->autoinflate) { - case AutoXflateMode::IO_DIRECTION_NONE: + case IODirection::NONE: inflate_in = SETTING_NO; inflate_out = SETTING_NO; break; - case AutoXflateMode::IO_DIRECTION_IN: + case IODirection::READ: inflate_in = SETTING_YES; inflate_out = SETTING_NO; break; - case AutoXflateMode::IO_DIRECTION_OUT: + case IODirection::WRITE: inflate_in = SETTING_NO; inflate_out = SETTING_YES; break; - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::READ_WRITE: inflate_in = SETTING_YES; inflate_out = SETTING_YES; break; diff --git a/core/src/stored/dev.h b/core/src/stored/dev.h index 641842510a2..8930afbf5f6 100644 --- a/core/src/stored/dev.h +++ b/core/src/stored/dev.h @@ -63,7 +63,7 @@ #include "include/bareos.h" #include "stored/record.h" #include "stored/volume_catalog_info.h" -#include "stored/autoxflate.h" +#include "stored/io_direction.h" #include "lib/btimers.h" #include @@ -232,7 +232,7 @@ class Device { int oflags{}; /**< Read/write flags */ DeviceMode open_mode{DeviceMode::kUndefined}; std::string device_type{}; - AutoXflateMode access_mode{}; /**< Allowed access mode(s) for reservation */ + IODirection access_mode{}; /**< Allowed access mode(s) for reservation */ bool autoselect{}; /**< Autoselect in autochanger */ bool norewindonclose{}; /**< Don't rewind tape drive on close */ bool initiated{}; /**< Set when FactoryCreateDevice() called */ diff --git a/core/src/stored/device_control_record.h b/core/src/stored/device_control_record.h index a6c91b6ce5d..9f5fea80e88 100644 --- a/core/src/stored/device_control_record.h +++ b/core/src/stored/device_control_record.h @@ -39,7 +39,7 @@ #ifndef BAREOS_STORED_DEVICE_CONTROL_RECORD_H_ #define BAREOS_STORED_DEVICE_CONTROL_RECORD_H_ -#include "stored/autoxflate.h" +#include "stored/io_direction.h" #include "stored/volume_catalog_info.h" namespace storagedaemon { @@ -97,8 +97,8 @@ class DeviceControlRecord { bool any_volume{}; /**< Any OK for dir_find_next... */ bool attached_to_dev{}; /**< Set when attached to dev */ bool keep_dcr{}; /**< Do not free dcr in release_dcr */ - AutoXflateMode autodeflate{AutoXflateMode::IO_DIRECTION_NONE}; - AutoXflateMode autoinflate{AutoXflateMode::IO_DIRECTION_NONE}; + IODirection autodeflate{IODirection::NONE}; + IODirection autoinflate{IODirection::NONE}; uint32_t VolFirstIndex{}; /**< First file index this Volume */ uint32_t VolLastIndex{}; /**< Last file index this Volume */ uint32_t FileIndex{}; /**< Current File Index */ diff --git a/core/src/stored/device_resource.cc b/core/src/stored/device_resource.cc index 9ae72eb9db0..1972a216304 100644 --- a/core/src/stored/device_resource.cc +++ b/core/src/stored/device_resource.cc @@ -22,7 +22,6 @@ */ #include "lib/parse_conf.h" -#include "stored/autoxflate.h" #include "stored/device_resource.h" #include "stored/stored_globals.h" #include diff --git a/core/src/stored/device_resource.h b/core/src/stored/device_resource.h index 40952167b17..c3360f5c0a3 100644 --- a/core/src/stored/device_resource.h +++ b/core/src/stored/device_resource.h @@ -25,7 +25,7 @@ #define BAREOS_STORED_DEVICE_RESOURCE_H_ #include "stored/dev.h" -#include "stored/autoxflate.h" +#include "stored/io_direction.h" #include "lib/bareos_resource.h" namespace storagedaemon { @@ -45,7 +45,7 @@ class DeviceResource : public BareosResource { char* spool_directory; /**< Spool file directory */ std::string device_type{DeviceType::B_UNKNOWN_DEV}; uint32_t label_type{B_BAREOS_LABEL}; - AutoXflateMode access_mode{AutoXflateMode::IO_DIRECTION_INOUT}; /**< Allowed access mode(s) for reservation */ + IODirection access_mode{IODirection::READ_WRITE}; /**< Allowed access mode(s) for reservation */ bool autoselect{true}; /**< Automatically select from AutoChanger */ bool norewindonclose{true}; /**< Don't rewind tape drive on close */ bool drive_tapealert_enabled{false}; /**< Enable Tape Alert monitoring */ @@ -70,11 +70,11 @@ class DeviceResource : public BareosResource { compression */ uint16_t autodeflate_level{6}; /**< Compression level to use for compression algorithm which uses levels */ - AutoXflateMode autodeflate{ - AutoXflateMode::IO_DIRECTION_NONE}; /**< auto deflation in this IO + IODirection autodeflate{ + IODirection::NONE}; /**< auto deflation in this IO direction */ - AutoXflateMode autoinflate{ - AutoXflateMode::IO_DIRECTION_NONE}; /**< auto inflation in this IO + IODirection autoinflate{ + IODirection::NONE}; /**< auto inflation in this IO direction */ utime_t vol_poll_interval{ 300}; /**< Interval between polling volume during mount */ diff --git a/core/src/stored/autoxflate.h b/core/src/stored/io_direction.h similarity index 81% rename from core/src/stored/autoxflate.h rename to core/src/stored/io_direction.h index 044abfe912a..f6349c40e47 100644 --- a/core/src/stored/autoxflate.h +++ b/core/src/stored/io_direction.h @@ -21,21 +21,21 @@ 02110-1301, USA. */ -#ifndef BAREOS_STORED_AUTOXFLATE_H_ -#define BAREOS_STORED_AUTOXFLATE_H_ +#ifndef BAREOS_STORED_IO_DIRECTION_H_ +#define BAREOS_STORED_IO_DIRECTION_H_ #include "include/bareos.h" namespace storagedaemon { -enum class AutoXflateMode : uint16_t +enum class IODirection : uint16_t { - IO_DIRECTION_NONE = 0, - IO_DIRECTION_IN, - IO_DIRECTION_OUT, - IO_DIRECTION_INOUT + NONE = 0, + READ, + WRITE, + READ_WRITE }; } // namespace storagedaemon -#endif // BAREOS_STORED_AUTOXFLATE_H_ +#endif // BAREOS_STORED_IO_DIRECTION_H_ diff --git a/core/src/stored/mac.cc b/core/src/stored/mac.cc index 5e10fdf4bf8..0b39fc01f85 100644 --- a/core/src/stored/mac.cc +++ b/core/src/stored/mac.cc @@ -381,10 +381,10 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) // Check autodeflation. switch (jcr->sd_impl->read_dcr->autodeflate) { - case AutoXflateMode::IO_DIRECTION_IN: - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::READ: + case IODirection::READ_WRITE: Dmsg0(200, "Clearing autodeflate on read_dcr\n"); - jcr->sd_impl->read_dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE; + jcr->sd_impl->read_dcr->autodeflate = IODirection::NONE; break; default: break; @@ -392,10 +392,10 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) if (jcr->sd_impl->dcr) { switch (jcr->sd_impl->dcr->autodeflate) { - case AutoXflateMode::IO_DIRECTION_OUT: - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::WRITE: + case IODirection::READ_WRITE: Dmsg0(200, "Clearing autodeflate on write dcr\n"); - jcr->sd_impl->dcr->autodeflate = AutoXflateMode::IO_DIRECTION_NONE; + jcr->sd_impl->dcr->autodeflate = IODirection::NONE; break; default: break; @@ -404,10 +404,10 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) // Check autoinflation. switch (jcr->sd_impl->read_dcr->autoinflate) { - case AutoXflateMode::IO_DIRECTION_IN: - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::READ: + case IODirection::READ_WRITE: Dmsg0(200, "Clearing autoinflate on read_dcr\n"); - jcr->sd_impl->read_dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE; + jcr->sd_impl->read_dcr->autoinflate = IODirection::NONE; break; default: break; @@ -415,10 +415,10 @@ static inline void CheckAutoXflation(JobControlRecord* jcr) if (jcr->sd_impl->dcr) { switch (jcr->sd_impl->dcr->autoinflate) { - case AutoXflateMode::IO_DIRECTION_OUT: - case AutoXflateMode::IO_DIRECTION_INOUT: + case IODirection::WRITE: + case IODirection::READ_WRITE: Dmsg0(200, "Clearing autoinflate on write dcr\n"); - jcr->sd_impl->dcr->autoinflate = AutoXflateMode::IO_DIRECTION_NONE; + jcr->sd_impl->dcr->autoinflate = IODirection::NONE; break; default: break; diff --git a/core/src/stored/reserve.cc b/core/src/stored/reserve.cc index b65900b4a9b..a41e3c92b5f 100644 --- a/core/src/stored/reserve.cc +++ b/core/src/stored/reserve.cc @@ -438,7 +438,7 @@ bool FindSuitableDeviceForJob(JobControlRecord* jcr, ReserveContext& rctx) rctx.device_name = device_name; rctx.device_resource = vol->dev->device_resource; - if (rctx.device_resource->access_mode == AutoXflateMode::IO_DIRECTION_IN) { + if (rctx.device_resource->access_mode == IODirection::READ) { Dmsg1(debuglevel, "device=%s not suitable because it is read only\n", vol->dev->device_resource->resource_name_); @@ -547,11 +547,11 @@ int SearchResForDevice(ReserveContext& rctx) Dmsg1(100, "Device %s not autoselect skipped.\n", rctx.device_resource->resource_name_); continue; /* Device is not available */ - } else if (rctx.append && rctx.device_resource->access_mode == AutoXflateMode::IO_DIRECTION_IN) { + } else if (rctx.append && rctx.device_resource->access_mode == IODirection::READ) { Dmsg1(debuglevel, "Device %s is read only.\n", rctx.device_resource->resource_name_); continue; /* Device is not available */ - } else if (!rctx.append && rctx.device_resource->access_mode == AutoXflateMode::IO_DIRECTION_OUT) { + } else if (!rctx.append && rctx.device_resource->access_mode == IODirection::WRITE) { Dmsg1(debuglevel, "Device %s is write only.\n", rctx.device_resource->resource_name_); continue; /* Device is not available */ @@ -661,9 +661,9 @@ static int ReserveDevice(ReserveContext& rctx) Dmsg3(debuglevel, "chk AccessMode append=%d access_mode=%d\n", rctx.append, rctx.device_resource->access_mode); - if (rctx.append && rctx.device_resource->access_mode == AutoXflateMode::IO_DIRECTION_IN) { + if (rctx.append && rctx.device_resource->access_mode == IODirection::READ) { return -1; - } else if (!rctx.append && rctx.device_resource->access_mode == AutoXflateMode::IO_DIRECTION_OUT) { + } else if (!rctx.append && rctx.device_resource->access_mode == IODirection::WRITE) { return -1; } diff --git a/core/src/stored/stored_conf.cc b/core/src/stored/stored_conf.cc index c464c132762..dd091c507d8 100644 --- a/core/src/stored/stored_conf.cc +++ b/core/src/stored/stored_conf.cc @@ -250,18 +250,18 @@ static struct s_kw authentication_methods[] struct s_io_kw { const char* name; - AutoXflateMode token; + IODirection token; }; -static s_io_kw io_directions[] = {{"in", AutoXflateMode::IO_DIRECTION_IN}, - {"read", AutoXflateMode::IO_DIRECTION_IN}, - {"readonly", AutoXflateMode::IO_DIRECTION_IN}, - {"out", AutoXflateMode::IO_DIRECTION_OUT}, - {"write", AutoXflateMode::IO_DIRECTION_OUT}, - {"writeonly", AutoXflateMode::IO_DIRECTION_OUT}, - {"both", AutoXflateMode::IO_DIRECTION_INOUT}, - {"readwrite", AutoXflateMode::IO_DIRECTION_INOUT}, - {nullptr, AutoXflateMode::IO_DIRECTION_NONE}}; +static s_io_kw io_directions[] = {{"in", IODirection::READ}, + {"read", IODirection::READ}, + {"readonly", IODirection::READ}, + {"out", IODirection::WRITE}, + {"write", IODirection::WRITE}, + {"writeonly", IODirection::WRITE}, + {"both", IODirection::READ_WRITE}, + {"readwrite", IODirection::READ_WRITE}, + {nullptr, IODirection::READ_WRITE}}; static s_kw compression_algorithms[] = {{"gzip", COMPRESS_GZIP}, {"lzo", COMPRESS_LZO1X}, @@ -337,7 +337,7 @@ static void StoreIoDirection(LEX* lc, ResourceItem* item, int index, int) LexGetToken(lc, BCT_NAME); for (i = 0; io_directions[i].name; i++) { if (Bstrcasecmp(lc->str, io_directions[i].name)) { - SetItemVariable(*item, io_directions[i].token); + SetItemVariable(*item, io_directions[i].token); i = 0; break; }