coreboot-kgpe-d16/util
Aaron Durbin 285111f822 cbfstool: Fix removing and adding file with same name
Currently, cbfstool regressed that removing a file from CBFS the space
is marked as empty but the filename is still shown, preventing adding a
file with the same name again. [1]

```
$ echo a > a
$ echo b > b
$ ./util/cbfstool/cbfstool  test.rom create -m x86 -s 1024
Created CBFS (capacity = 920 bytes)
$ ./util/cbfstool/cbfstool test.rom add -f a -n a -t raw
$ ./util/cbfstool/cbfstool test.rom add -f b -n b -t raw
$ cp test.rom test.rom.original
$ ./util/cbfstool/cbfstool test.rom remove  -n
$ diff -up <(hexdump -C test.rom.original) <(hexdump -C test.rom)
--- /dev/fd/63  2015-08-07 08:43:42.118430961 -0500
+++ /dev/fd/62  2015-08-07 08:43:42.114430961 -0500
@@ -1,4 +1,4 @@
-00000000  4c 41 52 43 48 49 56 45  00 00 00 02 00 00 00 50  |LARCHIVE.......P|
+00000000  4c 41 52 43 48 49 56 45  00 00 00 02 ff ff ff ff  |LARCHIVE........|
 00000010  00 00 00 00 00 00 00 28  61 00 00 00 00 00 00 00  |.......(a.......|
 00000020  00 00 00 00 00 00 00 00  61 0a ff ff ff ff ff ff  |........a.......|
 00000030  ff ff ff ff ff ff ff ff  ff ff ff ff ff ff ff ff  |................|
$ ./util/cbfstool/cbfstool test.rom add -f c -n c -t raw

$ ./util/cbfstool/cbfstool test.rom print
test.rom: 1 kB, bootblocksize 0, romsize 1024, offset 0x0
alignment: 64 bytes, architecture: x86

Name                           Offset     Type         Size
c                              0x0        raw          2
b                              0x40       raw          2
(empty)                        0x80       null         792
```

So it is “deteled” as the type changed. But the name was not changed to
match the *(empty)* heuristic.

So also adapt the name when removing a file by writing a null byte to
the beginning of the name, so that the heuristic works. (Though remove
doesn't really clear contents.)

```
$ ./util/cbfstool/cbfstool test.rom remove  -n c
$ ./util/cbfstool/cbfstool test.rom print
test.rom: 1 kB, bootblocksize 0, romsize 1024, offset 0x0
alignment: 64 bytes, architecture: x86

Name                           Offset     Type         Size
(empty)                        0x0        null         2
b                              0x40       raw          2
(empty)                        0x80       null         792
```

[1] http://www.coreboot.org/pipermail/coreboot/2015-August/080201.html

Change-Id: I033456ab10e3e1b402ac2374f3a887cefd3e5abf
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Signed-off-by: Paul Menzel <paulepanter@users.sourceforge.net>
Reviewed-on: http://review.coreboot.org/11632
Tested-by: build bot (Jenkins)
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
2015-10-17 06:57:50 +00:00
..
abuild abuild: add a command line parameter for junit filename 2015-10-15 12:21:19 +00:00
acpi Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
amdtools Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
arm_boot_tools/mksunxiboot arm_boot_tools: Add 'b' to fopen flags for Windows compatibility 2014-12-19 18:55:34 +01:00
autoport autoport: Fix ectool arguments. 2015-10-11 10:25:17 +00:00
bimgtool bimgtool: initialize data header 2015-06-12 23:16:01 +02:00
board_status Revert "Remove FSP Rangeley SOC and mohonpeak board support" 2015-10-14 22:49:03 +00:00
broadcom secimage: Use libz's crc32 function 2015-08-09 12:34:24 +02:00
cbfstool cbfstool: Fix removing and adding file with same name 2015-10-17 06:57:50 +00:00
cbmem util/cbmem: Fix failure with certain cbmem base alignments 2015-10-16 20:23:33 +00:00
crossgcc buildgcc: Fix the binutils-no-doc patch with 2.25 2015-10-05 17:22:41 +00:00
dtd_parser Remove address from GPLv2 headers 2015-05-21 20:50:25 +02:00
ectool util/ectool: don't dump the whole ram when writing to it 2015-07-06 23:11:03 +02:00
exynos exynos: Install the BL1 and set the checksum in the Makefile. 2014-09-09 20:01:18 +02:00
fletcher util/fletcher: fix debug option parsing 2014-10-18 14:45:42 +02:00
genbuild_h genbuild_h: Add Mac OS to case of "data -r" 2015-09-10 02:14:04 +00:00
genprof util/genprof: improve handling of command line arguments 2014-08-12 09:02:44 +02:00
gitconfig gitconfig/rebase.sh: adapt default branch name 2015-08-28 18:41:21 +00:00
ifdfake ifdfake: allow "base+size" description of regions 2015-09-21 13:01:22 +00:00
ifdtool ifdtool: Properly set + decode flmstr regs for IFD v2 2015-09-17 14:17:31 +00:00
inteltool inteltool: Add function to generate SPD dump. 2015-10-11 15:01:05 +00:00
intelvbttool VBT parser. 2015-05-25 18:19:51 +02:00
ipqheader Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
k8resdump Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
kconfig kconfig: fix build for xconfig, too 2015-10-01 20:14:13 +00:00
lint lint: Fix shellcheck warnings, add comments 2015-10-17 06:16:49 +00:00
msrtool Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
nvidia nvidia/cbootimage: update to 1.5 2015-04-25 12:16:58 +02:00
nvramtool Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
optionlist Remove address from GPLv2 headers 2015-05-21 20:50:25 +02:00
release release: add release script 2015-07-16 17:40:42 +02:00
rockchip add make_idb.py & update bootblock 2015-03-24 15:24:52 +01:00
romcc Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
sconfig Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
scripts util/scripts: add some support scripts 2015-06-30 08:24:38 +02:00
showdevicetree Remove address from GPLv2 headers 2015-05-21 20:50:25 +02:00
spkmodem_recv Add spkmodem receiver 2013-06-12 05:18:24 +02:00
superiotool Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
uio_usbdebug Remove address from GPLv2 headers 2015-05-21 20:50:25 +02:00
vgabios Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
viatool Remove empty lines at end of file 2015-06-08 00:55:07 +02:00
xcompile arm64: xcompile: Add support for A53 erratum 843419 2015-08-28 06:46:09 +00:00