[SLOF] [PATCH slof 06/10] ext2: Read size of group descriptors

Alexey Kardashevskiy aik at ozlabs.ru
Tue Dec 31 14:04:53 AEDT 2019


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 <aik at ozlabs.ru>
---
 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 055e636023ff..7245d9375cf5 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 at -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 at -le 9 .r \ size
   r> base ! ;
 
+80 CONSTANT EXT4_INCOMPAT_64BIT
+: super-feature-incompat ( data -- flags ) 60 + l at -le ;
+: super-desc-size ( data -- size ) FE + w at -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 at -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 at -le inode-size !
   THEN
   data @ 20 + l at -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 @ *
-- 
2.17.1



More information about the SLOF mailing list