Implement no-op commands

Provide implementations for "boot" and "legacy" that error out in MTD mode and
"repair" that is a no-op. Eventually if/when we add redundancy, repair will do
something, but boot/legacy never will.

BUG=chromium:221745
BRANCH=none
TEST=none

Original-Change-Id: Ie537f20d8dff9d14fb83d0431bd48453bff0217d
Reviewed-on: https://gerrit.chromium.org/gerrit/46883
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
(cherry picked from commit 00c4bc52e35c7c77ebe73322693a457b3dd072f9)

Change-Id: I90e6118114554a05245fb8cfcec9567c4705ea96
Reviewed-on: https://gerrit.chromium.org/gerrit/49790
Reviewed-by: Albert Chaulk <achaulk@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
This commit is contained in:
Albert Chaulk
2013-03-29 10:27:08 -07:00
committed by ChromeBot
parent f2a1dc0a54
commit 874109ec57
3 changed files with 22 additions and 0 deletions

View File

@@ -78,6 +78,15 @@ int CgptBoot(CgptBootParams *params) {
return CGPT_FAILED;
}
if (drive.is_mtd) {
/* This command manipulates the legacy MBR sector present at the beginning
* of the GPT structures, and so doesn't apply to MTD drives.
*/
Error("'boot' command unsupported in MTD mode\n");
retval = CGPT_FAILED;
goto done;
}
if (CGPT_OK != ReadPMBR(&drive)) {
Error("Unable to read PMBR\n");
goto done;

View File

@@ -18,6 +18,13 @@ int CgptLegacy(CgptLegacyParams *params) {
if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR))
return CGPT_FAILED;
if (drive.is_mtd) {
// This command requires GPT mode.
Error("'legacy' command unsupported in MTD mode\n");
DriveClose(&drive, 0);
return CGPT_FAILED;
}
h1 = (GptHeader *)drive.gpt.primary_header;
h2 = (GptHeader *)drive.gpt.secondary_header;
if (params->efipart) {

View File

@@ -18,6 +18,12 @@ int CgptRepair(CgptRepairParams *params) {
if (CGPT_OK != DriveOpen(params->drive_name, &drive, O_RDWR))
return CGPT_FAILED;
if (drive.is_mtd) {
// Nothing to do
DriveClose(&drive, 0);
return 0;
}
int gpt_retval = GptSanityCheck(&drive.gpt);
if (params->verbose)
printf("GptSanityCheck() returned %d: %s\n",