<feed xmlns='http://www.w3.org/2005/Atom'>
<title>u-boot.git/fs/fat, branch v2016.03</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.
</subtitle>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/'/>
<entry>
<title>block: pass block dev not num to read/write/erase()</title>
<updated>2016-01-14T02:05:18+00:00</updated>
<author>
<name>Stephen Warren</name>
<email>swarren@nvidia.com</email>
</author>
<published>2015-12-07T18:38:48+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=7c4213f6a52f35ff6ba2d97aa4eb04cbfc963b86'/>
<id>7c4213f6a52f35ff6ba2d97aa4eb04cbfc963b86</id>
<content type='text'>
This will allow the implementation to make use of data in the block_dev
structure beyond the base device number. This will be useful so that eMMC
block devices can encompass the HW partition ID rather than treating this
out-of-band. Equally, the existence of the priv field is crying out for
this patch to exist.

Signed-off-by: Stephen Warren &lt;swarren@nvidia.com&gt;
Reviewed-by: Tom Rini &lt;trini@konsulko.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This will allow the implementation to make use of data in the block_dev
structure beyond the base device number. This will be useful so that eMMC
block devices can encompass the HW partition ID rather than treating this
out-of-band. Equally, the existence of the priv field is crying out for
this patch to exist.

Signed-off-by: Stephen Warren &lt;swarren@nvidia.com&gt;
Reviewed-by: Tom Rini &lt;trini@konsulko.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fat/fat_write: Fix management of empty files</title>
<updated>2015-10-11T21:12:08+00:00</updated>
<author>
<name>Benoît Thébaudeau</name>
<email>benoit@wsystem.com</email>
</author>
<published>2015-09-28T13:45:32+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=1254b44a9f31c78ce7325eb392eaa949a2c7fc9a'/>
<id>1254b44a9f31c78ce7325eb392eaa949a2c7fc9a</id>
<content type='text'>
Overwriting an empty file not created by U-Boot did not work, and it
could even corrupt the FAT. Moreover, creating empty files or emptying
existing files allocated a cluster, which is not standard.

Fix this by always keeping empty files clusterless as specified by
Microsoft (the start cluster must be set to 0 in the directory entry in
that case), and by supporting overwriting such files.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Overwriting an empty file not created by U-Boot did not work, and it
could even corrupt the FAT. Moreover, creating empty files or emptying
existing files allocated a cluster, which is not standard.

Fix this by always keeping empty files clusterless as specified by
Microsoft (the start cluster must be set to 0 in the directory entry in
that case), and by supporting overwriting such files.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fat/fat_write: Factor out duplicate code</title>
<updated>2015-10-11T21:12:08+00:00</updated>
<author>
<name>Benoît Thébaudeau</name>
<email>benoit@wsystem.com</email>
</author>
<published>2015-09-28T13:45:31+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=e876be4b5ccb661d68b5b83330e134ace339316c'/>
<id>e876be4b5ccb661d68b5b83330e134ace339316c</id>
<content type='text'>
Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fat/fat_write: Fix curclust/newclust mix-up</title>
<updated>2015-10-11T21:12:07+00:00</updated>
<author>
<name>Benoît Thébaudeau</name>
<email>benoit@wsystem.com</email>
</author>
<published>2015-09-28T13:45:30+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=5e1a860e6cd6d42d9ae16c9d9abbde46514da46d'/>
<id>5e1a860e6cd6d42d9ae16c9d9abbde46514da46d</id>
<content type='text'>
curclust was used instead of newclust in the debug() calls and in one
CHECK_CLUST() call, which could skip a failure case.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
curclust was used instead of newclust in the debug() calls and in one
CHECK_CLUST() call, which could skip a failure case.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fat/fat_write: Merge calls to set_cluster()</title>
<updated>2015-10-11T21:12:07+00:00</updated>
<author>
<name>Benoît Thébaudeau</name>
<email>benoit@wsystem.com</email>
</author>
<published>2015-09-28T13:45:29+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=1d7f2ece69c9d80264321bc4ee07f57eec392538'/>
<id>1d7f2ece69c9d80264321bc4ee07f57eec392538</id>
<content type='text'>
set_contents() had uselessly split calls to set_cluster(). Merge these
calls, which removes some cases of set_cluster() being called with a
size of zero.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
set_contents() had uselessly split calls to set_cluster(). Merge these
calls, which removes some cases of set_cluster() being called with a
size of zero.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs/fat/fat_write: Fix buffer alignments</title>
<updated>2015-10-11T21:12:07+00:00</updated>
<author>
<name>Benoît Thébaudeau</name>
<email>benoit@wsystem.com</email>
</author>
<published>2015-09-28T13:45:28+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=8133f43d1cd4f0df0a6b4c2aa99a47753fda20d6'/>
<id>8133f43d1cd4f0df0a6b4c2aa99a47753fda20d6</id>
<content type='text'>
set_cluster() was using a temporary buffer without enforcing its
alignment for DMA and cache. Moreover, it did not check the alignment of
the passed buffer, which can come directly from applicative code or from
the user.

