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
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
-
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
21 Nov, 2018
1 commit
-
This fixes problems accessing drives formated under
Windows as FAT16.Signed-off-by: Thomas RIENOESSL
[trini: Rebase on top of f528c140c801]
Signed-off-by: Tom Rini
16 Oct, 2018
1 commit
-
As observed with clang:
fs/fat/fat_write.c:1024:13: warning: comparison of constant 128
with expression of type 'char' is always false
[-Wtautological-constant-out-of-range-compare]
if ((0x80
Signed-off-by: Alexander Graf
07 Oct, 2018
2 commits
-
Avoid CoverityScan warning SIGN_EXTENSION by changing the type of
parameter size of set_cluster().Avoid leaking stack content when writing an incomplete last sector.
Reported-by: Coverity (CID: 184096)
Signed-off-by: Heinrich Schuchardt -
Do not leak filename_copy in case of error.
Catch out of memory when calling strdup.Reported-by: Coverity (CID: 184086)
Signed-off-by: Heinrich Schuchardt
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
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 -
This reverts commit 0dc1bfb7302d220a48364263d5632d6d572b069b.
The succeeding patch series will supersede it.Signed-off-by: AKASHI Takahiro
Signed-off-by: Alexander Graf -
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 -
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 -
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
20 Aug, 2018
1 commit
-
In order to make the debug print in file_fat_read_at() a tad more useful,
show the offset the file is being read at alongside the filename.Suggested-by: Tero Kristo
Signed-off-by: Andreas Dannenberg
Reviewed-by: Heinrich Schuchardt
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
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
23 Jan, 2018
2 commits
-
fat.h unconditionally defines CONFIG_SUPPORT_VFAT (and has done since
2003), so as a result VFAT support is always enabled regardless of
whether a board config defines it or not. Drop this unnecessary option.Signed-off-by: Tuomas Tynkkynen
-
Signed-off-by: Tuomas Tynkkynen
20 Jan, 2018
1 commit
-
The message "reading %s\n" may be interesting when
debugging but otherwise it is superfluous.Only output the message when debugging.
Signed-off-by: Heinrich Schuchardt
Reviewed-by: Simon Glass
10 Jan, 2018
1 commit
-
commit 21a24c3bf35b ("fs/fat: fix case for FAT shortnames") made it
possible that get_name() returns file names with some upper cases.
find_directory_entry() must be updated to take this account, and use
case-insensitive functions to compare file names.Signed-off-by: Jean-Jacques Hiblot
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 - 0x4f59e7c8To 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
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 -
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
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
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.
15 Sep, 2017
8 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 -
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 -
Noticed when comparing our output to linux. There are some lcase bits
which control whether filename and/or extension should be downcase'd.Signed-off-by: Rob Clark
Reviewed-by: Łukasz Majewski
Reviewed-by: Simon Glass -
Add a generic implementation of 'ls' using opendir/readdir/closedir, and
replace fat's custom implementation. Other filesystems should move to
the generic implementation after they add opendir/readdir/closedir
support.Signed-off-by: Rob Clark
Reviewed-by: Łukasz Majewski
Reviewed-by: Simon Glass -
Spotted by chance, when trying to remove file_fat_ls(), I noticed there
were some dead users of the API.Signed-off-by: Rob Clark
Acked-by: Stefan Brüns
Reviewed-by: Simon Glass -
Implement the readdir interface using the directory iterators.
Signed-off-by: Rob Clark
Reviewed-by: Łukasz Majewski
Reviewed-by: Simon Glass -
And drop a whole lot of ugly code!
Signed-off-by: Rob Clark
Reviewed-by: Łukasz Majewski
Reviewed-by: Simon Glass -
Untangle directory traversal into a simple iterator, to replace the
existing multi-purpose do_fat_read_at() + get_dentfromdir().Signed-off-by: Rob Clark
Reviewed-by: Łukasz Majewski