diff options
author | Gabe Black <gabeblack@google.com> | 2012-01-27 00:33:47 -0800 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2012-04-02 18:39:08 +0200 |
commit | e1bb49e2ece1eda6a3d566b48b7a8e50a3469f63 (patch) | |
tree | c26d5c701a82d620aa87dfae071571faee200a3d /util/cbfstool/cbfstool.c | |
parent | dd30acdd590f6a39a5d3c4a38e3d949e73b5e2fa (diff) | |
download | coreboot-e1bb49e2ece1eda6a3d566b48b7a8e50a3469f63.tar.xz |
Add a "remove" command to cbfstool
This command removes the first file it finds with the given name by changing
its type to CBFS_COMPONENT_NULL and setting the first character of its name to
a null terminator. If the "files" immediately before or after the target file
are already marked as empty, they're all merged together into one large file.
Change-Id: Idc6b2a4c355c3f039c2ccae81866e3ed6035539b
Signed-off-by: Gabe Black <gabeblack@google.com>
Reviewed-by: Ronald G. Minnich <rminnich@google.com>
Reviewed-on: http://review.coreboot.org/814
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r-- | util/cbfstool/cbfstool.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 939221e66d..9dbdc1c11a 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -29,6 +29,7 @@ typedef enum { CMD_ADD, CMD_ADD_PAYLOAD, CMD_ADD_STAGE, + CMD_REMOVE, CMD_CREATE, CMD_LOCATE, CMD_PRINT, @@ -195,6 +196,33 @@ static int cbfs_add_stage(int argc, char **argv) return 0; } +static int cbfs_remove(int argc, char **argv) +{ + char *romname = argv[1]; + char *cmd = argv[2]; + void *rom = loadrom(romname); + + if (rom == NULL) { + printf("Could not load ROM image '%s'.\n", romname); + return 1; + } + + if (argc < 4) { + printf("not enough arguments to '%s'.\n", cmd); + return 1; + } + + char *cbfsname = argv[3]; + + if (remove_file_from_cbfs(cbfsname)) { + printf("Removing file '%s' failed.\n", cbfsname); + return 1; + } + if (writerom(romname, rom, romsize)) + return 1; + return 0; +} + static int cbfs_create(int argc, char **argv) { char *romname = argv[1]; @@ -275,6 +303,7 @@ static const struct command commands[] = { {CMD_ADD, "add", cbfs_add}, {CMD_ADD_PAYLOAD, "add-payload", cbfs_add_payload}, {CMD_ADD_STAGE, "add-stage", cbfs_add_stage}, + {CMD_REMOVE, "remove", cbfs_remove}, {CMD_CREATE, "create", cbfs_create}, {CMD_LOCATE, "locate", cbfs_locate}, {CMD_PRINT, "print", cbfs_print}, @@ -292,6 +321,7 @@ static void usage(void) " add FILE NAME TYPE [base address] Add a component\n" " add-payload FILE NAME [COMP] [base] Add a payload to the ROM\n" " add-stage FILE NAME [COMP] [base] Add a stage to the ROM\n" + " remove FILE NAME Remove a component\n" " create SIZE BOOTBLOCK [ALIGN] Create a ROM file\n" " locate FILE NAME ALIGN Find a place for a file of that size\n" " print Show the contents of the ROM\n" |