From d79b254660e0f59b97e5a410e243f54ea33e13d2 Mon Sep 17 00:00:00 2001 From: Alexey Kardashevskiy Date: Mon, 30 Dec 2019 13:59:25 +1100 Subject: ext2: Read size of group descriptors When incompat flags has INCOMPAT_64BIT set ("Enable a filesystem size over 2^32 blocks"), the group descriptor size is stored at 0xFE and these days it is 0x40 so use that rather than the default value of 0x20. Signed-off-by: Alexey Kardashevskiy --- slof/fs/packages/ext2-files.fs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/slof/fs/packages/ext2-files.fs b/slof/fs/packages/ext2-files.fs index 055e636..7245d93 100644 --- a/slof/fs/packages/ext2-files.fs +++ b/slof/fs/packages/ext2-files.fs @@ -18,6 +18,7 @@ INSTANCE VARIABLE inodes/group INSTANCE VARIABLE blocks-per-group INSTANCE VARIABLE group-descriptors +INSTANCE VARIABLE desc-size : seek s" seek" $call-parent ; : read s" read" $call-parent ; @@ -91,7 +92,7 @@ INSTANCE VARIABLE #blocks-left : read-inode ( inode# -- ) 1- inodes/group @ u/mod - 20 * group-descriptors @ + + desc-size @ * group-descriptors @ + 8 + l@-le \ reads bg_inode_table_lo block-size @ * \ # in group, inode table swap inode-size @ * + xlsplit seek drop inode @ inode-size @ read drop @@ -117,6 +118,13 @@ CREATE mode-chars 10 allot s" ?pc?d?b?-?l?s???" mode-chars swap move inode @ 04 + l@-le 9 .r \ size r> base ! ; +80 CONSTANT EXT4_INCOMPAT_64BIT +: super-feature-incompat ( data -- flags ) 60 + l@-le ; +: super-desc-size ( data -- size ) FE + w@-le ; +: super-feature-incompat-64bit ( data -- true|false ) + super-feature-incompat EXT4_INCOMPAT_64BIT and 0<> +; + : do-super ( -- ) 400 400 read-data data @ 14 + l@-le first-block ! @@ -129,6 +137,11 @@ CREATE mode-chars 10 allot s" ?pc?d?b?-?l?s???" mode-chars swap move data @ 58 + w@-le inode-size ! THEN data @ 20 + l@-le blocks-per-group ! + data @ super-feature-incompat-64bit IF + data @ super-desc-size desc-size ! + ELSE + 20 desc-size ! + THEN \ Read the group descriptor table: first-block @ 1+ block-size @ * -- cgit v1.1