28 Mar, 2020

1 commit

  • We need to align the cache buffer to ARCH_DMA_MINALIGN in order to avoid
    access errors like

    CACHE: Misaligned operation at range [be0231e0, be0235e0]

    seen on the MCIMX7SABRE.

    Fixes: d5aee659f217 ("fs: ext4: cache extent data")
    Signed-off-by: Jan Kiszka
    Reviewed-by: Tom Rini
    Reviewed-by: Stephen Warren
    Tested-by: Peter Robinson

    Jan Kiszka
     

11 Feb, 2020

1 commit


08 Feb, 2020

2 commits

  • The code for handing file overwrite incorrectly calculated the amount of
    data to write when writing to the last non-cluster aligned chunk. Fix
    this by ensuring that no more data than the 'filesize' is written to disk.
    While touching min()-based calculations, change it to type-safe min_t()
    function.

    Signed-off-by: Marek Szyprowski

    This patch finally fixes the issue revealed by the test script from the
    previous patch. The correctness of the change has been also verified by
    the following additional test scripts:

    --->8-fat_test2.sh---
    #!/bin/bash
    make sandbox_defconfig
    make
    dd if=/dev/zero of=/tmp/10M.img bs=1024 count=10k
    mkfs.vfat -v /tmp/10M.img
    cat >/tmp/cmds </tmp/model/file0001.raw
    yes ABC | head -c 4096 >/tmp/model/file0003.raw
    yes ABC | head -c 4096 >/tmp/model/file0005.raw
    yes DEF | head -c 7936 >/tmp/model/file0007.raw
    mcopy -n -i /tmp/10M.img ::file0001.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0003.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0005.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0007.raw /tmp/result
    hd /tmp/10M.img
    if diff -urq /tmp/model /tmp/result
    then
    echo Test okay
    else
    echo Test fail
    fi
    --->8-fat_test3.sh---
    #!/bin/bash
    make sandbox_defconfig
    make
    dd if=/dev/zero of=/tmp/10M.img bs=1024 count=10k
    mkfs.vfat -v /tmp/10M.img
    cat >/tmp/cmds </tmp/model/file0001.raw
    yes ABC | head -c 4096 >/tmp/model/file0003.raw
    yes ABC | head -c 4096 >/tmp/model/file0005.raw
    yes DEF | head -c 8448 >/tmp/model/file0007.raw
    mcopy -n -i /tmp/10M.img ::file0001.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0003.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0005.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0007.raw /tmp/result
    hd /tmp/10M.img
    if diff -urq /tmp/model /tmp/result
    then
    echo Test okay
    else
    echo Test fail
    fi
    --->8-fat_test4.sh---
    #!/bin/bash
    make sandbox_defconfig
    make
    dd if=/dev/zero of=/tmp/10M.img bs=1024 count=10k
    mkfs.vfat -v /tmp/10M.img
    cat >/tmp/cmds </tmp/model/file0001.raw
    yes ABC | head -c 4096 >/tmp/model/file0003.raw
    yes ABC | head -c 4096 >/tmp/model/file0005.raw
    yes DEF | head -c 2304 >/tmp/model/file0007.raw
    yes GHI | head -c 2304 >>/tmp/model/file0007.raw
    yes DEF | head -c 2304 >>/tmp/model/file0007.raw
    yes GHI | head -c 2304 >>/tmp/model/file0007.raw
    mcopy -n -i /tmp/10M.img ::file0001.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0003.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0005.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0007.raw /tmp/result
    hd /tmp/10M.img
    if diff -urq /tmp/model /tmp/result
    then
    echo Test okay
    else
    echo Test fail
    fi
    --->8---
    Feel free to prepare a proper sandbox/py_test based tests based on
    the provided test scripts.

    Marek Szyprowski
     
  • The code for handing file overwrite incorrectly assumed that the file on
    disk is always contiguous. This resulted in corrupting disk structure
    every time when write to existing fragmented file happened. Fix this
    by adding proper check for cluster discontinuity and adjust chunk size
    on each partial write.

    Signed-off-by: Marek Szyprowski

    This patch partially fixes the issue revealed by the following test
    script:

    --->8-fat_test1.sh---
    #!/bin/bash
    make sandbox_defconfig
    make
    dd if=/dev/zero of=/tmp/10M.img bs=1024 count=10k
    mkfs.vfat -v /tmp/10M.img
    cat >/tmp/cmds </tmp/model/file0001.raw
    yes ABC | head -c 4096 >/tmp/model/file0003.raw
    yes ABC | head -c 4096 >/tmp/model/file0005.raw
    yes DEF | head -c 16384 >/tmp/model/file0007.raw
    mcopy -n -i /tmp/10M.img ::file0001.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0003.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0005.raw /tmp/result
    mcopy -n -i /tmp/10M.img ::file0007.raw /tmp/result
    hd /tmp/10M.img
    if diff -urq /tmp/model /tmp/result
    then
    echo Test okay
    else
    echo Test fail
    fi
    --->8---

    Overwritting a discontiguous test file (file0007.raw) no longer causes
    corruption to file0003.raw, which's data lies between the chunks of the
    test file. The amount of data written to disk is still incorrect, what
    causes damage to the file (file0005.raw), which's data lies next to the
    test file. This will be fixed by the next patch.

    Feel free to prepare a proper sandbox/py_test based tests based on the
    provided test scripts.

    Marek Szyprowski
     

06 Feb, 2020

