[PATCH v2 0/5] fs/fat: fix handling of full disk

Heinrich Schuchardt heinrich.schuchardt at canonical.com
Sun Jul 31 13:58:32 CEST 2022

Currently we have two functions with redundant coding to find an empty

* find_empty_cluster() seeks from the beginning of the FAT table
* determine_fatent() seeks after a given entry

Both do not detect the end of the FAT table correctly and return an invalid
cluster number if no empty entry if found.

Correctly determine empty FAT entries and full disk correctly.

Carve out a function for creating directory entries to avoid code

Provide a unit test checking that a full FAT16 root directory is
recognized. For other file systems testing is too time consuming.
FAT32 allows 65536 entries per directory.

	Handle errors returned by fat_create_dir_entry()
	Add unit test

Heinrich Schuchardt (5):
  fs: fat: finding an empty FAT cluster
  fs: fat: determine_fatent() error handling
  fs: fat: carve out fat_create_dir_entry()
  test: let fs_obj_mkdir() provide full file system type
  test: add test for full FAT16 directory

 fs/fat/fat_write.c                  | 161 ++++++++++++++--------------
 test/py/tests/test_fs/conftest.py   |   6 +-
 test/py/tests/test_fs/test_mkdir.py |  72 ++++++++-----
 3 files changed, 131 insertions(+), 108 deletions(-)


More information about the U-Boot mailing list