mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
Bit 2 in the GPT partition attributes has been allocated as the legacy bios boot (equivalent to the "active" or "boot" flag in MBR). If we try to boot images on newer x86 systems, syslinux dies because it can't find any GPT partition marked bootable. Update the various parts of cgpt add & show to manage this bit. Now we can run: cgpt add -i 12 -B 1 chromiumos_image.bin And the EFI partition will be marked bootable. BUG=chromium:644845 TEST=vboot_reference unittests pass TEST=booted an amd64-generic disk image via USB on a generic laptop BRANCH=None Change-Id: I78e17b8df5b0c61e9e2d8a3c703e6d5ad230fe92 Reviewed-on: https://chromium-review.googlesource.com/382411 Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org>
120 lines
2.8 KiB
C
120 lines
2.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.
|
|
|
|
#define __STDC_FORMAT_MACROS
|
|
#include <getopt.h>
|
|
#include <inttypes.h>
|
|
#include <string.h>
|
|
|
|
#include "cgpt.h"
|
|
#include "vboot_host.h"
|
|
|
|
extern const char* progname;
|
|
|
|
static void Usage(void)
|
|
{
|
|
printf("\nUsage: %s show [OPTIONS] DRIVE\n\n"
|
|
"Display the GPT table\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"
|
|
" -n Numeric output only\n"
|
|
" -v Verbose output\n"
|
|
" -q Quick output\n"
|
|
" -i NUM Show specified partition only - pick one of:\n"
|
|
" -b beginning sector\n"
|
|
" -s partition size\n"
|
|
" -t type guid\n"
|
|
" -u unique guid\n"
|
|
" -l label\n"
|
|
" -S Successful flag\n"
|
|
" -T Tries flag\n"
|
|
" -P Priority flag\n"
|
|
" -B Legacy Boot flag\n"
|
|
" -A raw 16-bit attribute value (bits 48-63)\n"
|
|
" -d Debug output (including invalid headers)\n"
|
|
"\n", progname);
|
|
}
|
|
|
|
int cmd_show(int argc, char *argv[]) {
|
|
CgptShowParams params;
|
|
memset(¶ms, 0, sizeof(params));
|
|
|
|
int c;
|
|
int errorcnt = 0;
|
|
char *e = 0;
|
|
|
|
opterr = 0; // quiet, you
|
|
while ((c=getopt(argc, argv, ":hnvqi:bstulSTPBAdD:")) != -1)
|
|
{
|
|
switch (c)
|
|
{
|
|
case 'D':
|
|
params.drive_size = strtoull(optarg, &e, 0);
|
|
errorcnt += check_int_parse(c, e);
|
|
break;
|
|
case 'n':
|
|
params.numeric = 1;
|
|
break;
|
|
case 'v':
|
|
params.verbose = 1;
|
|
break;
|
|
case 'q':
|
|
params.quick = 1;
|
|
break;
|
|
case 'i':
|
|
params.partition = (uint32_t)strtoul(optarg, &e, 0);
|
|
errorcnt += check_int_parse(c, e);
|
|
break;
|
|
case 'b':
|
|
case 's':
|
|
case 't':
|
|
case 'u':
|
|
case 'l':
|
|
case 'S':
|
|
case 'T':
|
|
case 'P':
|
|
case 'B':
|
|
case 'A':
|
|
params.single_item = c;
|
|
break;
|
|
|
|
case 'd':
|
|
params.debug = 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");
|
|
Usage();
|
|
return CGPT_FAILED;
|
|
}
|
|
|
|
params.drive_name = argv[optind];
|
|
|
|
return CgptShow(¶ms);
|
|
}
|