30 May, 2019

1 commit


24 May, 2019

1 commit

  • The FAT16/12 has rootdir area before data area, and the clusters for
    rootdir are not mantained by FAT table. So we don't need to find empty
    cluster for next rootdir space, just use next dir cluster. And the FAT
    table don't need to update for this new dir cluster.

    Signed-off-by: Ye Li
    Acked-by: Peng Fan
    (cherry picked from commit 9e0a33cacc0a7926d46c0ca184498ae88278816e)

    Ye Li
     

01 Mar, 2019

1 commit

  • When compiling with DEBUG=1 an error
    fs/fat/fat_write.c:831: undefined reference to `__aeabi_ldivmod'
    occurred.

    We should use do_div() instead of the modulus operator.

    filesize and cur_pos cannot be negative. So let's use u64 to avoid
    warnings.

    Fixes: cb8af8af5ba0 ("fs: fat: support write with non-zero offset")
    Signed-off-by: Heinrich Schuchardt

    Heinrich Schuchardt
     

19 Feb, 2019

2 commits


01 Feb, 2019

1 commit


11 Jan, 2019

1 commit

  • This particular commit is causing a regression on stih410-b2260 and
    other platforms when reading from FAT16. Noting that I had rebased the
    original fix from Thomas onto then-current master, there is also
    question from Akashi-san if the change is still needed after other FAT
    fixes that have gone in.

    This reverts commit a68b0e11ea774492713a65d9fd5bb525fcaefff3.

    Reported-by: Patrice Chotard
    Cc: AKASHI Takahiro
    Cc: Thomas RIENOESSL
    Signed-off-by: Tom Rini

    Tom Rini
     

07 Dec, 2018

2 commits

  • The long name apparently can be accumulated using multiple
    13-byte slots. Unfortunately we never checked how many we
    can actually fit in the buffer we are reading to.

    Signed-off-by: Patrick Wildt

    Patrick Wildt
     
  • The cluster size specifies how many sectors make up a cluster. A
    cluster size of zero makes no sense, as it would mean that the
    cluster is made up of no sectors. This will later lead into a
    division by zero in sect_to_clust(), so better take care of that
    early.

    The MAX_CLUSTSIZE define can reduced using a define to make some
    room in low-memory system. Unfortunately if the code reads a
    filesystem with a bigger cluster size it will overflow the buffer.

    Signed-off-by: Patrick Wildt

    Patrick Wildt
     

21 Nov, 2018

1 commit


16 Oct, 2018

1 commit


07 Oct, 2018

2 commits


24 Sep, 2018

13 commits

  • The FAT driver supports unaligned reads and writes and EFI applications
    will make use of these. So a misaligned buffer is only worth a debug
    message.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     
  • In this patch, unlink support is added to FAT file system.
    A directory can be deleted only if it is empty.

    In this implementation, only a directory entry for a short file name
    will be removed. So entries for a long file name can and should be
    reclaimed with fsck.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, mkdir support is added to FAT file system.
    A newly created directory contains only "." and ".." entries.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • The starting cluster number of directory is needed to initialize ".."
    (parent directory) entry when creating a new directory.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, all the necessary code for allowing for a file offset
    at write is implemented. What plays a major roll here is get_set_cluster(),
    which, in contrast to its counterpart, set_cluster(), only operates on
    already-allocated clusters, overwriting with data.

    So, with a file offset specified, set_contents() seeks and writes data
    with set_get_cluster() until the end of a file, and, once it reaches
    there, continues writing with set_cluster() for the rest.

    Please note that a file will be trimmed as a result of write operation if
    write ends before reaching file's end. This is an intended behavior
    in order to maintain compatibility with the current interface.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • The current write implementation is quite simple: remove existing clusters
    and then allocating new ones and filling them with data. This, inevitably,
    enforces always writing from the beginning of a file.

    As the first step to lift this restriction, fat_file_write() and
    set_contents() are modified to accept an additional parameter, file offset
    and further re-factored so that, in the next patch, all the necessary code
    will be put into set_contents().

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In this patch, write implementation is overhauled and rewritten by
    making full use of directory iterator. The obvious bonus is that we are
    now able to write to a file with a directory path, like /A/B/C/FILE.

    Please note that, as there is no notion of "current directory" on u-boot,
    a file name specified must contain an absolute directory path. Otherwise,
    "/" (root directory) is assumed.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • It would be good that FAT write function return error code instead of
    just returning -1 as fat_read_file() does.
    This patch attempts to address this issue although it is 'best effort
    (or estimate)' for now.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • FAT file system's long file name support is a bit complicated and has some
    restrictions on its naming. We should be careful about it especially for
    write as it may easily end up with wrong file system.

    normalize_longname() check for the rules and normalize a file name
    if necessary. Please note, however, that this function is yet to be
    extended to fully comply with the standard.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • This reverts commit 0dc1bfb7302d220a48364263d5632d6d572b069b.
    The succeeding patch series will supersede it.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • In my attempt to re-work write operation, it was revealed that iterator's
    "clust" does not always point to a cluster to which a current directory
    entry ("dent") belongs.
    This patch assures that it is always true by adding "next_clust" which is
    used solely for dereferencing a cluster chain.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • FAT's root directory does not have "." nor ".."
    So care must be taken when scanning root directory with fat_itr_resolve().
    Without this patch, any file path starting with "." or ".." will not be
    resolved at all.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     
  • get_fs_info() was introduced in major re-work of read operation by Rob.
    We want to reuse this function in write operation by extending it with
    additional members in fsdata structure.

    Signed-off-by: AKASHI Takahiro
    Signed-off-by: Alexander Graf

    AKASHI Takahiro
     

20 Aug, 2018

1 commit


25 Jul, 2018

1 commit

  • fs_fat_write() is not able to write to subdirectories.

    Currently if a filepath with a leading slash is passed, the slash is
    treated as part of the filename to be created in the root directory.

    Strip leading (back-)slashes.

    Check that the remaining filename does not contain any illegal characters
    (<>:"/\|?*). This way we will throw an error when trying to write to a
    subdirectory.

    Signed-off-by: Heinrich Schuchardt
    Signed-off-by: Alexander Graf

    Heinrich Schuchardt
     

07 May, 2018

1 commit

  • When U-Boot started using SPDX tags we were among the early adopters and
    there weren't a lot of other examples to borrow from. So we picked the
    area of the file that usually had a full license text and replaced it
    with an appropriate SPDX-License-Identifier: entry. Since then, the
    Linux Kernel has adopted SPDX tags and they place it as the very first
    line in a file (except where shebangs are used, then it's second line)
    and with slightly different comment styles than us.

    In part due to community overlap, in part due to better tag visibility
    and in part for other minor reasons, switch over to that style.

    This commit changes all instances where we have a single declared
    license in the tag as both the before and after are identical in tag
    contents. There's also a few places where I found we did not have a tag
    and have introduced one.

    Signed-off-by: Tom Rini

    Tom Rini
     

23 Jan, 2018

2 commits


20 Jan, 2018

1 commit


10 Jan, 2018

1 commit


30 Nov, 2017

1 commit

  • Before this patch one could receive following errors when executing "fatls"
    command on machine with cache enabled (ex i.MX6Q) :

    => fatls mmc 0:1
    CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8]
    CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8]
    ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x4f59dfc8
    ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x4f59e7c8
    CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8]
    CACHE: Misaligned operation at range [4f59dfc8, 4f59e7c8]
    ERROR: v7_outer_cache_inval_range - start address is not aligned - 0x4f59dfc8
    ERROR: v7_outer_cache_inval_range - stop address is not aligned - 0x4f59e7c8

    To alleviate this problem - the calloc()s have been replaced with
    malloc_cache_aligned() and memset().

    After those changes the buffers are properly aligned (with both start
    address and size) to SoC cache line.

    Fixes: 09fa964bba80 ("fs/fat: Fix 'CACHE: Misaligned operation at range' warnings")
    Suggested-by: Lukasz Majewski
    Signed-off-by: Neil Armstrong
    Reviewed-by: Lukasz Majewski
    Reviewed-by: Fabio Estevam

    Neil Armstrong
     

09 Oct, 2017

2 commits

  • Check malloc() return values and properly unwind on errors so
    memory allocated for fat_itr structures get freed properly.

    Also fixes a leak of fsdata.fatbuf in fat_size().

    Fixes: 2460098cffacd1 ("fs/fat: Reduce stack usage")
    Reported-by: Coverity (CID: 167225, 167233, 167234)
    Signed-off-by: Tuomas Tynkkynen
    Reviewed-by: Tom Rini

    Tuomas Tynkkynen
     
  • The 'block' field of fat_itr needs to be properly aligned for DMA and
    while it does have '__aligned(ARCH_DMA_MINALIGN)', the fat_itr structure
    itself needs to be properly aligned as well.

    While at it use malloc_cache_aligned() for the other aligned allocations
    in the file as well.

    Fixes: 2460098cffacd1 ("fs/fat: Reduce stack usage")
    Signed-off-by: Tuomas Tynkkynen
    Reviewed-by: Tom Rini

    Tuomas Tynkkynen
     

06 Oct, 2017

1 commit

  • If we end up back in the root directory via a '..' directory entry, set
    itr->is_root accordingly. Failing to do that gives spews like
    "Invalid FAT entry" and being unable to access directory entries located
    past the first cluster of the root directory.

    Fixes: 8eafae209c35 ("fat/fs: convert to directory iterators")
    Reviewed-by: Tom Rini
    Signed-off-by: Tuomas Tynkkynen

    Tuomas Tynkkynen
     

22 Sep, 2017

1 commit

  • We have limited stack in SPL builds. Drop itrblock and move to
    malloc/free of itr to move this off of the stack. As part of this fix a
    double-free issue in fat_size().

    Signed-off-by: Tom Rini
    ---
    Rework to use malloc/free as moving this to a global overflows some SH
    targets.

    Tom Rini
     

15 Sep, 2017

2 commits

  • A new fatbuf was allocated by get_fs_info() (called by fat_itr_root()),
    but not freed, resulting in eventually running out of memory. Spotted
    by running 'ls -r' in a large FAT filesystem from Shell.efi.

    fatbuf is mainly used to cache FAT entry lookups (get_fatent())..
    possibly once fat_write.c it can move into the iterator to simplify
    this.

    Signed-off-by: Rob Clark
    Reviewed-by: Simon Glass
    Reviewed-by: Łukasz Majewski

    Rob Clark
     
  • Use the clust_to_sect() helper that was introduced earlier, and add an
    inverse sect_to_clust(), plus update the various spots that open-coded
    this conversion previously.

    Signed-off-by: Rob Clark
    Reviewed-by: Simon Glass

    Rob Clark