ext2: Distinguish physical (always valid) and logical (per file) cached blocks
diff --git a/src/filo-fs-ext2.ads b/src/filo-fs-ext2.ads
index b1f1544..fbe6a35 100644
--- a/src/filo-fs-ext2.ads
+++ b/src/filo-fs-ext2.ads
@@ -55,9 +55,11 @@
-- to 64 1KiB blocks.
-- Cache entries can be used for blocks that map logical block offets
-- to physical ones. Then we note the first logical block offset mapped
- -- by the cached block.
+ -- by the cached block. Otherwise, we use their physical offset.
+ type Cache_Label is new Unsigned_64;
subtype Block_Cache_Index is Natural range 0 .. 63;
- type Block_Cache_Type is array (Block_Cache_Index) of FSBlock_Logical;
+ type Cache_Label_Logical is array (Block_Cache_Index) of Boolean;
+ type Cache_Label_Array is array (Block_Cache_Index) of Cache_Label;
-- Same as the 12 direct + 3 indirect blocks times 4B:
subtype Inode_Extents_Index is Natural range 0 .. 59;
@@ -72,17 +74,18 @@
type T is record
S : State;
- Part_Len : Partition_Length := 0;
- First_Data_Block : FSBlock_Offset := 0;
- Block_Size_Bits : Log_Block_Size := 10;
- Inodes_Per_Group : Positive := 1;
- Inode_Size : Ext2.Inode_Size := Ext2.Inode_Size'First;
- Desc_Size : Ext2.Desc_Size := Ext2.Desc_Size'First;
- Feature_Extents : Boolean := False;
- Feature_64Bit : Boolean := False;
- Inode : Inode_Info := (others => <>);
- Block_Cache_Index : Block_Cache_Type := (others => 0);
- Block_Cache : Buffer_Type (Max_Block_Index) := (others => 16#00#);
+ Part_Len : Partition_Length := 0;
+ First_Data_Block : FSBlock_Offset := 0;
+ Block_Size_Bits : Log_Block_Size := 10;
+ Inodes_Per_Group : Positive := 1;
+ Inode_Size : Ext2.Inode_Size := Ext2.Inode_Size'First;
+ Desc_Size : Ext2.Desc_Size := Ext2.Desc_Size'First;
+ Feature_Extents : Boolean := False;
+ Feature_64Bit : Boolean := False;
+ Inode : Inode_Info := (others => <>);
+ Block_Cache_Logical : Cache_Label_Logical := (others => False);
+ Block_Cache_Label : Cache_Label_Array := (others => 0);
+ Block_Cache : Buffer_Type (Max_Block_Index) := (others => 16#00#);
end record;
end FILO.FS.Ext2;