[U-Boot] [PATCH 1/3] fs-test: Add FAT16 support
Rob Clark
robdclark at gmail.com
Sun Sep 24 21:48:30 UTC 2017
On Sun, Sep 24, 2017 at 5:07 PM, Tuomas Tynkkynen
<tuomas.tynkkynen at iki.fi> wrote:
> Currently we can only test FAT32 which is the default FAT version that
> mkfs.vfat creates by default. Instead make it explicitly create either a
> FAT16 or a FAT32 volume. This allows us to exercise more code, for
> instance the root directory handling is done differently in FAT32 than
> the older FATs.
>
> Adding FAT12 support is a much bigger job since the test creates a 2.5GB
> file and the FAT12 maximum partition size is way smaller than that.
Thanks
Note that fat12 and fat16 work more similar to each other (other than
file allocation table size) compared to fat32. (fat12 and fat16 have
a single contiguous root directory, whereas fat32 has a root directory
constructed from a chain of clusters, more like how subdirectories
work on earlier fat versions).
That said, I think we could probably increase test coverage w/ much
smaller filesys image sizes.. my current wishlist:
+ bunch of small files w/ long vfat names, enough that the directory
spans multiple clusters.. depends a bit on sector/cluster size but
>128 should do the trick.. there might end up being a lower limit on
root directory in fat12/fat16 so this could be a subdir
+ we don't need huge files, but something bigger than cluster size..
1MB should be sufficient
BR,
-R
> Signed-off-by: Tuomas Tynkkynen <tuomas.tynkkynen at iki.fi>
> ---
> test/fs/fs-test.sh | 41 +++++++++++++++++++++++++++--------------
> 1 file changed, 27 insertions(+), 14 deletions(-)
>
> diff --git a/test/fs/fs-test.sh b/test/fs/fs-test.sh
> index b19486419e..2ddac50f90 100755
> --- a/test/fs/fs-test.sh
> +++ b/test/fs/fs-test.sh
> @@ -41,7 +41,7 @@ SMALL_FILE="1MB.file"
> BIG_FILE="2.5GB.file"
>
> # $MD5_FILE will have the expected md5s when we do the test
> -# They shall have a suffix which represents their file system (ext4/fat)
> +# They shall have a suffix which represents their file system (ext4/fat16/...)
> MD5_FILE="${OUT_DIR}/md5s.list"
>
> # $OUT shall be the prefix of the test output. Their suffix will be .out
> @@ -104,15 +104,25 @@ function prepare_env() {
> }
>
> # 1st parameter is the name of the image file to be created
> -# 2nd parameter is the filesystem - fat ext4 etc
> +# 2nd parameter is the filesystem - fat16 ext4 etc
> # -F cant be used with fat as it means something else.
> function create_image() {
> # Create image if not already present - saves time, while debugging
> - if [ "$2" = "ext4" ]; then
> + case "$2" in
> + fat16)
> + MKFS_OPTION="-F 16"
> + FS_TYPE="fat"
> + ;;
> + fat32)
> + MKFS_OPTION="-F 32"
> + FS_TYPE="fat"
> + ;;
> + ext4)
> MKFS_OPTION="-F"
> - else
> - MKFS_OPTION=""
> - fi
> + FS_TYPE="ext4"
> + ;;
> + esac
> +
> if [ ! -f "$1" ]; then
> fallocate -l 3G "$1" &> /dev/null
> if [ $? -ne 0 ]; then
> @@ -123,8 +133,8 @@ function create_image() {
> exit $?
> fi
> fi
> - mkfs -t "$2" $MKFS_OPTION "$1" &> /dev/null
> - if [ $? -ne 0 -a "$2" = "fat" ]; then
> + mkfs -t "$FS_TYPE" $MKFS_OPTION "$1" &> /dev/null
> + if [ $? -ne 0 -a "$FS_TYPE" = "fat" ]; then
> # If we fail and we did fat, try vfat.
> mkfs -t vfat $MKFS_OPTION "$1" &> /dev/null
> fi
> @@ -136,7 +146,7 @@ function create_image() {
> }
>
> # 1st parameter is image file
> -# 2nd parameter is file system type - fat/ext4
> +# 2nd parameter is file system type - fat16/ext4/...
> # 3rd parameter is name of small file
> # 4th parameter is name of big file
> # 5th parameter is fs/nonfs/sb - to dictate generic fs commands or
> @@ -149,7 +159,7 @@ function test_image() {
> length="0x00100000"
>
> case "$2" in
> - fat)
> + fat*)
> FPATH=""
> PREFIX="fat"
> WRITE="write"
> @@ -550,7 +560,7 @@ TOTAL_PASS=0
> # In each loop, for a given file system image, we test both the
> # fs command, like load/size/write, the file system specific command
> # like: ext4load/ext4size/ext4write and the sb load/ls/save commands.
> -for fs in ext4 fat; do
> +for fs in ext4 fat16 fat32; do
>
> echo "Creating $fs image if not already present."
> IMAGE=${IMG}.${fs}.img
> @@ -563,11 +573,14 @@ for fs in ext4 fat; do
>
> # Lets mount the image and test sb hostfs commands
> mkdir -p "$MOUNT_DIR"
> - if [ "$fs" = "fat" ]; then
> + case "$fs" in
> + fat*)
> uid="uid=`id -u`"
> - else
> + ;;
> + *)
> uid=""
> - fi
> + ;;
> + esac
> sudo mount -o loop,rw,$uid "$IMAGE" "$MOUNT_DIR"
> sudo chmod 777 "$MOUNT_DIR"
>
> --
> 2.13.0
>
More information about the U-Boot
mailing list