summaryrefslogtreecommitdiff
path: root/cgpt/cmd_legacy.c
diff options
context:
space:
mode:
authorStefan Reinauer <reinauer@chromium.org>2012-08-23 15:06:25 -0700
committerGerrit <chrome-bot@google.com>2012-09-19 15:33:30 -0700
commitb7b865cfee68190babd971ab9a897bdabbab075f (patch)
tree8ad900ddff6a69f9a65cd0507857a6da2677592f /cgpt/cmd_legacy.c
parent40d8651bb36048c9b5f07be97ff17b2cf503015e (diff)
downloadvboot-b7b865cfee68190babd971ab9a897bdabbab075f.tar.gz
Support alternative GPT header signature
In order to dual boot Windows and ChromeOS, Windows must not find a GPT partition table on the disk. So change ChromeOS to cope with an alternative signature "CHROMEOS" instead of the standard "EFI PART" BUG=chrome-os-partner:6108 TEST=rebuild chromeos, install it, run cgpt legacy /dev/sda dd if=/dev/sda of=/tmp/x bs=1k hexdump -C /tmp/X see the string CHROMEOS BRANCH=link Signed-off-by: Stefan Reinauer <reinauer@chromium.org> Change-Id: Ia88eff33b9880bd73a78c1b8e026c1f8298c4557 Reviewed-on: https://gerrit.chromium.org/gerrit/31264 Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Ready: Stefan Reinauer <reinauer@chromium.org> Tested-by: Stefan Reinauer <reinauer@chromium.org>
Diffstat (limited to 'cgpt/cmd_legacy.c')
-rw-r--r--cgpt/cmd_legacy.c67
1 files changed, 67 insertions, 0 deletions
diff --git a/cgpt/cmd_legacy.c b/cgpt/cmd_legacy.c
new file mode 100644
index 00000000..5dad01e3
--- /dev/null
+++ b/cgpt/cmd_legacy.c
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "cgpt.h"
+
+#include <getopt.h>
+#include <string.h>
+
+#include "cgpt_params.h"
+
+static void Usage(void)
+{
+ printf("\nUsage: %s legacy [OPTIONS] DRIVE\n\n"
+ "Switch GPT header signature to \"CHROMEOS\".\n\n"
+ "Options:\n"
+ " -e Switch GPT header signature back to \"EFI PART\"\n"
+ "\n", progname);
+}
+
+int cmd_legacy(int argc, char *argv[]) {
+ CgptLegacyParams params;
+ memset(&params, 0, sizeof(params));
+
+ int c;
+ int errorcnt = 0;
+
+ opterr = 0; // quiet, you
+ while ((c=getopt(argc, argv, ":he")) != -1)
+ {
+ switch (c)
+ {
+ case 'e':
+ params.efipart = 1;
+ break;
+
+ case 'h':
+ Usage();
+ return CGPT_OK;
+ case '?':
+ Error("unrecognized option: -%c\n", optopt);
+ errorcnt++;
+ break;
+ case ':':
+ Error("missing argument to -%c\n", optopt);
+ errorcnt++;
+ break;
+ default:
+ errorcnt++;
+ break;
+ }
+ }
+ if (errorcnt)
+ {
+ Usage();
+ return CGPT_FAILED;
+ }
+
+ if (optind >= argc) {
+ Usage();
+ return CGPT_FAILED;
+ }
+
+ params.drive_name = argv[optind];
+
+ return cgpt_legacy(&params);
+}