2 commits

  • At present dm/device.h includes the linux-compatible features. This
    requires including linux/compat.h which in turn includes a lot of headers.
    One of these is malloc.h which we thus end up including in every file in
    U-Boot. Apart from the inefficiency of this, it is problematic for sandbox
    which needs to use the system malloc() in some files.

    Move the compatibility features into a separate header file.

    Signed-off-by: Simon Glass

    Simon Glass
     
  • At present devres.h is included in all files that include dm.h but few
    make use of it. Also this pulls in linux/compat which adds several more
    headers. Drop the automatic inclusion and require files to include devres
    themselves. This provides a good indication of which files use devres.

    Signed-off-by: Simon Glass
    Reviewed-by: Anatolij Gustschin

    Simon Glass
     

07 Dec, 2019

1 commit


05 Dec, 2019

1 commit

  • 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 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 f8240ce95d64 ("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

    AKASHI Takahiro
     

03 Dec, 2019

2 commits


18 Oct, 2019

3 commits

  • This function is a variant of fs_get_type_name() and returns a filesystem
    type with which the current device is associated.
    We don't want to export fs_type variable directly because we have to take
    care of it consistently within fs.c.

    Signed-off-by: AKASHI Takahiro
    Reviewed-by: Heinrich Schuchardt

    AKASHI Takahiro
     
  • fs_ls(), fs_mkdir() and fs_unlink() sets fs_type to FS_TYPE_ANY
    explicitly, but it is redundant as they call fs_close().
    So just remove those lines.

    Signed-off-by: AKASHI Takahiro
    Reviewed-by: Heinrich Schuchardt

    AKASHI Takahiro
     
  • fs_close() closes the connection to a file system which opened with
    either fs_set_blk_dev() or fs_set_dev_with_part(). Many file system
    functions implicitly call fs_close(), e.g. fs_closedir(), fs_exist(),
    fs_ln(), fs_ls(), fs_mkdir(), fs_read(), fs_size(), fs_write()
    and fs_unlink().
    So just export it.

    Signed-off-by: AKASHI Takahiro
    Reviewed-by: Heinrich Schuchardt

    AKASHI Takahiro
     

12 Oct, 2019

2 commits


26 Aug, 2019

1 commit

  • File was found on specified location. Info about file was read,
    but then immediately destroyed using 'free' call. As a result
    file size was set to 0, hence fat process didn't read any data.

    Premature 'free' call removed. Resources are freed right before
    function return. File is read correctly.

    Signed-off-by: Martin Vystrcil

    Martin Vystrčil
     

21 Aug, 2019

1 commit


18 Aug, 2019

6 commits

  • Rename some camel-case variables to match U-Boot style.

    Camel case is not generally allowed in U-Boot. Rename this variable to fit
    in with the style.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     
  • Sometimes an image has multiple CBFS. The current CBFS API is limited to
    handling only one at time. Also it keeps track of the CBFS internally in
    BSS, which does not work before relocation, for example.

    Add a few new functions to overcome these limitations.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     
  • Move the result variable into the struct also, so that it can be used when
    BSS is not available. Add a function to read it.

    Note that all functions sill use the BSS version of the data.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     
  • At present there are a number of static variables in BSS. This cannot work
    with SPL, at least until BSS is available in board_init_r().

    Move the variables into a struct, so it is possible to malloc() it and use
    it before BSS is available.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     
  • At present this file has a function at the top, above declarations. This
    is normally avoided, so fix it.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     
  • Add a new Kconfig option to enable CBFS in SPL. This can be useful when
    the memory-init code is in CBFS.

    Signed-off-by: Simon Glass
    Reviewed-by: Bin Meng
    Tested-by: Bin Meng

    Simon Glass
     

12 Aug, 2019

2 commits


24 Jul, 2019

1 commit


18 Jul, 2019

6 commits


21 Jun, 2019

1 commit

  • fatload command can be used to load the EFI payload since EFI system
    partition is always a FAT partition. Call into EFI code from do_load()
    to set the device path from which the last binary was loaded. An EFI
    application like grub2 can’t find its configuration file without the
    device path set.

    Since device path is now set in do_load() there is no need to set it
    in do_load_wrapper() for the load command.

    Signed-off-by: Mian Yousaf Kaukab
    Reviewed-by: Heinrich Schuchardt

    Mian Yousaf Kaukab
     

29 May, 2019

5 commits

  • Contrary to fat12/16, fat32 can have root directory at any location
    and its size can be expanded.
    Without this patch, root directory won't grow properly and so we will
    eventually fail to add files under root directory. Please note that this
    can happen even if you delete many files as deleted directory entries
    are not reclaimed but just marked as "deleted" under the current
    implementation.

    Signed-off-by: AKASHI Takahiro
    Tested-by: Heinrich Schuchardt

    AKASHI Takahiro
     
  • When a long name directory entry is created, multiple directory entries
    may be occupied across a directory cluster boundary. Since only one
    directory cluster is cached in a directory iterator, a first cluster must
    be written back to device before switching over a second cluster.

    Without this patch, some added files may be lost even if you don't see
    any failures on write operation.

    Signed-off-by: AKASHI Takahiro
    Tested-by: Heinrich Schuchardt

    AKASHI Takahiro
     
  • With the commit below, fat now correctly handles a file read under
    a non-cluster-aligned root directory of fat12/16.
    Write operation should be fixed in the same manner.

    Fixes: commit 9b18358dc05d ("fs: fat: fix reading non-cluster-aligned
    root directory")
    Signed-off-by: AKASHI Takahiro
    Cc: Anssi Hannula
    Tested-by: Heinrich Schuchardt

    AKASHI Takahiro
     
  • fat_itr_root() allocates fatbuf so we free it on the exit path, if
    the function fails we should not free it, check the return value
    and skip freeing if the function fails.

    Signed-off-by: Andrew F. Davis

    Andrew F. Davis
     
  • File names may not contain control characters (< 0x20).
    Simplify the coding.

    Signed-off-by: Heinrich Schuchardt

    Heinrich Schuchardt
     

05 May, 2019

1 commit


03 May, 2019

1 commit