summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cgpt/cgpt_boot.c9
-rw-r--r--cgpt/cgpt_legacy.c7
-rw-r--r--cgpt/cgpt_repair.c6
3 files changed, 22 insertions, 0 deletions
diff --git a/cgpt/cgpt_boot.c b/cgpt/cgpt_boot.c
index 386c4f4d..993e8654 100644
--- a/cgpt/cgpt_boot.c
+++ b/cgpt/cgpt_boot.c
@@ -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;
diff --git a/cgpt/cgpt_legacy.c b/cgpt/cgpt_legacy.c
index 932fbb92..e736bd4c 100644
--- a/cgpt/cgpt_legacy.c
+++ b/cgpt/cgpt_legacy.c
@@ -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) {
diff --git a/cgpt/cgpt_repair.c b/cgpt/cgpt_repair.c
index e591c75b..9b4d2dfb 100644
--- a/cgpt/cgpt_repair.c
+++ b/cgpt/cgpt_repair.c
@@ -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",