Skip to content

Commit

Permalink
stored: rename dev_type to device_type
Browse files Browse the repository at this point in the history
  • Loading branch information
arogge committed Nov 7, 2022
1 parent 28d4311 commit 8208f2a
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 44 deletions.
13 changes: 7 additions & 6 deletions core/src/stored/dev.cc
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,16 @@ Device* FactoryCreateDevice(JobControlRecord* jcr,
Dmsg1(400, "max_block_size in device_resource res is %u\n",
device_resource->max_block_size);

if (!ImplementationFactory<Device>::IsRegistered(device_resource->dev_type)) {
if (!ImplementationFactory<Device>::IsRegistered(
device_resource->device_type)) {
Jmsg2(jcr, M_ERROR, 0, _("%s has an unknown device type %s\n"),
device_resource->archive_device_string,
device_resource->dev_type.c_str());
device_resource->device_type.c_str());
return nullptr;
}

Device* dev
= ImplementationFactory<Device>::Create(device_resource->dev_type);
= ImplementationFactory<Device>::Create(device_resource->device_type);

dev->device_resource = device_resource;
device_resource->dev = dev;
Expand Down Expand Up @@ -179,7 +180,7 @@ static void InitiateDevice(JobControlRecord* jcr, Device* dev)
dev->drive_index = dev->device_resource->drive_index;
dev->autoselect = dev->device_resource->autoselect;
dev->norewindonclose = dev->device_resource->norewindonclose;
dev->dev_type = dev->device_resource->dev_type;
dev->device_type = dev->device_resource->device_type;

if (dev->vol_poll_interval && dev->vol_poll_interval < 60) {
dev->vol_poll_interval = 60;
Expand Down Expand Up @@ -505,7 +506,7 @@ bool Device::open(DeviceControlRecord* dcr, DeviceMode omode)
}

Dmsg4(100, "open dev: type=%d archive_device_string=%s vol=%s mode=%s\n",
dev_type.c_str(), print_name(), getVolCatName(), mode_to_str(omode));
device_type.c_str(), print_name(), getVolCatName(), mode_to_str(omode));

ClearBit(ST_LABEL, state);
ClearBit(ST_APPENDREADY, state);
Expand Down Expand Up @@ -899,7 +900,7 @@ bool Device::close(DeviceControlRecord* dcr)

if (!norewindonclose) { OfflineOrRewind(); }

