ext2: Pre-compute Inodes_Per_Block & Desc_Per_Block
Eases proving that they are in range.
diff --git a/src/filo-fs-ext2.ads b/src/filo-fs-ext2.ads
index 7c1e467..5537507 100644
--- a/src/filo-fs-ext2.ads
+++ b/src/filo-fs-ext2.ads
@@ -86,6 +86,16 @@
Inline : Inode_Extents := (others => 16#00#);
end record;
+ type Group_Index is new Natural range 0 .. Natural (Inode_Index'Last / 2);
+ subtype Group_In_Block_Count is Group_Index
+ range 1 .. Group_Index (Block_Size'Last / Desc_Size'First);
+ type Desc_In_Block_Index is new Natural range 0 .. Natural (Group_In_Block_Count'Last - 1);
+
+ type Inode_In_Group_Index is new Natural range 0 .. Natural (Inode_Index'Last / 2);
+ subtype Inode_In_Block_Count is Inode_In_Group_Index
+ range 1 .. Inode_In_Group_Index (Block_Size'Last / Inode_Size'First);
+ type Inode_In_Block_Index is new Natural range 0 .. Natural (Inode_In_Block_Count'Last - 1);
+
type Mount_State is record
Part_Len : Partition_Length := 0;
First_Data_Block : FSBlock_Offset := 0;
@@ -93,7 +103,9 @@
Block_Size : Ext2.Block_Size := Ext2.Block_Size'First;
Inodes_Per_Group : Inode_Index := Inode_Index'First;
Inode_Size : Ext2.Inode_Size := Ext2.Inode_Size'First;
+ Inodes_Per_Block : Inode_In_Block_Count := Inode_In_Block_Count'First;
Desc_Size : Ext2.Desc_Size := Ext2.Desc_Size'First;
+ Desc_Per_Block : Group_In_Block_Count := Group_In_Block_Count'First;
Feature_Extents : Boolean := False;
Feature_64Bit : Boolean := False;
end record;