diff options
Diffstat (limited to 'gsi_tool.cpp')
-rw-r--r-- | gsi_tool.cpp | 62 |
1 files changed, 44 insertions, 18 deletions
diff --git a/gsi_tool.cpp b/gsi_tool.cpp index 6cafd82..9abb1ff 100644 --- a/gsi_tool.cpp +++ b/gsi_tool.cpp @@ -299,8 +299,13 @@ static int Install(sp<IGsiService> gsid, int argc, char** argv) { return EX_SOFTWARE; } progress.Finish(); - - status = gsid->enableGsi(true, &error); + std::string dsuSlot; + status = gsid->getActiveDsuSlot(&dsuSlot); + if (!status.isOk()) { + std::cerr << "Could not get the active DSU slot: " << ErrorMessage(status) << "\n"; + return EX_SOFTWARE; + } + status = gsid->enableGsi(true, dsuSlot, &error); if (!status.isOk() || error != IGsiService::INSTALL_OK) { std::cerr << "Could not make live image bootable: " << ErrorMessage(status, error) << "\n"; return EX_SOFTWARE; @@ -409,21 +414,31 @@ static int Status(sp<IGsiService> gsid, int argc, char** /* argv */) { if (getuid() != 0) { return 0; } - sp<IImageService> image_service = nullptr; - status = gsid->openImageService("dsu", &image_service); - if (!status.isOk()) { - std::cerr << "error: " << status.exceptionMessage().string() << std::endl; - return EX_SOFTWARE; - } - std::vector<std::string> images; - status = image_service->getAllBackingImages(&images); + + std::vector<std::string> dsu_slots; + status = gsid->getInstalledDsuSlots(&dsu_slots); if (!status.isOk()) { - std::cerr << "error: " << status.exceptionMessage().string() << std::endl; + std::cerr << status.exceptionMessage().string() << std::endl; return EX_SOFTWARE; } - - for (auto&& image : images) { - std::cout << "installed: " << image << std::endl; + int n = 0; + for (auto&& dsu_slot : dsu_slots) { + std::cout << "[" << n++ << "] " << dsu_slot << std::endl; + sp<IImageService> image_service = nullptr; + status = gsid->openImageService("dsu/" + dsu_slot + "/", &image_service); + if (!status.isOk()) { + std::cerr << "error: " << status.exceptionMessage().string() << std::endl; + return EX_SOFTWARE; + } + std::vector<std::string> images; + status = image_service->getAllBackingImages(&images); + if (!status.isOk()) { + std::cerr << "error: " << status.exceptionMessage().string() << std::endl; + return EX_SOFTWARE; + } + for (auto&& image : images) { + std::cout << "installed: " << image << std::endl; + } } return 0; } @@ -444,9 +459,10 @@ static int Cancel(sp<IGsiService> gsid, int /* argc */, char** /* argv */) { static int Enable(sp<IGsiService> gsid, int argc, char** argv) { bool one_shot = false; - + std::string dsuSlot = {}; struct option options[] = { {"single-boot", no_argument, nullptr, 's'}, + {"dsuslot", required_argument, nullptr, 'd'}, {nullptr, 0, nullptr, 0}, }; int rv, index; @@ -455,6 +471,9 @@ static int Enable(sp<IGsiService> gsid, int argc, char** argv) { case 's': one_shot = true; break; + case 'd': + dsuSlot = optarg; + break; default: std::cerr << "Unrecognized argument to enable\n"; return EX_USAGE; @@ -474,9 +493,15 @@ static int Enable(sp<IGsiService> gsid, int argc, char** argv) { std::cerr << "Cannot enable or disable while an installation is in progress." << std::endl; return EX_SOFTWARE; } - + if (dsuSlot.empty()) { + auto status = gsid->getActiveDsuSlot(&dsuSlot); + if (!status.isOk()) { + std::cerr << "Could not get the active DSU slot: " << ErrorMessage(status) << "\n"; + return EX_SOFTWARE; + } + } int error; - auto status = gsid->enableGsi(one_shot, &error); + auto status = gsid->enableGsi(one_shot, dsuSlot, &error); if (!status.isOk() || error != IGsiService::INSTALL_OK) { std::cerr << "Error re-enabling GSI: " << ErrorMessage(status, error) << "\n"; return EX_SOFTWARE; @@ -516,7 +541,8 @@ static int usage(int /* argc */, char* argv[]) { " %s <disable|install|wipe|status> [options]\n" "\n" " disable Disable the currently installed GSI.\n" - " enable [-s, --single-boot]\n" + " enable [-s, --single-boot]\n" + " [-d, --dsuslot slotname]\n" " Enable a previously disabled GSI.\n" " install Install a new GSI. Specify the image size with\n" " --gsi-size and the desired userdata size with\n" |