duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit 819177522ca9620302bffc6429a173357b30791a
parent 7b3d452c3fc5718d96ebeb3bc9d5b7204888f73d
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Fri, 12 Aug 2022 15:43:59 -0400

fs/fat: move readsectors and readcluster to FAT struct

Diffstat:
Mfs/fs/fat.fs | 1+
Mfs/fs/fatlo.fs | 25++++++++++++++-----------
2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/fs/fs/fat.fs b/fs/fs/fat.fs @@ -18,6 +18,7 @@ \ File and directory IDs in FAT are the offset, on disk, of their corresponding \ DirEntry. +\ TODO: in my big FAT refactoring, I broke this section. Fix it. ?f<< fs/fatlo.fs $ffff const EOC diff --git a/fs/fs/fatlo.fs b/fs/fs/fatlo.fs @@ -146,6 +146,19 @@ r@ :buf( r> Filesystem drv Drive :sec@ ; fnbuf! r@ :getdirentry r@ :readdir r@ :findindir dup if r@ :getid then rdrop ; current value :child' + +0 value _self +\ read multiple sectors in buf +: :readsectors ( sec u buf self -- ) to _self + A>r swap >r swap >A begin ( buf ) + A> over fatdrv Drive :sec@ + A+ _self secsz + next ( buf ) drop r>A ; + +: :readcluster ( cluster dst self -- ) >r + over 2 - $fff6 > if abort" cluster out of range!" then + swap r@ :FirstSectorOfCluster ( dst sec ) + swap r@ secpercluster swap r> :readsectors ; + ]struct $1000 const FATMAXSECSZ @@ -210,16 +223,6 @@ struct[ FATCursors create _FATCursors _FATFS , 0 , _FATCursors structbind FATCursors cursors -\ read multiple sectors in buf -: readsectors ( sec u buf -- ) - A>r swap >r swap >A begin ( buf ) - A> over fatdrv Drive :sec@ A+ FATFS secsz + next ( buf ) drop r>A ; - -: readcluster ( cluster dst -- ) - over 2 - $fff6 > if abort" cluster out of range!" then - swap FATFS :FirstSectorOfCluster ( dst sec ) - swap FATFS secpercluster swap readsectors ; - \ set fcursor to pos. If new pos crosses cluster boundaries compared to current \ pos, flush current buffer and read a new sector from disk. : fatseek ( pos fcursor -- ) @@ -230,7 +233,7 @@ _FATCursors structbind FATCursors cursors dup FATFS :ClusterSize / dup r@ to FATFile clusteridx ( pos idx ) r@ FATFile :cluster0 ( pos idx cl ) swap ?dup if >r begin ( pos cl ) FATFS :FAT@ next then ( pos cl ) - dup r@ FATFile :buf( readcluster ( pos cl ) + dup r@ FATFile :buf( FATFS :readcluster ( pos cl ) r@ to FATFile cluster r> ( pos fc ) then ( pos fcursor ) to FATFile pos ;