This could cause random data corruption, which has been observed on
i.MX25 writing to an SD card.

Fix this by only passing ARCH_DMA_MINALIGN-aligned buffers to
disk_write(), which requires the introduction of a buffer bouncing
mechanism for the misaligned buffers passed to set_cluster().

By the way, improve the handling of the corresponding return values from
disk_write():
 - print them with debug() in case of error,
 - consider that there is an error is disk_write() returns a smaller
   block count than the requested one, not only if its return value is
   negative.

After this change, set_cluster() and get_cluster() are almost
symmetrical.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
set_cluster() was using a temporary buffer without enforcing its
alignment for DMA and cache. Moreover, it did not check the alignment of
the passed buffer, which can come directly from applicative code or from
the user.

This could cause random data corruption, which has been observed on
i.MX25 writing to an SD card.

Fix this by only passing ARCH_DMA_MINALIGN-aligned buffers to
disk_write(), which requires the introduction of a buffer bouncing
mechanism for the misaligned buffers passed to set_cluster().

By the way, improve the handling of the corresponding return values from
disk_write():
 - print them with debug() in case of error,
 - consider that there is an error is disk_write() returns a smaller
   block count than the requested one, not only if its return value is
   negative.

After this change, set_cluster() and get_cluster() are almost
symmetrical.

Signed-off-by: Benoît Thébaudeau &lt;benoit@wsystem.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>FIX: fat: Provide correct return code from disk_{read|write} to upper layers</title>
<updated>2015-09-11T21:15:21+00:00</updated>
<author>
<name>Łukasz Majewski</name>
<email>l.majewski@samsung.com</email>
</author>
<published>2015-09-03T12:21:39+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=0a04ed86cfaa36d93d55016d0b3dc3f06352a2fe'/>
<id>0a04ed86cfaa36d93d55016d0b3dc3f06352a2fe</id>
<content type='text'>
It is very common that FAT code is using following pattern:
if (disk_{read|write}() &lt; 0)
        return -1;

Up till now the above code was dead, since disk_{read|write) could only
return value &gt;= 0.
As a result some errors from medium layer (i.e. eMMC/SD) were not caught.

The above behavior was caused by block_{read|write|erase} declared at
struct block_dev_desc (@part.h). It returns unsigned long, where 0
indicates error and &gt; 0 indicates that medium operation was correct.

This patch as error regards 0 returned from block_{read|write|erase}
when nr_blocks is grater than zero. Read/Write operation with nr_blocks=0
should return 0 and hence is not considered as an error.

Signed-off-by: Lukasz Majewski &lt;l.majewski@samsung.com&gt;

Test HW: Odroid XU3 - Exynos 5433
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
It is very common that FAT code is using following pattern:
if (disk_{read|write}() &lt; 0)
        return -1;

Up till now the above code was dead, since disk_{read|write) could only
return value &gt;= 0.
As a result some errors from medium layer (i.e. eMMC/SD) were not caught.

The above behavior was caused by block_{read|write|erase} declared at
struct block_dev_desc (@part.h). It returns unsigned long, where 0
indicates error and &gt; 0 indicates that medium operation was correct.

This patch as error regards 0 returned from block_{read|write|erase}
when nr_blocks is grater than zero. Read/Write operation with nr_blocks=0
should return 0 and hence is not considered as an error.

Signed-off-by: Lukasz Majewski &lt;l.majewski@samsung.com&gt;

