<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/fs/fat, branch v2020.01</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/u-boot.git/atom/fs/fat?h=v2020.01</id>
<link rel='self' href='http://cgit.235523.xyz/u-boot.git/atom/fs/fat?h=v2020.01'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<updated>2019-12-05T15:28:38Z</updated>
<entry>
<title>fs: fat: handle deleted directory entries correctly</title>
<updated>2019-12-05T15:28:38Z</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2019-11-26T08:29:31Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=39606d462c97408fa10c41206631e64225458636'/>
<id>urn:sha1:39606d462c97408fa10c41206631e64225458636</id>
<content type='text'>
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&lt;===
fs_obj_unlink = ['fat', '/home/akashi/tmp/uboot_sandbox_test/128MB.fat32.img']

    def test_unlink2(self, u_boot_console, fs_obj_unlink):
        """
        Test Case 2 - delete many files
        """
        fs_type,fs_img = fs_obj_unlink
        with u_boot_console.log.section('Test Case 2 - unlink (many)'):
            output = u_boot_console.run_command('host bind 0 %s' % fs_img)

            for i in range(0, 20):
                output = u_boot_console.run_command_list([
                    '%srm host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i),
                    '%sls host 0:0 dir2/0123456789abcdef%02x' % (fs_type, i)])
                assert('' == ''.join(output))

            output = u_boot_console.run_command(
                '%sls host 0:0 dir2' % fs_type)
&gt;           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
===&gt;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 &lt;takahiro.akashi@linaro.org&gt;
</content>
</entry>
<entry>
<title>fs: fat: get_contents() always returns -1 for errors</title>
<updated>2019-10-11T23:05:14Z</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2019-09-12T17:19:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=f13683816b9d0aada2546343d77bb87925505c46'/>
<id>urn:sha1:f13683816b9d0aada2546343d77bb87925505c46</id>
<content type='text'>
If out of memory, return -1 and not -ENOMEM from get_contents().

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fs: fat: treat invalid FAT clusters as errors</title>
<updated>2019-10-11T23:05:14Z</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2019-09-12T17:19:29Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=c7a86d1645325697372b404f0b8cadac8a722ce9'/>
<id>urn:sha1:c7a86d1645325697372b404f0b8cadac8a722ce9</id>
<content type='text'>
When hitting an invalid FAT cluster while reading a file always print an
error message and return an error code.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fat: FAT filesystem premature release of info struct.</title>
<updated>2019-08-26T15:46:21Z</updated>
<author>
<name>Martin Vystrčil</name>
<email>martin.vystrcil@m-linux.cz</email>
</author>
<published>2019-08-20T20:18:30Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=d7af2a863017be1f5fd1b65a858ddc7e87d7b876'/>
<id>urn:sha1:d7af2a863017be1f5fd1b65a858ddc7e87d7b876</id>
<content type='text'>
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 &lt;martin.vystrcil@m-linux.cz&gt;
</content>
</entry>
<entry>
<title>fs: fat: allocate a new cluster for root directory of fat32</title>
<updated>2019-05-28T22:55:09Z</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2019-05-24T05:10:37Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=cd2d727fff7ea4c69db49d7ee63bd791f91acd26'/>
<id>urn:sha1:cd2d727fff7ea4c69db49d7ee63bd791f91acd26</id>
<content type='text'>
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 &lt;takahiro.akashi@linaro.org&gt;
Tested-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fs: fat: flush a directory cluster properly</title>
<updated>2019-05-28T22:55:08Z</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2019-05-24T05:10:36Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=9c709c7b4177d063733070c7256f0b8635996d65'/>
<id>urn:sha1:9c709c7b4177d063733070c7256f0b8635996d65</id>
<content type='text'>
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 &lt;takahiro.akashi@linaro.org&gt;
Tested-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fs: fat: write to non-cluster-aligned root directory</title>
<updated>2019-05-28T22:55:08Z</updated>
<author>
<name>AKASHI Takahiro</name>
<email>takahiro.akashi@linaro.org</email>
</author>
<published>2019-05-24T05:10:35Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=a9f6706cf0ba330281ae7d6a0af65cc26ffb7d25'/>
<id>urn:sha1:a9f6706cf0ba330281ae7d6a0af65cc26ffb7d25</id>
<content type='text'>
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 &lt;takahiro.akashi@linaro.org&gt;
Cc: Anssi Hannula &lt;anssi.hannula@bitwise.fi&gt;
Tested-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fs: fat: Fix possible double free of fatbuf</title>
<updated>2019-05-28T17:57:52Z</updated>
<author>
<name>Andrew F. Davis</name>
<email>afd@ti.com</email>
</author>
<published>2019-05-16T14:34:31Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=d0cd30eb8137c0f14034aeb22c9f00cd70ccc98c'/>
<id>urn:sha1:d0cd30eb8137c0f14034aeb22c9f00cd70ccc98c</id>
<content type='text'>
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 &lt;afd@ti.com&gt;
</content>
</entry>
<entry>
<title>fs: fat: correct file name normalization</title>
<updated>2019-05-28T17:57:52Z</updated>
<author>
<name>Heinrich Schuchardt</name>
<email>xypron.glpk@gmx.de</email>
</author>
<published>2019-05-12T07:59:18Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=7b437807ee0a051f46d329e868e0295299026b75'/>
<id>urn:sha1:7b437807ee0a051f46d329e868e0295299026b75</id>
<content type='text'>
File names may not contain control characters (&lt; 0x20).
Simplify the coding.

Signed-off-by: Heinrich Schuchardt &lt;xypron.glpk@gmx.de&gt;
</content>
</entry>
<entry>
<title>fs: fat: fix reading non-cluster-aligned root directory</title>
<updated>2019-04-10T00:04:04Z</updated>
<author>
<name>Anssi Hannula</name>
<email>anssi.hannula@bitwise.fi</email>
</author>
<published>2019-02-27T10:55:57Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=9b18358dc05df1dc69c2274a61ec6bcf75a058ad'/>
<id>urn:sha1:9b18358dc05df1dc69c2274a61ec6bcf75a058ad</id>
<content type='text'>
A FAT12/FAT16 root directory location is specified by a sector offset and
it might not start at a cluster boundary. It also resides before the
data area (before cluster 2).

However, the current code assumes that the root directory is located at
a beginning of a cluster, causing no files to be found if that is not
the case.

Since the FAT12/FAT16 root directory is located before the data area
and is not aligned to clusters, using unsigned cluster numbers to refer
to the root directory does not work well (the "cluster number" may be
negative, and even allowing it be signed would not make it properly
aligned).

Modify the code to not use the normal cluster numbering when referring to
the root directory of FAT12/FAT16 and instead use a cluster-sized
offsets counted from the root directory start sector.

This is a relatively common case as at least the filesystem formatter on
Win7 seems to create such filesystems by default on 2GB USB sticks when
"FAT" is selected (cluster size 64 sectors, rootdir size 32 sectors,
rootdir starts at half a cluster before cluster 2).

dosfstools mkfs.vfat does not seem to create affected filesystems.

Signed-off-by: Anssi Hannula &lt;anssi.hannula@bitwise.fi&gt;
Reviewed-by: Bernhard Messerklinger &lt;bernhard.messerklinger@br-automation.com&gt;
Tested-by: Bernhard Messerklinger &lt;bernhard.messerklinger@br-automation.com&gt;
</content>
</entry>
</feed>
