util/cbfstool: Remove existing file for add-int command

Since add-int is intended for manipulating options stored as integers in
CBFS (such as SeaBIOS runtime config options), removing the file so that
it can be re-added with a new value is a common action. Attempt to
remove the existing integer automatically if it already exists to remove
the need for the extra step.

Change-Id: I5a0ac409fc9b91a4f7c0c35650875d6211ac2b25
Signed-off-by: Nicholas Chin <nic.c3.14@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/86009
Reviewed-by: Julius Werner <jwerner@chromium.org>
Reviewed-by: Subrata Banik <subratabanik@google.com>
Reviewed-by: Kapil Porwal <kapilporwal@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Nicholas Chin 2025-01-15 17:47:25 -07:00 committed by Subrata Banik
commit 8dda86c3e1

View file

@ -653,8 +653,10 @@ static int cbfs_add_integer_component(const char *name,
}
if (cbfs_get_entry(&image, name)) {
ERROR("'%s' already in ROM image.\n", name);
goto done;
if (cbfs_remove_entry(&image, name) != 0) {
ERROR("Removing file '%s' failed.\n", name);
goto done;
}
}
header = cbfs_create_file_header(CBFS_TYPE_RAW,