Message ID | 1465444063.2948.25.camel@kernel.crashing.org |
---|---|
State | Superseded |
Headers | show |
On Thu, Jun 09, 2016 at 01:47:43PM +1000, Benjamin Herrenschmidt wrote: > : seek ( lo hi -- status ) > + dir? @ IF ABORT" fat-files: trying to seek a dir" THEN ABORT" has an IF built-in, so this should be dir? @ ABORT" fat-files: trying to seek a dir" > : dir > - dir? @ IF file-cluster @ .dir ELSE ." not a directory!" cr THEN > + dir? @ IF file-cluster @ .dir ELSE cr ." not a directory!" THEN > ; Belongs in the other patch? > : open > do-super > 0 my-args find-path > - 0= IF free-data false EXIT > - THEN > - dir? ! file-len ! file-cluster ! > - dir? @ IF > + 0= IF close false EXIT THEN > + dir? ! file-len ! file-cluster ! > + dir? @ 0= IF > 0 0 seek 0= > ELSE true THEN > ; This as well, I guess? Segher
On Thu, 2016-06-09 at 02:24 -0500, Segher Boessenkool wrote: > On Thu, Jun 09, 2016 at 01:47:43PM +1000, Benjamin Herrenschmidt > wrote: > > : seek ( lo hi -- status ) > > + dir? @ IF ABORT" fat-files: trying to seek a dir" THEN > > ABORT" has an IF built-in, so this should be > > dir? @ ABORT" fat-files: trying to seek a dir" > > > : dir > > - dir? @ IF file-cluster @ .dir ELSE ." not a directory!" cr THEN > > + dir? @ IF file-cluster @ .dir ELSE cr ." not a directory!" THEN > > ; > > Belongs in the other patch? > > > : open > > do-super > > 0 my-args find-path > > - 0= IF free-data false EXIT > > - THEN > > - dir? ! file-len ! file-cluster ! > > - dir? @ IF > > + 0= IF close false EXIT THEN > > + dir? ! file-len ! file-cluster ! > > + dir? @ 0= IF > > 0 0 seek 0= > > ELSE true THEN > > ; > > This as well, I guess? Nah I mixed up the patches. The global dir method should only touch boot.fs and everything in fat-files.fs should be in this one. I'll resend tomorrow after addressing your comments. Cheers, Ben.
On 09/06/16 18:08, Benjamin Herrenschmidt wrote: > On Thu, 2016-06-09 at 02:24 -0500, Segher Boessenkool wrote: >> On Thu, Jun 09, 2016 at 01:47:43PM +1000, Benjamin Herrenschmidt >> wrote: >>> : seek ( lo hi -- status ) >>> + dir? @ IF ABORT" fat-files: trying to seek a dir" THEN >> >> ABORT" has an IF built-in, so this should be >> >> dir? @ ABORT" fat-files: trying to seek a dir" >> >>> : dir >>> - dir? @ IF file-cluster @ .dir ELSE ." not a directory!" cr THEN >>> + dir? @ IF file-cluster @ .dir ELSE cr ." not a directory!" THEN >>> ; >> >> Belongs in the other patch? >> >>> : open >>> do-super >>> 0 my-args find-path >>> - 0= IF free-data false EXIT >>> - THEN >>> - dir? ! file-len ! file-cluster ! >>> - dir? @ IF >>> + 0= IF close false EXIT THEN >>> + dir? ! file-len ! file-cluster ! >>> + dir? @ 0= IF >>> 0 0 seek 0= >>> ELSE true THEN >>> ; >> >> This as well, I guess? > > Nah I mixed up the patches. The global dir method should only > touch boot.fs and everything in fat-files.fs should be in this one. > > I'll resend tomorrow after addressing your comments. When you resend, "git send-mail" (or whatever you do for kernel/qemu) please as this patch, "Add a global "dir" method" and "instance: Fix set-my-args for empty arguments" are poisoned with 0xa0 too. Thanks.
diff --git a/slof/fs/packages/fat-files.fs b/slof/fs/packages/fat-files.fs index ac2f141..906f0ee 100644 --- a/slof/fs/packages/fat-files.fs +++ b/slof/fs/packages/fat-files.fs @@ -209,6 +209,7 @@ INSTANCE VARIABLE current-pos INSTANCE VARIABLE pos-in-data : seek ( lo hi -- status ) + dir? @ IF ABORT" fat-files: trying to seek a dir" THEN lxjoin dup current-pos ! file-cluster @ read-cluster \ Read and skip blocks until we are where we want to be. BEGIN dup #data @ >= WHILE #data @ - next-cluster @ dup 0= IF @@ -220,25 +221,26 @@ INSTANCE VARIABLE pos-in-data r@ pos-in-data +! r@ current-pos +! pos-in-data @ #data @ = IF next-cluster @ ?dup IF read-cluster 0 pos-in-data ! THEN THEN r> ; : read ( adr len -- actual ) + dir? @ IF ABORT" fat-files: trying to read a dir" THEN file-len @ min \ len cannot be greater than file size dup >r BEGIN dup WHILE 2dup read dup 0= ABORT" fat-files: read failed" /string ( tuck - >r + r> ) REPEAT 2drop r> ; : load ( adr -- len ) + dir? @ IF ABORT" fat-files: trying to load a dir" THEN file-len @ read dup file-len @ <> ABORT" fat-files: failed loading file" ; : close free-data ; : dir - dir? @ IF file-cluster @ .dir ELSE ." not a directory!" cr THEN + dir? @ IF file-cluster @ .dir ELSE cr ." not a directory!" THEN ; : open do-super 0 my-args find-path - 0= IF free-data false EXIT - THEN - dir? ! file-len ! file-cluster ! - dir? @ IF + 0= IF close false EXIT THEN + dir? ! file-len ! file-cluster ! + dir? @ 0= IF 0 0 seek 0= ELSE true THEN ;
Add a "dir" methods to FAT filesystem, example: Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> --- slof/fs/packages/fat-files.fs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)