aboutsummaryrefslogtreecommitdiff
path: root/slof
diff options
context:
space:
mode:
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>2016-06-27 13:42:01 +1000
committerAlexey Kardashevskiy <aik@ozlabs.ru>2016-06-27 13:42:22 +1000
commit554eb9b91580cc06a34283129a7d157660f4cc22 (patch)
treeec70cedc9a9a6461384b20c074b1a6384f259e65 /slof
parent070886b669840532399c9dff5f1d35d91d6fa63a (diff)
downloadSLOF-554eb9b91580cc06a34283129a7d157660f4cc22.zip
SLOF-554eb9b91580cc06a34283129a7d157660f4cc22.tar.gz
SLOF-554eb9b91580cc06a34283129a7d157660f4cc22.tar.bz2
fat-files: Fix access to FAT32 dir/files when cluster > 16-bits
On FAT32, the directory entry contains a new field providing the top 16-bits of the cluster number. We didn't use it, thus reading the wrong sectors when trying to access files or directories beyond block 0x10000. Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Reviewed-by: Thomas Huth <thuth@redhat.com> [aik: removed unrelated empty lines] Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'slof')
-rw-r--r--slof/fs/packages/fat-files.fs13
1 files changed, 11 insertions, 2 deletions
diff --git a/slof/fs/packages/fat-files.fs b/slof/fs/packages/fat-files.fs
index d919452..a80279d 100644
--- a/slof/fs/packages/fat-files.fs
+++ b/slof/fs/packages/fat-files.fs
@@ -73,6 +73,14 @@ INSTANCE VARIABLE next-cluster
THEN
;
+\ Read cluster# from directory entry (handle FAT32 extension)
+: get-cluster ( direntry -- cluster# )
+ fat-type @ 20 = IF
+ dup 14 + 2c@ bwjoin 10 lshift
+ ELSE 0 THEN
+ swap 1a + 2c@ bwjoin +
+;
+
: .time ( x -- )
base @ >r decimal
b #split 2 0.r [char] : emit 5 #split 2 0.r [char] : emit 2* 2 0.r
@@ -87,7 +95,7 @@ INSTANCE VARIABLE next-cluster
dup 0b + c@ 8 and IF drop EXIT THEN \ volume label, not a file
dup c@ e5 = IF drop EXIT THEN \ deleted file
cr
- dup 1a + 2c@ bwjoin [char] # emit 4 0.r space \ starting cluster
+ dup get-cluster [char] # emit 8 0.r space \ starting cluster
dup 18 + 2c@ bwjoin .date space
dup 16 + 2c@ bwjoin .time space
dup 1c + 4c@ bljoin base @ decimal swap a .r base ! space \ size in bytes
@@ -114,7 +122,8 @@ CREATE dos-name b allot
: (find-file) ( -- cluster file-len is-dir? true | false )
data @ BEGIN dup data @ #data @ + < WHILE
dup dos-name b comp WHILE 20 + REPEAT
- dup 1a + 2c@ bwjoin swap dup 1c + 4c@ bljoin swap 0b + c@ 10 and 0<> true
+ dup get-cluster
+ swap dup 1c + 4c@ bljoin swap 0b + c@ 10 and 0<> true
ELSE drop false THEN ;
: find-file ( dir-cluster name len -- cluster file-len is-dir? true | false )
make-dos-name read-dir BEGIN (find-file) 0= WHILE next-cluster @ WHILE