diff options
author | Anssi Hannula <anssi.hannula@bitwise.fi> | 2019-02-27 12:55:57 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2019-04-09 20:04:04 -0400 |
commit | 9b18358dc05df1dc69c2274a61ec6bcf75a058ad (patch) | |
tree | e480ab9745f52a54ac917f725103138ca63a6a59 /drivers/bootcount | |
parent | 1c48fda3e5a88159130b4d4805fbdf367212afab (diff) |
fs: fat: fix reading non-cluster-aligned root directory
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 <anssi.hannula@bitwise.fi>
Reviewed-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Tested-by: Bernhard Messerklinger <bernhard.messerklinger@br-automation.com>
Diffstat (limited to 'drivers/bootcount')
0 files changed, 0 insertions, 0 deletions