diff --git a/cpp/command/command_executor.cpp b/cpp/command/command_executor.cpp index 012e3a15..2703f79e 100644 --- a/cpp/command/command_executor.cpp +++ b/cpp/command/command_executor.cpp @@ -207,7 +207,7 @@ bool CommandExecutor::Attach(const CommandContext &context, const PbDeviceDefini const string &filename = GetParam(pb_device, "file"); - const auto device = CreateDevice(context, type, lun, filename); + const auto device = CreateDevice(context, pb_device, filename); if (!device) { return false; } @@ -613,16 +613,18 @@ bool CommandExecutor::EnsureLun0(const CommandContext &context, const PbCommand true : context.ReturnLocalizedError(LocalizationKey::ERROR_MISSING_LUN0, to_string((*it).first)); } -shared_ptr CommandExecutor::CreateDevice(const CommandContext &context, const PbDeviceType type, - int lun, const string &filename) const +shared_ptr CommandExecutor::CreateDevice(const CommandContext &context, + const PbDeviceDefinition &pb_device, const string &filename) const { - auto device = DeviceFactory::Instance().CreateDevice(type, lun, filename); + auto device = DeviceFactory::Instance().CreateDevice(pb_device.type(), pb_device.unit(), filename); if (!device) { - if (type == UNDEFINED) { - context.ReturnLocalizedError(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, filename); + if (pb_device.type() == UNDEFINED) { + context.ReturnLocalizedError(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, to_string(pb_device.id()), + to_string(pb_device.unit()), filename); } else { - context.ReturnLocalizedError(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, PbDeviceType_Name(type)); + context.ReturnLocalizedError(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, to_string(pb_device.id()), + to_string(pb_device.unit()), PbDeviceType_Name(pb_device.type())); } return nullptr; diff --git a/cpp/command/command_executor.h b/cpp/command/command_executor.h index 07d85b82..7913108b 100644 --- a/cpp/command/command_executor.h +++ b/cpp/command/command_executor.h @@ -48,7 +48,7 @@ class CommandExecutor bool ValidateImageFile(const CommandContext&, StorageDevice&, const string&) const; bool EnsureLun0(const CommandContext&, const PbCommand&) const; bool ValidateDevice(const CommandContext&, const PbDeviceDefinition&) const; - shared_ptr CreateDevice(const CommandContext&, const PbDeviceType, int, const string&) const; + shared_ptr CreateDevice(const CommandContext&, const PbDeviceDefinition&, const string&) const; bool SetBlockSize(const CommandContext&, shared_ptr, int) const; mutex& GetExecutionLocker() diff --git a/cpp/command/command_localizer.cpp b/cpp/command/command_localizer.cpp index abca5682..f54a0bcf 100644 --- a/cpp/command/command_localizer.cpp +++ b/cpp/command/command_localizer.cpp @@ -92,22 +92,24 @@ CommandLocalizer::CommandLocalizer() Add(LocalizationKey::ERROR_NON_EXISTING_UNIT, "es", "Comando para ID %1 inexistente, unidad %2"); Add(LocalizationKey::ERROR_NON_EXISTING_UNIT, "zh", "不存在的 ID %1, 单元 %2 的指令"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "en", "Unknown device type %1"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "de", "Unbekannter Gerätetyp %1"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "sv", "Obekant enhetstyp: %1"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "fr", "Type de périphérique inconnu %1"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "es", "Tipo de dispositivo desconocido %1"); - Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "zh", "未知设备类型 %1"); - - Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "en", "Device type required for unknown extension of file '%1'"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "en", "%1:%2: Unknown device type %1"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "de", "%1:%2: Unbekannter Gerätetyp %1"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "sv", "%1:%2: Obekant enhetstyp: %1"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "fr", "%1:%2: Type de périphérique inconnu %1"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "es", "%1:%2: Tipo de dispositivo desconocido %1"); + Add(LocalizationKey::ERROR_UNKNOWN_DEVICE_TYPE, "zh", "%1:%2: 未知设备类型 %1"); + + Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "en", + "%1:%2: Device type required for unknown extension of file '%1'"); Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "de", - "Gerätetyp erforderlich für unbekannte Extension der Datei '%1'"); - Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "sv", "Man måste ange enhetstyp för obekant filändelse '%1'"); + "%1:%2: Gerätetyp erforderlich für unbekannte Extension der Datei '%1'"); + Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "sv", + "%1:%2: Man måste ange enhetstyp för obekant filändelse '%1'"); Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "fr", - "Type de périphérique requis pour extension inconnue du fichier '%1'"); + "%1:%2: Type de périphérique requis pour extension inconnue du fichier '%1'"); Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "es", - "Tipo de dispositivo requerido para la extensión desconocida del archivo '%1'"); - Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "zh", "文件'%1'的未知扩展名所需的设备类型"); + "%1:%2: Tipo de dispositivo requerido para la extensión desconocida del archivo '%1'"); + Add(LocalizationKey::ERROR_MISSING_DEVICE_TYPE, "zh", "%1:%2: 文件'%1'的未知扩展名所需的设备类型"); Add(LocalizationKey::ERROR_DUPLICATE_ID, "en", "Duplicate ID %1, unit %2"); Add(LocalizationKey::ERROR_DUPLICATE_ID, "de", "Doppelte ID %1, Einheit %2"); diff --git a/cpp/shared/s2p_version.cpp b/cpp/shared/s2p_version.cpp index adfe54f2..2c6d03bb 100644 --- a/cpp/shared/s2p_version.cpp +++ b/cpp/shared/s2p_version.cpp @@ -11,4 +11,4 @@ const int s2p_major_version = 4; const int s2p_minor_version = 1; const int s2p_revision = 0; -const std::string s2p_suffix = "-rc1"; +const std::string s2p_suffix = ""; diff --git a/cpp/test/command_executor_test.cpp b/cpp/test/command_executor_test.cpp index 0ce19140..c31b57c5 100644 --- a/cpp/test/command_executor_test.cpp +++ b/cpp/test/command_executor_test.cpp @@ -448,16 +448,21 @@ TEST(CommandExecutorTest, CreateDevice) const auto bus = make_shared(); ControllerFactory controller_factory; const auto executor = make_shared(*bus, controller_factory); + PbDeviceDefinition device; PbCommand command; CommandContext context(command); - EXPECT_EQ(nullptr, executor->CreateDevice(context, UNDEFINED, 0, "")); + device.set_type(UNDEFINED); + EXPECT_EQ(nullptr, executor->CreateDevice(context, device, "")); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" - EXPECT_EQ(nullptr, executor->CreateDevice(context, SCBR, 0, "")); + device.set_type(SCBR); + EXPECT_EQ(nullptr, executor->CreateDevice(context, device, "")); #pragma GCC diagnostic pop - EXPECT_NE(nullptr, executor->CreateDevice(context, UNDEFINED, 0, "services")); - EXPECT_NE(nullptr, executor->CreateDevice(context, SCHS, 0, "")); + device.set_type(UNDEFINED); + EXPECT_NE(nullptr, executor->CreateDevice(context, device, "services")); + device.set_type(SCHS); + EXPECT_NE(nullptr, executor->CreateDevice(context, device, "")); } TEST(CommandExecutorTest, SetBlockSize)