Tune ext2 types
diff --git a/src/filo-fs-ext2.adb b/src/filo-fs-ext2.adb
index 7cf6147..21cfe0c 100644
--- a/src/filo-fs-ext2.adb
+++ b/src/filo-fs-ext2.adb
@@ -56,7 +56,7 @@
end if;
State.Part_Len := Part_Len;
- State.First_Data_Block := Block_Offset (Read_LE32 (Super_Block, 5 * 4));
+ State.First_Data_Block := FSBlock_Offset (Read_LE32 (Super_Block, 5 * 4));
declare
S_Log_Block_Size : constant Unsigned_32 := Read_LE32 (Super_Block, 6 * 4);
@@ -110,8 +110,9 @@
declare
S_Desc_Size : constant Unsigned_16 := Read_LE16 (Super_Block, 63 * 4 + 2);
begin
- if S_Desc_Size in
- Unsigned_16 (Desc_Size'First) .. Unsigned_16 (Desc_Size'Last)
+ if Is_Power_Of_2 (S_Desc_Size) and then
+ S_Desc_Size in Unsigned_16 (Desc_Size'First) ..
+ Unsigned_16 (Positive'Min (Desc_Size'Last, 2 ** State.Block_Size_Bits))
then
State.Desc_Size := Desc_Size (S_Desc_Size);
else
diff --git a/src/filo-fs-ext2.ads b/src/filo-fs-ext2.ads
index 13e23f8..63f817e 100644
--- a/src/filo-fs-ext2.ads
+++ b/src/filo-fs-ext2.ads
@@ -66,12 +66,12 @@
subtype Inode_Extents_Index is Natural range 0 .. 59;
subtype Inode_Size is Positive range 128 .. Positive (Unsigned_16'Last);
- subtype Desc_Size is Positive range 32 .. Positive (Unsigned_16'Last);
+ subtype Desc_Size is Positive range 32 .. 2 ** 15; -- power-of-2 that fits in 16 bits
type T is record
S : State;
Part_Len : Partition_Length := 0;
- First_Data_Block : Block_Offset := 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;