diff options
| author | Patrick Venture <venture@google.com> | 2019-08-15 10:12:50 -0700 |
|---|---|---|
| committer | Patrick Venture <venture@google.com> | 2019-08-15 10:19:43 -0700 |
| commit | c498caa44844220497086dee8a806c0417a93e9d (patch) | |
| tree | 33ee7d377759aa4be57de1fbc4be44ca2d7c2389 | |
| parent | 097435fca7e52b7f6c9d7f26c8e247366e4e3ef5 (diff) | |
| download | phosphor-ipmi-flash-c498caa44844220497086dee8a806c0417a93e9d.tar.gz phosphor-ipmi-flash-c498caa44844220497086dee8a806c0417a93e9d.zip | |
tools: type field now matches the /flash/{type}
Instead of mapping one word to a pre-defined mapping of types, let the
host user specify any value.
A user shouldn't specify hash, or update, or something meaningful.
Perhaps this should be validated.
Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Icec103e0ade999d527923dcacb440086c93e175c
| -rw-r--r-- | tools/main.cpp | 25 | ||||
| -rw-r--r-- | tools/updater.cpp | 10 |
2 files changed, 9 insertions, 26 deletions
diff --git a/tools/main.cpp b/tools/main.cpp index a933e67..ae85c1b 100644 --- a/tools/main.cpp +++ b/tools/main.cpp @@ -42,14 +42,10 @@ #define IPMILPC "ipmilpc" #define IPMIPCI "ipmipci" #define IPMIBT "ipmibt" -#define STATIC "static" -#define UBITAR "ubitar" -#define BIOS "bios" namespace { const std::vector<std::string> interfaceList = {IPMIBT, IPMILPC, IPMIPCI}; -const std::vector<std::string> typeList = {STATIC, UBITAR, BIOS}; } // namespace void usage(const char* program) @@ -65,16 +61,9 @@ void usage(const char* program) std::ostream_iterator<std::string>(std::cerr, ", ")); std::fprintf(stderr, "\n"); - std::fprintf(stderr, "layouts: "); - std::copy(typeList.begin(), typeList.end(), - std::ostream_iterator<std::string>(std::cerr, ", ")); - std::fprintf(stderr, "\n"); -} - -bool checkType(const std::string& type) -{ - auto tFound = std::find(typeList.begin(), typeList.end(), type); - return (tFound != typeList.end()); + std::fprintf(stderr, "layouts examples: image, bios\n"); + std::fprintf(stderr, + "the type field specifies '/flash/{layout}' for a handler\n"); } bool checkCommand(const std::string& command) @@ -178,11 +167,6 @@ int main(int argc, char* argv[]) break; case 't': type = std::string{optarg}; - if (!checkType(type)) - { - usage(argv[0]); - exit(EXIT_FAILURE); - } break; default: usage(argv[0]); @@ -199,7 +183,8 @@ int main(int argc, char* argv[]) /* They want to update the firmware. */ if (command == "update") { - if (interface.empty() || imagePath.empty() || signaturePath.empty()) + if (interface.empty() || imagePath.empty() || signaturePath.empty() || + type.empty()) { usage(argv[0]); exit(EXIT_FAILURE); diff --git a/tools/updater.cpp b/tools/updater.cpp index 96f38b1..0fcfe6f 100644 --- a/tools/updater.cpp +++ b/tools/updater.cpp @@ -38,12 +38,10 @@ void updaterMain(UpdateHandlerInterface* updater, const std::string& imagePath, const std::string& signaturePath, const std::string& layoutType) { - static std::unordered_map<std::string, std::string> typesToBlob = { - {"static", ipmi_flash::staticLayoutBlobId}, - {"ubitar", ipmi_flash::ubiTarballBlobId}, - {"bios", ipmi_flash::biosBlobId}}; - /* We know it's one of the above types already. */ - auto& layout = typesToBlob[layoutType]; + /* TODO: validate the layoutType isn't a special value such as: 'update', + * 'verify', or 'hash' + */ + std::string layout = "/flash/" + layoutType; bool goalSupported = updater->checkAvailable(layout); if (!goalSupported) |

