diff options
author | Bill Richardson <wfrichar@chromium.org> | 2014-07-15 12:52:19 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-07-31 22:46:27 +0000 |
commit | 6f3961507e73f90cec665896dece884e86be560a (patch) | |
tree | 0f11e2ca91c3c5be6ed30748b0d9224c6ede456a /futility/cmd_dump_kernel_config.c | |
parent | b52d7b7acb14743747489ed7323b416bc001503b (diff) | |
download | vboot-6f3961507e73f90cec665896dece884e86be560a.tar.gz |
futility: Add remaining vboot binary utilities
This change adds these formerly external utilities into the futility binary:
dev_sign_file
dump_kernel_config
gbb_utility
vbutil_firmware
vbutil_kernel
These target binaries will remain independent of futility, since they are
not directly related to verified boot:
cgpt
crossystem
tpm_init_temp_fix
tpmc
Also, dumpRSAPublicKey is removed from the target, since it is only used on
the build host to create new keypairs.
This change also add several additional tests.
BUG=chromium:224734
BRANCH=ToT
CQ-DEPEND=CL:210391,CL:210568,CL:210587
TEST=manual
make runtests
make clean
Also build and test:
- normal image
- test image
- recovery image
- firmware shellball
Note that this CL depends on simultaneous changes to the chromeos-initramfs
ebuild.
Change-Id: If791b5e9b5aac218ceafa9f45fc1785f16b91a64
Signed-off-by: Bill Richardson <wfrichar@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210403
Diffstat (limited to 'futility/cmd_dump_kernel_config.c')
-rw-r--r-- | futility/cmd_dump_kernel_config.c | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/futility/cmd_dump_kernel_config.c b/futility/cmd_dump_kernel_config.c new file mode 100644 index 00000000..2d15f99f --- /dev/null +++ b/futility/cmd_dump_kernel_config.c @@ -0,0 +1,93 @@ +/* Copyright 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. + * + * Exports the kernel commandline from a given partition/image. + */ + + +#include <getopt.h> +#include <stdio.h> +#include <sys/mman.h> +#include <unistd.h> + +#include "futility.h" +#include "vboot_host.h" + +enum { + OPT_KLOADADDR = 1000, +}; + +static struct option long_opts[] = { + { "kloadaddr", 1, NULL, OPT_KLOADADDR }, + { NULL, 0, NULL, 0 } +}; + +/* Print help and return error */ +static int PrintHelp(void) { + puts("dump_kernel_config - Prints the kernel command line\n" + "\n" + "Usage: dump_kernel_config [--kloadaddr <ADDRESS>] " + "<image/blockdevice>\n" + "\n" + ""); + return 1; +} + +int do_dump_kernel_config(int argc, char* argv[]) { + char *infile = NULL; + char *config = NULL; + uint64_t kernel_body_load_address = USE_PREAMBLE_LOAD_ADDR; + int parse_error = 0; + char *e; + int i; + + while (((i = getopt_long(argc, argv, ":", long_opts, NULL)) != -1) && + !parse_error) { + switch (i) { + default: + case '?': + /* Unhandled option */ + parse_error = 1; + break; + + case 0: + /* silently handled option */ + break; + + case OPT_KLOADADDR: + kernel_body_load_address = strtoul(optarg, &e, 0); + if (!*optarg || (e && *e)) { + fprintf(stderr, "Invalid --kloadaddr\n"); + parse_error = 1; + } + break; + } + } + + if (optind >= argc) { + fprintf(stderr, "Expected argument after options\n"); + parse_error = 1; + } else + infile = argv[optind]; + + if (parse_error) + return PrintHelp(); + + if (!infile || !*infile) { + fprintf(stderr, "Must specify filename\n"); + return 1; + } + + config = FindKernelConfig(infile, kernel_body_load_address); + if (!config) + return 1; + + printf("%s", config); + + free(config); + return 0; +} + +DECLARE_FUTIL_COMMAND(dump_kernel_config, do_dump_kernel_config, + "Prints the kernel command line"); |