if (dev_type == DeviceType::B_TAPE_DEV) { UnlockDoor(); }
if (device_type == DeviceType::B_TAPE_DEV) { UnlockDoor(); }
status = d_close(fd);
if (status < 0) {
BErrNo be;
Expand Down
6 changes: 3 additions & 3 deletions core/src/stored/dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Device {
int dev_errno{}; /**< Our own errno */
int oflags{}; /**< Read/write flags */
DeviceMode open_mode{DeviceMode::kUndefined};
std::string dev_type{};
std::string device_type{};
bool autoselect{}; /**< Autoselect in autochanger */
bool norewindonclose{}; /**< Don't rewind tape drive on close */
bool initiated{}; /**< Set when FactoryCreateDevice() called */
Expand Down Expand Up @@ -298,7 +298,7 @@ class Device {
bool AttachedToAutochanger() const { return BitIsSet(CAP_ATTACHED_TO_AUTOCHANGER, capabilities); }
bool RequiresMount() const { return BitIsSet(CAP_REQMOUNT, capabilities); }
bool IsRemovable() const { return BitIsSet(CAP_REM, capabilities); }
bool IsTape() const { return (dev_type == DeviceType::B_TAPE_DEV); }
bool IsTape() const { return (device_type == DeviceType::B_TAPE_DEV); }
bool IsOpen() const { return fd >= 0; }
bool IsOffline() const { return BitIsSet(ST_OFFLINE, state); }
bool IsLabeled() const { return BitIsSet(ST_LABEL, state); }
Expand Down Expand Up @@ -335,7 +335,7 @@ class Device {
const char* strerror() const;
const char* archive_name() const;
const char* name() const;
const std::string& type() const { return dev_type; }
const std::string& type() const { return device_type; }
const char* print_name() const; /**< Name for display purposes */
void SetEot() { SetBit(ST_EOT, state); }
void SetEof() { SetBit(ST_EOF, state); }
Expand Down
8 changes: 4 additions & 4 deletions core/src/stored/device_resource.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ DeviceResource::DeviceResource()
, changer_command(nullptr)
, alert_command(nullptr)
, spool_directory(nullptr)
, dev_type(DeviceType::B_UNKNOWN_DEV)
, device_type(DeviceType::B_UNKNOWN_DEV)
, label_type(B_BAREOS_LABEL)
, autoselect(true)
, norewindonclose(true)
Expand Down Expand Up @@ -115,7 +115,7 @@ DeviceResource::DeviceResource(const DeviceResource& other)
if (other.spool_directory) {
spool_directory = strdup(other.spool_directory);
}
dev_type = other.dev_type;
device_type = other.device_type;
label_type = other.label_type;
autoselect = other.autoselect;
norewindonclose = other.norewindonclose;
Expand Down Expand Up @@ -170,7 +170,7 @@ DeviceResource& DeviceResource::operator=(const DeviceResource& rhs)
changer_command = rhs.changer_command;
alert_command = rhs.alert_command;
spool_directory = rhs.spool_directory;
dev_type = rhs.dev_type;
device_type = rhs.device_type;
label_type = rhs.label_type;
autoselect = rhs.autoselect;
norewindonclose = rhs.norewindonclose;
Expand Down Expand Up @@ -274,7 +274,7 @@ void DeviceResource::CreateAndAssignSerialNumber(uint16_t number)

bool DeviceResource::Validate()
{
if (max_block_size > 0 && dev_type != DeviceType::B_TAPE_DEV) {
if (max_block_size > 0 && device_type != DeviceType::B_TAPE_DEV) {
my_config->AddWarning(
"Setting 'Maximum Block Size' on a non-tape device is unsupported");
}
Expand Down
20 changes: 10 additions & 10 deletions core/src/stored/device_resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ class AutochangerResource;

class DeviceResource : public BareosResource {
public:
char* media_type; /**< User assigned media type */
char* archive_device_string; /**< Archive device name */
char* device_options; /**< Device specific option string */
char* diag_device_name; /**< Diagnostic device name */
char* changer_name; /**< Changer device name */
char* changer_command; /**< Changer command -- external program */
char* alert_command; /**< Alert command -- external program */
char* spool_directory; /**< Spool file directory */
std::string dev_type; /**< device type */
uint32_t label_type; /**< label type */
char* media_type; /**< User assigned media type */
char* archive_device_string; /**< Archive device name */
char* device_options; /**< Device specific option string */
char* diag_device_name; /**< Diagnostic device name */
char* changer_name; /**< Changer device name */
char* changer_command; /**< Changer command -- external program */
char* alert_command; /**< Alert command -- external program */
char* spool_directory; /**< Spool file directory */
std::string device_type;
uint32_t label_type;
bool autoselect; /**< Automatically select from AutoChanger */
bool norewindonclose; /**< Don't rewind tape drive on close */
bool drive_tapealert_enabled; /**< Enable Tape Alert monitoring */
Expand Down
2 changes: 1 addition & 1 deletion core/src/stored/sd_backends.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Device;
template <typename T> Device* DeviceFactory(void) { return new T(); }

#if defined(HAVE_DYNAMIC_SD_BACKENDS)
bool LoadStorageBackend(const std::string& dev_type,
bool LoadStorageBackend(const std::string& device_type,
const std::vector<std::string>& backend_directories);
#endif

Expand Down
10 changes: 5 additions & 5 deletions core/src/stored/sd_backends_dynamic.cc
Original file line number Diff line number Diff line change
Expand Up @@ -53,23 +53,23 @@ static bool LoadDynamicLibrary(
return false;
}

bool LoadStorageBackend(const std::string& dev_type,
bool LoadStorageBackend(const std::string& device_type,
const std::vector<std::string>& backend_directories)
{
using namespace std::string_literals;

if (dev_type.empty() || backend_directories.empty()) { return false; }
if (device_type.empty() || backend_directories.empty()) { return false; }

if (!LoadDynamicLibrary("libbareossd-"s + dev_type + kDynLibExtension,
if (!LoadDynamicLibrary("libbareossd-"s + device_type + kDynLibExtension,
backend_directories)) {
return false;
}

if (!ImplementationFactory<Device>::IsRegistered(dev_type)) {
if (!ImplementationFactory<Device>::IsRegistered(device_type)) {
Jmsg(nullptr, M_ERROR_TERM, 0,
"Loaded backend library for %s did not register its backend. This is "
"probably a bug in the backend library.\n",
dev_type.c_str());
device_type.c_str());
}

return true;
Expand Down
30 changes: 15 additions & 15 deletions core/src/stored/stored_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ static ResourceItem dev_items[] = {
{"Description", CFG_TYPE_STR, ITEM(res_dev, description_), 0, 0, NULL, NULL,
"The Description directive provides easier human recognition, but is not used by Bareos directly."},
{"MediaType", CFG_TYPE_STRNAME, ITEM(res_dev, media_type), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL},
{"DeviceType", CFG_TYPE_STDSTR, ITEM(res_dev, dev_type), 0, CFG_ITEM_DEFAULT, "", NULL, NULL},
{"DeviceType", CFG_TYPE_STDSTR, ITEM(res_dev, device_type), 0, CFG_ITEM_DEFAULT, "", NULL, NULL},
{"ArchiveDevice", CFG_TYPE_STRNAME, ITEM(res_dev, archive_device_string), 0, CFG_ITEM_REQUIRED, NULL, NULL, NULL},
{"DeviceOptions", CFG_TYPE_STR, ITEM(res_dev, device_options), 0, 0, NULL, "15.2.0-", NULL},
{"DiagnosticDevice", CFG_TYPE_STRNAME, ITEM(res_dev, diag_device_name), 0, 0, NULL, NULL, NULL},
Expand Down Expand Up @@ -489,11 +489,11 @@ static void CheckDropletDevices(ConfigurationParser& my_config)

while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
DeviceResource* d = dynamic_cast<DeviceResource*>(p);
if (d && d->dev_type == DeviceType::B_DROPLET_DEV) {
if (d && d->device_type == DeviceType::B_DROPLET_DEV) {
if (d->max_concurrent_jobs == 0) {
/*
* 0 is the general default. However, for this dev_type, only 1 works.
* So we set it to this value.
* 0 is the general default. However, for this device_type, only 1
* works. So we set it to this value.
*/
Jmsg1(nullptr, M_WARNING, 0,
_("device %s is set to the default 'Maximum Concurrent Jobs' = "
Expand All @@ -516,7 +516,7 @@ static void GuessMissingDeviceTypes(ConfigurationParser& my_config)

while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
DeviceResource* d = dynamic_cast<DeviceResource*>(p);
if (d && d->dev_type == DeviceType::B_UNKNOWN_DEV) {
if (d && d->device_type == DeviceType::B_UNKNOWN_DEV) {
struct stat statp;
// Check that device is available
if (stat(d->archive_device_string, &statp) < 0) {
Expand All @@ -529,11 +529,11 @@ static void GuessMissingDeviceTypes(ConfigurationParser& my_config)
return;
}
if (S_ISDIR(statp.st_mode)) {
d->dev_type = DeviceType::B_FILE_DEV;
d->device_type = DeviceType::B_FILE_DEV;
} else if (S_ISCHR(statp.st_mode)) {
d->dev_type = DeviceType::B_TAPE_DEV;
d->device_type = DeviceType::B_TAPE_DEV;
} else if (S_ISFIFO(statp.st_mode)) {
d->dev_type = DeviceType::B_FIFO_DEV;
d->device_type = DeviceType::B_FIFO_DEV;
} else if (!BitIsSet(CAP_REQMOUNT, d->cap_bits)) {
Jmsg2(nullptr, M_ERROR_TERM, 0,
_("%s is an unknown device type. Must be tape or directory, "
Expand All @@ -556,24 +556,24 @@ static void CheckAndLoadDeviceBackends(ConfigurationParser& my_config)
while ((p = my_config.GetNextRes(R_DEVICE, p)) != nullptr) {
DeviceResource* d = dynamic_cast<DeviceResource*>(p);
if (d) {
to_lower(d->dev_type);
if (!ImplementationFactory<Device>::IsRegistered(d->dev_type)) {
to_lower(d->device_type);
if (!ImplementationFactory<Device>::IsRegistered(d->device_type)) {
#if defined(HAVE_DYNAMIC_SD_BACKENDS)
if (!storage_res || storage_res->backend_directories.empty()) {
Jmsg2(nullptr, M_ERROR_TERM, 0,
"Backend Directory not set. Cannot load dynamic backend %s\n",
d->dev_type.c_str());
d->device_type.c_str());
}
if (!LoadStorageBackend(d->dev_type,
if (!LoadStorageBackend(d->device_type,
storage_res->backend_directories)) {
Jmsg2(nullptr, M_ERROR_TERM, 0,
"Could not load storage backend %s for device %s.\n",
d->dev_type.c_str(), d->resource_name_);
d->device_type.c_str(), d->resource_name_);
}
#else
Jmsg2(nullptr, M_ERROR_TERM, 0,
"Backend %s for device %s not available.\n", d->dev_type.c_str(),
d->resource_name_);
"Backend %s for device %s not available.\n",
d->device_type.c_str(), d->resource_name_);
#endif
}
}
Expand Down

0 comments on commit 8208f2a

Please sign in to comment.