Files
OpenCellular/cgpt/cmd_boot.c
Bill Richardson 4cb5497984 Remove cgpt app-specific symbols from libvboot_host.a
Three symbols used by the standalone cgpt executable were being referenced
in the files used to create the external libvboot_host.a needed by non-vboot
userspace applications.

This cleans things up so those symbols don't have to be explictly defined
by other repos just to link with that library.

BUG=chromium:318536
BRANCH=ToT
TEST=manual

No new functionality, just code cleanup. Tested with

  make runtests runfutiltests runlongtests

Change-Id: Ibc77fb9800c89d7109ebf38d4d6729f52665722f
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/205667
Reviewed-by: Randall Spangler <rspangler@chromium.org>
2014-06-26 02:41:51 +00:00

87 lines
1.8 KiB
C

// 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 <getopt.h>
#include <string.h>
#include "cgpt.h"
#include "vboot_host.h"
extern const char* progname;
static void Usage(void)
{
printf("\nUsage: %s boot [OPTIONS] DRIVE\n\n"
"Edit the PMBR sector for legacy BIOSes\n\n"
"Options:\n"
" -i NUM Set bootable partition\n"
" -b FILE Install bootloader code in the PMBR\n"
" -p Create legacy PMBR partition table\n"
"\n"
"With no options, it will just print the PMBR boot guid\n"
"\n", progname);
}
int cmd_boot(int argc, char *argv[]) {
CgptBootParams params;
memset(&params, 0, sizeof(params));
int c;
int errorcnt = 0;
char *e = 0;
opterr = 0; // quiet, you
while ((c=getopt(argc, argv, ":hi:b:p")) != -1)
{
switch (c)
{
case 'i':
params.partition = (uint32_t)strtoul(optarg, &e, 0);
if (!*optarg || (e && *e))
{
Error("invalid argument to -%c: \"%s\"\n", c, optarg);
errorcnt++;
}
break;
case 'b':
params.bootfile = optarg;
break;
case 'p':
params.create_pmbr = 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) {
Error("missing drive argument\n");
return CGPT_FAILED;
}
params.drive_name = argv[optind];
return CgptBoot(&params);
}