Fixed non-linux builds.

This commit is contained in:
Alexander Shaduri
2021-03-16 16:27:06 +04:00
parent 788a4760b8
commit 812bd2191e
10 changed files with 32 additions and 32 deletions
+1 -1
View File
@@ -55,7 +55,7 @@ class CommandExecutorFactory {
/// A reference-counting pointer to CommandExecutorFactory
using ExecutorFactoryPtr = std::shared_ptr<CommandExecutorFactory>;
using CommandExecutorFactoryPtr = std::shared_ptr<CommandExecutorFactory>;
+6 -6
View File
@@ -28,18 +28,18 @@ Copyright:
std::string StorageDetector::detect(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
std::string StorageDetector::detect(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Starting drive detection.\n");
std::vector<StorageDevicePtr> all_detected;
std::string error_msg;
std::string error_message;
// Try each one and move to next if it fails.
#if defined CONFIG_KERNEL_LINUX
error_msg = detect_drives_linux(all_detected, ex_factory); // linux /proc/partitions as fallback.
error_message = detect_drives_linux(all_detected, ex_factory); // linux /proc/partitions as fallback.
#elif defined CONFIG_KERNEL_FAMILY_WINDOWS
@@ -53,7 +53,7 @@ std::string StorageDetector::detect(std::vector<StorageDevicePtr>& drives, const
if (all_detected.empty()) {
debug_out_warn("app", DBG_FUNC_MSG << "Cannot detect drives: None of the drive detection methods returned any drives.\n");
return error_msg; // last error message should be ok.
return error_message; // last error message should be ok.
}
for (auto& drive : all_detected) {
@@ -96,7 +96,7 @@ std::string StorageDetector::detect(std::vector<StorageDevicePtr>& drives, const
std::string StorageDetector::fetch_basic_data(std::vector<StorageDevicePtr>& drives,
const ExecutorFactoryPtr& ex_factory, bool return_first_error)
const CommandExecutorFactoryPtr& ex_factory, bool return_first_error)
{
fetch_data_errors_.clear();
fetch_data_error_outputs_.clear();
@@ -144,7 +144,7 @@ std::string StorageDetector::fetch_basic_data(std::vector<StorageDevicePtr>& dri
std::string StorageDetector::detect_and_fetch_basic_data(std::vector<StorageDevicePtr>& put_drives_here,
const ExecutorFactoryPtr& ex_factory)
const CommandExecutorFactoryPtr& ex_factory)
{
std::string error_msg = detect(put_drives_here, ex_factory);
+3 -3
View File
@@ -27,20 +27,20 @@ class StorageDetector {
/// Detects a list of drives. Returns detection error message if error occurs.
std::string detect(std::vector<StorageDevicePtr>& drives,
const ExecutorFactoryPtr& ex_factory);
const CommandExecutorFactoryPtr& ex_factory);
/// For each drive, fetch basic data and parse it.
/// If \c return_first_error is true, the function returns on the first error.
/// \return An empty string. Or, if return_first_error is true, the first error that occurs.
std::string fetch_basic_data(std::vector<StorageDevicePtr>& drives,
const ExecutorFactoryPtr& ex_factory, bool return_first_error = false);
const CommandExecutorFactoryPtr& ex_factory, bool return_first_error = false);
/// Run detect() and fetch_basic_data().
/// \return An error if such occurs.
std::string detect_and_fetch_basic_data(std::vector<StorageDevicePtr>& put_drives_here,
const ExecutorFactoryPtr& ex_factory);
const CommandExecutorFactoryPtr& ex_factory);
// void add_match_patterns(std::vector<std::string>& patterns)
+4 -4
View File
@@ -28,7 +28,7 @@ Copyright:
/// Find and execute tw_cli with specified options, return its output through \c output.
/// \return error message
inline std::string execute_tw_cli(const ExecutorFactoryPtr& ex_factory, const std::string& command_options, std::string& output)
inline std::string execute_tw_cli(const CommandExecutorFactoryPtr& ex_factory, const std::string& command_options, std::string& output)
{
std::shared_ptr<CommandExecutor> executor = ex_factory->create_executor(CommandExecutorFactory::ExecutorType::TwCli);
@@ -73,7 +73,7 @@ inline std::string execute_tw_cli(const ExecutorFactoryPtr& ex_factory, const st
/// Get the drives on a 3ware controller using tw_cli.
/// Note that the drives are inserted in the order they are detected.
inline std::string tw_cli_get_drives(const std::string& dev, int controller,
std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory, bool use_tw_cli_dev)
std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory, bool use_tw_cli_dev)
{
debug_out_info("app", "Getting available 3ware drives (ports) for controller " << controller << " through tw_cli...\n");
@@ -114,7 +114,7 @@ inline std::string tw_cli_get_drives(const std::string& dev, int controller,
/// Return 3ware SCSI host numbers (same as /c switch to tw_cli).
/// \return error string on error
inline std::string tw_cli_get_controllers(const ExecutorFactoryPtr& ex_factory, std::vector<int>& controllers)
inline std::string tw_cli_get_controllers(const CommandExecutorFactoryPtr& ex_factory, std::vector<int>& controllers)
{
debug_out_info("app", "Getting available 3ware controllers through tw_cli...\n");
@@ -153,7 +153,7 @@ inline std::string tw_cli_get_controllers(const ExecutorFactoryPtr& ex_factory,
/// one of the gives an error. \c type contains a printf-formatted string with %d.
/// \return an error message on error.
inline std::string smartctl_scan_drives_sequentially(const std::string& dev, const std::string& type,
int from, int to, std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory, std::string& last_output)
int from, int to, std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory, std::string& last_output)
{
std::shared_ptr<CommandExecutor> smartctl_ex = ex_factory->create_executor(CommandExecutorFactory::ExecutorType::Smartctl);
+7 -7
View File
@@ -367,7 +367,7 @@ major minor #blocks name
254 8 1966080 mmcblk1
254 9 2007032 mmcblk1p1
</pre> */
inline std::string detect_drives_linux_proc_partitions(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_proc_partitions(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives through partitions file (/proc/partitions by default; set \"system/linux_proc_partitions_path\" config key to override).\n");
@@ -466,7 +466,7 @@ Implementation notes: it seems that twe uses "3ware" and twa uses "AMCC"
We can't handle a situation with mixed twa/twe/twl systems, since we don't know
how they will be ordered for tw_cli.
</pre> */
inline std::string detect_drives_linux_3ware(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_3ware(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind 3ware controller(s)...\n");
@@ -600,7 +600,7 @@ using "id > 0" requirement (the third column of /proc/scsi/sg/devices.
Try "-d sat" by default. If it fails ("Device Read Identity Failed:" ? not
sure how to detect the failure), fall back to "-d scsi".
</pre> */
inline std::string detect_drives_linux_adaptec(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_adaptec(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind Adaptec controller(s)...\n");
@@ -730,7 +730,7 @@ Notification: If /sys/bus/scsi/devices/hostN/scsi_host/hostN/host_fw_version
is older than "V1.46 2009-01-06", (1.51 for enclosure-having cards) notify the user
(maybe its better to grep the smartctl output for that on port 0?). NOT IMPLEMENTED YET.
</pre> */
inline std::string detect_drives_linux_areca(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_areca(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind Areca controller(s)...\n");
@@ -881,7 +881,7 @@ Detection:
Note: We're not sure how to differentiate the outputs of free / non-existent ports,
so scan them until 15, just in case.
</pre> */
inline std::string detect_drives_linux_cciss(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_cciss(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind HP RAID (CCISS) controller(s)...\n");
@@ -969,7 +969,7 @@ Detection:
Run smartctl -i -d cciss,[0-127] /dev/cciss/cNd0
until "No such device or address" or "VALID ARGUMENTS ARE" is encountered in output.
</pre> */
inline std::string detect_drives_linux_hpsa(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_linux_hpsa(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind HP RAID (hpsa/hpahcisr) controller(s)...\n");
@@ -1058,7 +1058,7 @@ inline std::string detect_drives_linux_hpsa(std::vector<StorageDevicePtr>& drive
std::string detect_drives_linux(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
std::string detect_drives_linux(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
clear_read_file_cache();
+1 -1
View File
@@ -26,7 +26,7 @@ Copyright:
/// Detect drives in Linux
std::string detect_drives_linux(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory);
std::string detect_drives_linux(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory);
+1 -1
View File
@@ -30,7 +30,7 @@ Copyright:
std::string detect_drives_other(std::vector<StorageDevicePtr>& drives,
[[maybe_unused]] const ExecutorFactoryPtr& ex_factory)
[[maybe_unused]] const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives through /dev...\n");
+2 -2
View File
@@ -20,13 +20,13 @@ Copyright:
#include <string>
#include <vector>
#include "executor_factory.h"
#include "command_executor_factory.h"
#include "storage_device.h"
/// Detect drives in FreeBSD, Solaris, etc... (all except Linux and Windows).
std::string detect_drives_other(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory);
std::string detect_drives_other(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory);
+5 -5
View File
@@ -170,7 +170,7 @@ std::map<char, DriveLetterInfo> win32_get_drive_letter_map()
/// a port parameter. We don't pick the others because the may
/// conflict with pd* devices, and we like pd* better than sd*.
std::string get_scan_open_multiport_devices(std::vector<StorageDevicePtr>& drives,
const ExecutorFactoryPtr& ex_factory,
const CommandExecutorFactoryPtr& ex_factory,
const std::map<char, DriveLetterInfo>& drive_letter_map,
std::set<int>& equivalent_pds)
{
@@ -258,7 +258,7 @@ std::string get_scan_open_multiport_devices(std::vector<StorageDevicePtr>& drive
/// Find and execute areca cli with specified options, return its output through \c output.
/// \return error message
inline std::string execute_areca_cli(const ExecutorFactoryPtr& ex_factory, const std::string& cli_binary,
inline std::string execute_areca_cli(const CommandExecutorFactoryPtr& ex_factory, const std::string& cli_binary,
const std::string& command_options, std::string& output)
{
std::shared_ptr<CommandExecutor> executor = ex_factory->create_executor(CommandExecutorFactory::ExecutorType::ArecaCli);
@@ -364,7 +364,7 @@ GuiErrMsg<0x00>: Success.
------------------------------------------------------------
</pre> */
inline std::string areca_cli_get_drives(const std::string& cli_binary, const std::string& dev, int controller,
std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", "Getting available Areca drives (ports) for controller " << controller << " through Areca CLI...\n");
@@ -486,7 +486,7 @@ If CLI is not installed, do the brute-force way:
-d areca,[1-128]/[1-8] /dev/arcmsrN
It's 2-3 drives a second on an empty port, so some limits are set in config.
</pre> */
inline std::string detect_drives_win32_areca(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
inline std::string detect_drives_win32_areca(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
debug_out_info("app", DBG_FUNC_MSG << "Detecting drives behind Areca controller(s)...\n");
@@ -647,7 +647,7 @@ inline std::string detect_drives_win32_areca(std::vector<StorageDevicePtr>& driv
// (or /dev/pdN, /dev/ being optional) where N comes from
// "\\.\PhysicalDriveN" (winnt only).
// http://msdn.microsoft.com/en-us/library/aa365247(VS.85).aspx
std::string detect_drives_win32(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory)
std::string detect_drives_win32(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory)
{
std::vector<std::string> error_msgs;
std::string error_message;
+2 -2
View File
@@ -20,13 +20,13 @@ Copyright:
#include <string>
#include <vector>
#include "executor_factory.h"
#include "command_executor_factory.h"
#include "storage_device.h"
/// Detect drives in Windows
std::string detect_drives_win32(std::vector<StorageDevicePtr>& drives, const ExecutorFactoryPtr& ex_factory);
std::string detect_drives_win32(std::vector<StorageDevicePtr>& drives, const CommandExecutorFactoryPtr& ex_factory);