diff options
author | Nam T. Nguyen <namnguyen@chromium.org> | 2015-02-12 11:10:35 -0800 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-02-19 21:17:02 +0000 |
commit | f44ebbe36b2c1603437edc57b534244e89bfcd9c (patch) | |
tree | d6cc323f025c33331e9f76f52468a83b058cf915 /futility | |
parent | a0f7ab5567529af71516559773eca2557f8d8005 (diff) | |
download | vboot-f44ebbe36b2c1603437edc57b534244e89bfcd9c.tar.gz |
vboot_reference: Support MTD devices in dump_kernel_configstabilize-js-6812.26.Bstabilize-js-6812.25.Bstabilize-js-6812.21.Bstabilize-6812.83.Bstabilize-6812.75.Bstabilize-6812.41.Bstabilize-6812.34.Bstabilize-6812.29.Bstabilize-6812.15.Bstabilize-6812.14.Bstabilize-6812.13.Brelease-R42-6812.Bfactory-ryu-6486.14.B
This CL implements a read function that works with MTD devices in
dump_kernel_config.
BUG=chromium:457862
BRANCH=none
TEST=make runtests
TEST=try on storm_nand
Change-Id: Id784d422de64e7918b163005c0b426d727d2115e
Reviewed-on: https://chromium-review.googlesource.com/249271
Reviewed-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
Trybot-Ready: Nam Nguyen <namnguyen@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Diffstat (limited to 'futility')
-rw-r--r-- | futility/dump_kernel_config_lib.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/futility/dump_kernel_config_lib.c b/futility/dump_kernel_config_lib.c index 1baa2d58..c2d59433 100644 --- a/futility/dump_kernel_config_lib.c +++ b/futility/dump_kernel_config_lib.c @@ -18,6 +18,12 @@ #include "vboot_api.h" #include "vboot_host.h" +#ifdef USE_MTD +#include <linux/major.h> +#include <mtd/mtd-user.h> +#include <mtdutils.h> +#endif + typedef ssize_t (*ReadFullyFn)(void *ctx, void *buf, size_t count); static ssize_t ReadFullyWithRead(void *ctx, void *buf, size_t count) @@ -37,6 +43,14 @@ static ssize_t ReadFullyWithRead(void *ctx, void *buf, size_t count) return nr_read; } +#ifdef USE_MTD +static ssize_t ReadFullyWithMtdRead(void *ctx, void *buf, size_t count) +{ + MtdReadContext *mtd_ctx = (MtdReadContext*)ctx; + return mtd_read_data(mtd_ctx, buf, count); +} +#endif + /* Skip the stream by calling |read_fn| many times. Return 0 on success. */ static int SkipWithRead(void *ctx, ReadFullyFn read_fn, size_t count) { @@ -130,9 +144,32 @@ char *FindKernelConfig(const char *infile, uint64_t kernel_body_load_address) void *ctx = &fd; ReadFullyFn read_fn = ReadFullyWithRead; +#ifdef USE_MTD + struct stat stat_buf; + if (fstat(fd, &stat_buf)) { + VbExError("Cannot stat %s\n", infile); + return NULL; + } + + int is_mtd = (major(stat_buf.st_rdev) == MTD_CHAR_MAJOR); + if (is_mtd) { + ctx = mtd_read_descriptor(fd, infile); + if (!ctx) { + VbExError("Cannot read from MTD device %s\n", infile); + return NULL; + } + read_fn = ReadFullyWithMtdRead; + } +#endif + newstr = FindKernelConfigFromStream(ctx, read_fn, kernel_body_load_address); +#ifdef USE_MTD + if (is_mtd) { + mtd_read_close(ctx); + } +#endif close(fd); return newstr; |