Test HW: Odroid XU3 - Exynos 5433
</pre>
</div>
</content>
</entry>
<entry>
<title>Move ALLOC_CACHE_ALIGN_BUFFER() to the new memalign.h header</title>
<updated>2015-09-11T21:15:20+00:00</updated>
<author>
<name>Simon Glass</name>
<email>sjg@chromium.org</email>
</author>
<published>2015-09-02T23:24:58+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=cf92e05c0135bc2b1a1b25a3218e31e6d79bad59'/>
<id>cf92e05c0135bc2b1a1b25a3218e31e6d79bad59</id>
<content type='text'>
Now that we have a new header file for cache-aligned allocation, we should
move the stack-based allocation macro there also.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Now that we have a new header file for cache-aligned allocation, we should
move the stack-based allocation macro there also.

Signed-off-by: Simon Glass &lt;sjg@chromium.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fat: handle paths that include ../</title>
<updated>2015-09-11T18:05:33+00:00</updated>
<author>
<name>Stephen Warren</name>
<email>swarren@wwwdotorg.org</email>
</author>
<published>2015-07-29T03:55:03+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=18a10d46f267057ede0490ddba71c106475b4eb1'/>
<id>18a10d46f267057ede0490ddba71c106475b4eb1</id>
<content type='text'>
The FAT code contains a special case to parse the root directory. This
is needed since the root directory location/layout on disk is special
cased for FAT12/16. In particular, the location and size of the FAT12/16
root directory is hard-coded and contiguous, whereas all FAT12/16 non-root
directories, and all FAT32 directories, are stored in a non-contiguous
fashion, with the layout represented by a linked-list of clusters in the
FAT.

If a file path contains ../ (for example /extlinux/../bcm2835-rpi-cm.dtb),
it is possible to need to parse the root directory for the first element
in the path (requiring application of the special case), then a sub-
directory (in the general way), then re-parse the root directory (again
requiring the special case). However, the current code in U-Boot only
applies the special case for the very first path element, and never for
any later path element. When reparsing the root directory without
applying the special case, any file in a sector (or cluster?) other than
the first sector/cluster of the root directory will not be found.

This change modifies the non-root-dir-parsing loop of do_fat_read_at()
to detect if it's walked back to the root directory, and if so, jumps
back to the special case code that handles parsing of the root directory.

This change was tested using sandbox by executing:

./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/../"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/..backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../backup/../bcm2835-rpi-cm.dtb"

(/extlinux and /backup are in different sectors so trigger some different
cases, and bcm2835-rpi-cm.dtb is in a sector of the root directory other
than the first).

In all honesty, this change is a bit of a hack, using goto and all.
However, as demonstrated above it appears to work well in practice, is
quite minimal, likely doesn't introduce any risk of regressions, and
hopefully doesn't introduce any maintenance issues.

The correct fix would be to collapse the root and non-root loops in
do_fat_read_at() and get_dentfromdir() into a single loop that has a
small special-case when moving from one sector to the next, to handle
the layout difference of root/non-root directories. AFAIK all other
aspects of directory parsing are identical. However, that's a much
larger change which needs significantly more thought before it's
implemented.

Signed-off-by: Stephen Warren &lt;swarren@wwwdotorg.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The FAT code contains a special case to parse the root directory. This
is needed since the root directory location/layout on disk is special
cased for FAT12/16. In particular, the location and size of the FAT12/16
root directory is hard-coded and contiguous, whereas all FAT12/16 non-root
directories, and all FAT32 directories, are stored in a non-contiguous
fashion, with the layout represented by a linked-list of clusters in the
FAT.

If a file path contains ../ (for example /extlinux/../bcm2835-rpi-cm.dtb),
it is possible to need to parse the root directory for the first element
in the path (requiring application of the special case), then a sub-
directory (in the general way), then re-parse the root directory (again
requiring the special case). However, the current code in U-Boot only
applies the special case for the very first path element, and never for
any later path element. When reparsing the root directory without
applying the special case, any file in a sector (or cluster?) other than
the first sector/cluster of the root directory will not be found.

This change modifies the non-root-dir-parsing loop of do_fat_read_at()
to detect if it's walked back to the root directory, and if so, jumps
back to the special case code that handles parsing of the root directory.

This change was tested using sandbox by executing:

./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/"
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/.."
./u-boot -c "host bind 0 ../sd-p1.bin; ls host 0:0 /extlinux/../backup/../"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/..backup/../bcm2835-rpi-cm.dtb"
./u-boot -c "host bind 0 ../sd-p1.bin; load host 0:0 0 /extlinux/../backup/../bcm2835-rpi-cm.dtb"

