u-boot-brain/fs
AKASHI Takahiro 39606d462c fs: fat: handle deleted directory entries correctly
Unlink test for FAT file system seems to fail at test_unlink2.
(When I added this test, I haven't seen any errors though.)
for example,
===8<===
fs_obj_unlink = ['fat', '/home/akashi/tmp/uboot_sandbox_test/128MB.fat32.img']

    def test_unlink2(self, u_boot_console, fs_obj_unlink):
        """
        Test Case 2 - delete many files
        """
        fs_type,fs_img = fs_obj_unlink
        with u_boot_console.log.section('Test Case 2 - unlink (many)'):
            output = u_boot_console.run_command('host bind 0 %s' % fs_img)

            for i in range(0, 20):
                output = u_boot_console.run_command_list([
                    '%srm host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i),
                    '%sls host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i)])
                assert('' == ''.join(output))

            output = u_boot_console.run_command(
                '%sls host 0:0 dir2' % fs_type)
>           assert('0 file(s), 2 dir(s)' in output)
E           AssertionError: assert '0 file(s), 2 dir(s)' in '            ./\r\r\n            ../\r\r\n        0   0123456789abcdef11\r\r\n\r\r\n1 file(s), 2 dir(s)'

test/py/tests/test_fs/test_unlink.py:52: AssertionError
===>8===

This can happen when fat_itr_next() wrongly detects an already-
deleted directory entry.

File deletion, which was added in the commit f8240ce95d ("fs: fat:
support unlink"), is implemented by marking its entry for a short name
with DELETED_FLAG, but related entry slots for a long file name are kept
unmodified. (So entries will never be actually deleted from media.)

To handle this case correctly, an additional check for a directory slot
will be needed in fat_itr_next().

In addition, I added extra comments about long file name and short file
name format in FAT file system. Although they are not directly related
to the issue, I hope it will be helpful for better understandings
in general.

Signed-off-by: AKASHI Takahiro <takahiro.akashi@linaro.org>
2019-12-05 10:28:38 -05:00
..
btrfs fs: btrfs: add zstd decompression support 2019-05-05 08:48:50 -04:00
cbfs cbfs: Rename camel-case variables 2019-08-18 21:54:10 +08:00
cramfs SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ext4 CVE-2019-13106: ext4: fix out-of-bounds memset 2019-07-18 11:31:29 -04:00
fat fs: fat: handle deleted directory entries correctly 2019-12-05 10:28:38 -05:00
jffs2 crc32: Use the crc.h header for crc functions 2019-12-02 18:23:08 -05:00
reiserfs SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sandbox SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ubifs crc32: Use the crc.h header for crc functions 2019-12-02 18:23:08 -05:00
yaffs2 common: Move sorting functions to their own header file 2019-12-02 18:23:08 -05:00
zfs SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
fs_internal.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
fs.c fs: add fs_get_type() for current filesystem type 2019-10-17 19:19:56 +02:00
Kconfig fs: btrfs: Add U-Boot fs handlers. 2017-10-02 21:52:18 -04:00
Makefile cbfs: Allow CBFS to be used in SPL 2019-08-18 21:54:10 +08:00