Author: wmb
Date: 2010-01-29 08:03:08 +0100 (Fri, 29 Jan 2010)
New Revision: 1720
Modified:
ofw/fs/ext2fs/dir.fth
ofw/fs/ext2fs/inode.fth
ofw/fs/ext2fs/layout.fth
ofw/fs/ext2fs/methods.fth
ofw/fs/ext2fs/sb.fth
Log:
OLPC trac 9972 - support the ext2 LARGE_FILE extension and improve the error reporting in the presence of unsupported extensions.
Modified: ofw/fs/ext2fs/dir.fth
===================================================================
--- ofw/fs/ext2fs/dir.fth 2010-01-29 05:13:22 UTC (rev 1719)
+++ ofw/fs/ext2fs/dir.fth 2010-01-29 07:03:08 UTC (rev 1720)
@@ -18,7 +18,7 @@
0 instance value wf-type \ Type - 4 for directory, d# 10 for symlink, etc
: get-dirblk ( -- end? )
- lblk# bsize * file-size >= if true exit then
+ lblk# bsize um* dfile-size d< 0= if true exit then
lblk# >pblk# to dir-block#
false
;
@@ -58,7 +58,7 @@
\ **** Select the next directory entry
: next-dirent ( -- end? )
dirent-len@ dup diroff +! totoff +!
- totoff @ file-size >= if true exit then
+ totoff @ u>d dfile-size d< 0= if true exit then
diroff @ bsize = if
lblk#++ get-dirblk if true exit then
diroff off
@@ -130,7 +130,7 @@
drop ( last )
;
: last-dirent ( -- free-bytes )
- file-size bsize /mod swap 0= if 1- then to lblk# ( )
+ dfile-size bsize um/mod nip swap 0= if 1- then to lblk# ( )
lblk# >pblk# to dir-block#
(last-dirent) drop
dirent-len@ dirent-reclen -
@@ -413,7 +413,7 @@
: file-info ( id -- false | id' s m h d m y len attributes name$ true )
inode# >r dirent-inode@ set-inode ( id )
- 1+ mtime unix-seconds> file-size file-attr file-name true
+ 1+ mtime unix-seconds> dfile-size drop file-attr file-name true
r> set-inode
;
Modified: ofw/fs/ext2fs/inode.fth
===================================================================
--- ofw/fs/ext2fs/inode.fth 2010-01-29 05:13:22 UTC (rev 1719)
+++ ofw/fs/ext2fs/inode.fth 2010-01-29 07:03:08 UTC (rev 1720)
@@ -23,8 +23,8 @@
: uid ( -- uid ) 2 +i short@ ;
: uid! ( uid -- ) 2 +i short! update ;
: filetype ( -- type ) file-attr h# f000 and ;
-: file-size ( -- n ) 4 +i int@ ;
-: file-size! ( n -- ) 4 +i int! update ;
+: dfile-size ( -- d ) 4 +i int@ 108 +i int@ ;
+: dfile-size! ( d -- ) 108 +i int! 4 +i int! update ;
: atime ( -- seconds ) 8 +i int@ ;
: atime! ( seconds -- ) 8 +i int! update ;
: ctime ( -- seconds ) 12 +i int@ ;
@@ -40,6 +40,7 @@
: #blks-held ( -- n ) 28 +i int@ ;
: #blks-held! ( n -- ) 28 +i int! update ;
: file-acl ( -- n ) 104 +i int@ ;
+: dir-acl ( -- n ) 108 +i int@ ;
d# 12 constant #direct-blocks
: direct0 ( -- adr ) 40 +i ;
Modified: ofw/fs/ext2fs/layout.fth
===================================================================
--- ofw/fs/ext2fs/layout.fth 2010-01-29 05:13:22 UTC (rev 1719)
+++ ofw/fs/ext2fs/layout.fth 2010-01-29 07:03:08 UTC (rev 1720)
@@ -189,8 +189,8 @@
;
: append-block ( -- )
- add-block ( block )
- file-size bsize / dup bsize * file-size! ( block #blocks )
+ add-block ( block )
+ dfile-size bsize um/mod nip dup bsize um* dfile-size! ( block #blocks )
1+ >pblk int! update
;
Modified: ofw/fs/ext2fs/methods.fth
===================================================================
--- ofw/fs/ext2fs/methods.fth 2010-01-29 05:13:22 UTC (rev 1719)
+++ ofw/fs/ext2fs/methods.fth 2010-01-29 07:03:08 UTC (rev 1720)
@@ -19,7 +19,7 @@
dirent-inode@ set-inode
add-block ( block# )
- file-size h# 400 + file-size!
+ dfile-size h# 400. d+ dfile-size! ( block# )
dup direct0 int! update ( block# )
block bsize erase update \ flush ( )
inode# first-dirent if true exit then ( )
@@ -136,7 +136,7 @@
\ EXT2FS file interface
-: ext2fsdflen ( 'fhandle -- d.size ) drop file-size 0 ;
+: ext2fsdflen ( 'fhandle -- d.size ) drop dfile-size ;
: ext2fsdfalign ( d.byte# 'fh -- d.aligned )
drop swap bsize 1- invert and swap
@@ -159,19 +159,24 @@
: ext2fsfread ( addr count 'fh -- #read )
drop
dup bsize > abort" Bad size for ext2fsfread"
- file-size lblk# bsize * - ( addr count rem )
+ dfile-size lblk# bsize um* d- drop ( addr count rem )
umin swap ( actual addr )
lblk# read-file-block ( actual )
dup 0> if lblk#++ then ( actual )
;
+: ext2fsnowrite ( addr count 'fh -- #written )
+ ." Not writing to the ext2 filesystem because of unsupported extensions" cr
+ 2drop 0
+;
: ext2fsfwrite ( addr count 'fh -- #written )
drop
dup bsize > abort" Bad size for ext2fsfwrite" ( addr count )
- tuck lblk# bsize * + dup file-size u> if ( actual addr new )
- file-size! \ changing byte count, NOT #blks
- else
- drop
+ tuck 0 lblk# bsize um* d+ ( addr count d.new-size )
+ dfile-size 2over d< if ( actual addr d.new )
+ dfile-size! \ extending file ( actual addr )
+ else ( actual addr d.new )
+ 2drop \ not extending file ( actual addr )
then ( actual addr )
lblk# write-file-block ( actual )
@@ -191,7 +196,11 @@
>r
bsize alloc-mem bsize initbuf
dirent-inode@ r@ ['] ext2fsdflen ['] ext2fsdfalign ['] ext2fsfclose ['] ext2fsdfseek
- r@ read = unknown-extensions? or if ['] nullwrite else ['] ext2fsfwrite then
+ r@ read = unknown-extensions? or if
+ ['] ext2fsnowrite
+ else
+ ['] ext2fsfwrite
+ then
r> write = if ['] nullread else ['] ext2fsfread then
true
;
@@ -249,8 +258,8 @@
: seek ( offset.low offset.high -- error? )
ext2fs-fd ['] dfseek catch if 2drop true else false then
;
-: size ( -- d ) file-size 0 ;
-: load ( adr -- size ) file-size read ;
+: size ( -- d ) dfile-size ;
+: load ( adr -- size ) dfile-size drop read ;
\ : files ( -- ) begin file-name type cr next-dirent until ;
\ LICENSE_BEGIN
Modified: ofw/fs/ext2fs/sb.fth
===================================================================
--- ofw/fs/ext2fs/sb.fth 2010-01-29 05:13:22 UTC (rev 1719)
+++ ofw/fs/ext2fs/sb.fth 2010-01-29 07:03:08 UTC (rev 1720)
@@ -54,7 +54,7 @@
23 +sbl h# ffffffff invert and \ Accept all compat extensions
24 +sbl h# 00000002 invert and or \ Incompatible - accept FILETYPE
- 25 +sbl h# 00000001 invert and or \ RO - accept SPARSE_SUPER
+ 25 +sbl h# 00000003 invert and or \ RO - accept SPARSE_SUPER and LARGE_FILE
;
: do-alloc ( adr len -- ) " dma-alloc" $call-parent ;