summaryrefslogtreecommitdiff
path: root/cgpt/cmd_create.c
diff options
context:
space:
mode:
authorNam T. Nguyen <namnguyen@chromium.org>2014-11-13 19:30:46 -0800
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-11-14 22:46:59 +0000
commitab899591808dd3e5f955ab7693b54a83389cd35f (patch)
tree8d12700b5be62ac132fd09e3cb17f6b6cce4b70c /cgpt/cmd_create.c
parenta524a3a51591618c1395cb9e1238ee72b3f5e767 (diff)
downloadvboot-ab899591808dd3e5f955ab7693b54a83389cd35f.tar.gz
vboot: cgpt: Treat drive_path as the GPT storage
Previously, "cgpt" called out to "flashrom" directly to read and write NOR area. This CL removes that dependency and always treats "drive_path" as the storage of GPT structs. This makes it consistent that whatever device that cgpt reads from or writes to is always the device that stores GPT structs. We only need to pass in the size of the drive that contains the partitions, but we do not need to access to that drive. More information is in the bug. BUG=chromium:432611 BRANCH=none TEST=unittest CQ-DEPEND=CL:228942 Change-Id: Id0139adf70463cec4f2924de8b9a4725dbec822b Reviewed-on: https://chromium-review.googlesource.com/229736 Reviewed-by: Bill Richardson <wfrichar@chromium.org> Commit-Queue: Nam Nguyen <namnguyen@chromium.org> Tested-by: Nam Nguyen <namnguyen@chromium.org>
Diffstat (limited to 'cgpt/cmd_create.c')
-rw-r--r--cgpt/cmd_create.c25
1 files changed, 20 insertions, 5 deletions
diff --git a/cgpt/cmd_create.c b/cgpt/cmd_create.c
index ca1b815d..47137bdc 100644
--- a/cgpt/cmd_create.c
+++ b/cgpt/cmd_create.c
@@ -15,10 +15,13 @@ static void Usage(void)
printf("\nUsage: %s create [OPTIONS] DRIVE\n\n"
"Create or reset an empty GPT.\n\n"
"Options:\n"
+ " -D NUM Size (in bytes) of the disk where partitions reside\n"
+ " default 0, meaning partitions and GPT structs are\n"
+ " both on DRIVE\n"
" -z Zero the sectors of the GPT table and entries\n"
- " -s Size (in byes) of the disk (MTD only)\n"
- " -p Size (in blocks) of the disk to pad between the\n"
- " primary GPT header and its entries, default 0\n"
+ " -s NUM Size (in bytes) of the disk (MTD only)\n"
+ " -p NUM Size (in blocks) of the disk to pad between the\n"
+ " primary GPT header and its entries, default 0\n"
"\n", progname);
}
@@ -31,10 +34,18 @@ int cmd_create(int argc, char *argv[]) {
char *e = 0;
opterr = 0; // quiet, you
- while ((c=getopt(argc, argv, ":hzsp:")) != -1)
+ while ((c=getopt(argc, argv, ":hzs:p:D:")) != -1)
{
switch (c)
{
+ case 'D':
+ params.drive_size = strtoull(optarg, &e, 0);
+ if (!*optarg || (e && *e))
+ {
+ Error("invalid argument to -%c: \"%s\"\n", c, optarg);
+ errorcnt++;
+ }
+ break;
case 'z':
params.zap = 1;
break;
@@ -43,8 +54,12 @@ int cmd_create(int argc, char *argv[]) {
break;
case 'p':
params.padding = strtoull(optarg, &e, 0);
+ if (!*optarg || (e && *e))
+ {
+ Error("invalid argument to -%c: \"%s\"\n", c, optarg);
+ errorcnt++;
+ }
break;
-
case 'h':
Usage();
return CGPT_OK;