diff options
author | Albert Chaulk <achaulk@chromium.org> | 2013-07-19 12:56:38 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-31 15:40:23 -0700 |
commit | 494646dbadedae88776d6fced396e3ee8af38e54 (patch) | |
tree | e5d2dffbb2610cbdef31e86e0fdd701f4b51cd1d /cgpt/cmd_create.c | |
parent | 32fd6dead10a8255fea27f6e5ce9ba92d8716008 (diff) | |
download | vboot-494646dbadedae88776d6fced396e3ee8af38e54.tar.gz |
Fix some issues with LBA vs byte offsets
In several places the existing code assumes LBA, but was improperly converted
to use byte offsets, so multiply by the sector size to correct it and maintain
the same interface between MTD & GPT.
Also, since we will need to cgpt create on /dev/fts, which isn't a stat()able
device, allow providing the disk size on the commandline.
BRANCH=none
BUG=chromium:221745
TEST=make runtests; cgpt create -s 12345 on MTD image
Change-Id: Icc89a4505aba9a3dfc39b176a372f6e12d106aed
Reviewed-on: https://gerrit.chromium.org/gerrit/62675
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Albert Chaulk <achaulk@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Diffstat (limited to 'cgpt/cmd_create.c')
-rw-r--r-- | cgpt/cmd_create.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/cgpt/cmd_create.c b/cgpt/cmd_create.c index 0d91b08a..4f042204 100644 --- a/cgpt/cmd_create.c +++ b/cgpt/cmd_create.c @@ -14,6 +14,7 @@ static void Usage(void) "Create or reset an empty GPT.\n\n" "Options:\n" " -z Zero the sectors of the GPT table and entries\n" + " -s Size (in byes) of the disk (MTD only)\n" "\n", progname); } @@ -23,15 +24,19 @@ int cmd_create(int argc, char *argv[]) { int c; int errorcnt = 0; + char *e = 0; opterr = 0; // quiet, you - while ((c=getopt(argc, argv, ":hz")) != -1) + while ((c=getopt(argc, argv, ":hzs:")) != -1) { switch (c) { case 'z': params.zap = 1; break; + case 's': + params.size = strtoull(optarg, &e, 0); + break; case 'h': Usage(); |