(/extlinux and /backup are in different sectors so trigger some different
cases, and bcm2835-rpi-cm.dtb is in a sector of the root directory other
than the first).

In all honesty, this change is a bit of a hack, using goto and all.
However, as demonstrated above it appears to work well in practice, is
quite minimal, likely doesn't introduce any risk of regressions, and
hopefully doesn't introduce any maintenance issues.

The correct fix would be to collapse the root and non-root loops in
do_fat_read_at() and get_dentfromdir() into a single loop that has a
small special-case when moving from one sector to the next, to handle
the layout difference of root/non-root directories. AFAIK all other
aspects of directory parsing are identical. However, that's a much
larger change which needs significantly more thought before it's
implemented.

Signed-off-by: Stephen Warren &lt;swarren@wwwdotorg.org&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>fs: fat: read: fix fat16 ls/read issue</title>
<updated>2015-01-05T20:13:46+00:00</updated>
<author>
<name>Przemyslaw Marczak</name>
<email>p.marczak@samsung.com</email>
</author>
<published>2014-12-18T16:14:17+00:00</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/u-boot.git/commit/?id=64f65e1e36adffc39730635d104399937ea21949'/>
<id>64f65e1e36adffc39730635d104399937ea21949</id>
<content type='text'>
The present fat implementation ignores FAT16 long name
directory entries which aren't placed in a single sector.

This was becouse of the buffer was always filled by the
two sectors, and the loop was made also for two sectors.

If some file long name entries are stored in two sectors,
the we have two cases:

Case 1:
Both of sectors are in the buffer - all required data
for long file name is in the buffer.
- Read OK!

Case 2:
The current directory entry is placed at the end of the
second buffered sector. And the next entries are placed
in a sector which is not buffered yet. Then two next
sectors are buffered and the mentioned entry is ignored.
- Read fail!

This commit fixes this issue by:
- read two sectors after loop on each single is done
- keep the last used sector as a first in the buffer
  before the read of two next

The commit doesn't affects the fat32 imlementation,
which works good as previous.

Signed-off-by: Przemyslaw Marczak &lt;p.marczak@samsung.com&gt;
Cc: Mikhail Zolotaryov &lt;lebon@lebon.org.ua&gt;
Cc: Tom Rini &lt;trini@ti.com&gt;
Cc: Stephen Warren &lt;swarren@nvidia.com&gt;
Cc: Simon Glass &lt;sjg@chromium.org&gt;
Cc: Suriyan Ramasami &lt;suriyan.r@gmail.com&gt;
Cc: Lukasz Majewski &lt;l.majewski@samsung.com&gt;
Cc: Wolfgang Denk &lt;wd@denx.de&gt;
Tested-by: Simon Glass &lt;sjg@chomium.org&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The present fat implementation ignores FAT16 long name
directory entries which aren't placed in a single sector.

This was becouse of the buffer was always filled by the
two sectors, and the loop was made also for two sectors.

If some file long name entries are stored in two sectors,
the we have two cases:

Case 1:
Both of sectors are in the buffer - all required data
for long file name is in the buffer.
- Read OK!

Case 2:
The current directory entry is placed at the end of the
second buffered sector. And the next entries are placed
in a sector which is not buffered yet. Then two next
sectors are buffered and the mentioned entry is ignored.
- Read fail!

This commit fixes this issue by:
- read two sectors after loop on each single is done
- keep the last used sector as a first in the buffer
  before the read of two next

The commit doesn't affects the fat32 imlementation,
which works good as previous.

Signed-off-by: Przemyslaw Marczak &lt;p.marczak@samsung.com&gt;
Cc: Mikhail Zolotaryov &lt;lebon@lebon.org.ua&gt;
Cc: Tom Rini &lt;trini@ti.com&gt;
Cc: Stephen Warren &lt;swarren@nvidia.com&gt;
Cc: Simon Glass &lt;sjg@chromium.org&gt;
Cc: Suriyan Ramasami &lt;suriyan.r@gmail.com&gt;
Cc: Lukasz Majewski &lt;l.majewski@samsung.com&gt;
Cc: Wolfgang Denk &lt;wd@denx.de&gt;
Tested-by: Simon Glass &lt;sjg@chomium.org&gt;
</pre>
</div>
</content>
</entry>
</feed>
