[coreboot-gerrit] Patch merged into coreboot/master: cbfstool: Fix removing and adding file with same name

gerrit at coreboot.org gerrit at coreboot.org
Sat Oct 17 08:57:53 CEST 2015


the following patch was just integrated into master:
commit 285111f822f38124df488514e34298ce1a1e341c
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Sat Aug 8 20:25:17 2015 +0200

    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 at chromium.org>
    Signed-off-by: Paul Menzel <paulepanter at users.sourceforge.net>
    Reviewed-on: http://review.coreboot.org/11632
    Tested-by: build bot (Jenkins)
    Tested-by: Raptor Engineering Automated Test Stand <noreply at raptorengineeringinc.com>


See http://review.coreboot.org/11632 for details.

-gerrit



More information about the coreboot-gerrit mailing list