iso9660: Add FS_Record type to describe part of a block
diff --git a/src/filo-fs-iso9660.adb b/src/filo-fs-iso9660.adb
index ad462f0..eb21610 100644
--- a/src/filo-fs-iso9660.adb
+++ b/src/filo-fs-iso9660.adb
@@ -23,22 +23,14 @@
 
    procedure Read
      (Buf      :    out Buffer_Type;
-      Block    : in     FSBlock;
-      Offset   : in     FSBlock_Index;
-      FS_Len   : in     Partition_Length;
+      Rec      : in     FS_Record;
       Success  :    out Boolean)
    with
-      Pre => Buf'Length <= FSBlock_Size - Offset
+      Pre => Buf'Length <= Rec.Size
    is
-      Block_64 : constant Integer_64 := Integer_64 (Block);
-      Offset_64 : constant Integer_64 := Integer_64 (Offset);
-      Max_Block_Offset : constant Integer_64 := Integer_64 (FS_Len) / FSBlock_Size - 1;
+      Block_64 : constant Integer_64 := Integer_64 (Rec.Block);
+      Offset_64 : constant Integer_64 := Integer_64 (Rec.Offset);
    begin
-      if Block_64 > Max_Block_Offset then
-         Buf := (others => 16#00#);
-         Success := False;
-         return;
-      end if;
       Blockdev.Read (Buf, Blockdev_Length (Block_64 * FSBlock_Size + Offset_64), Success);
    end Read;
 
@@ -71,8 +63,9 @@
             Success := False;
             return;
          end if;
+         Static.Part_Len := Part_Len;
 
-         Read (Volume_Descriptor, Block, 0, Part_Len, Success);
+         Read (Volume_Descriptor, FS_Record'(Block, 0, FSBlock_Size), Success);
          if not Success then
             return;
          end if;
@@ -94,8 +87,7 @@
          end if;
       end loop;
 
-      Static.Part_Len := Part_Len;
-      Static.Root_Inode := (Block, 156);
+      Static.Root_Inode := (Block, 156, Directory_Record'Length);
 
       State.S := Mounted;
    end Mount;
@@ -108,7 +100,6 @@
       Pre => Is_Mounted (State),
       Post => Is_Mounted (State) and (Success = Is_Open (State))
    is
-      Static : Mount_State renames State.Static;
       Inode : Inode_Info renames State.Inode;
 
       Dir_Rec : Directory_Record;
@@ -117,7 +108,7 @@
 
       Inode := (I, others => <>);
 
-      Read (Dir_Rec, I.Block, I.Offset, Static.Part_Len, Success);
+      Read (Dir_Rec, I, Success);
       if not Success then
          return;
       end if;
@@ -311,8 +302,9 @@
 
                   if Success then
                      Found_Inode :=
-                       (Block => FSBlock (Dir_Pos / FSBlock_Size) + State.Inode.Extents (0).Start,
-                        Offset => FSBlock_Index (Dir_Pos mod FSBlock_Size));
+                       (Block  => FSBlock (Dir_Pos / FSBlock_Size) + State.Inode.Extents (0).Start,
+                        Offset => FSBlock_Index (Dir_Pos mod FSBlock_Size),
+                        Size   => Dir_Rec_Length);
                      exit;
                   end if;
 
@@ -404,9 +396,7 @@
             begin
                Read
                  (Buf      => Buf (Pos .. Last),
-                  Block    => Physical,
-                  Offset   => In_Block,
-                  FS_Len   => Static.Part_Len,
+                  Rec      => FS_Record'(Physical, In_Block, In_Block_Space),
                   Success  => Success);
                exit when not Success;
 
diff --git a/src/filo-fs-iso9660.ads b/src/filo-fs-iso9660.ads
index 0a28cc2..480ce39 100644
--- a/src/filo-fs-iso9660.ads
+++ b/src/filo-fs-iso9660.ads
@@ -49,22 +49,31 @@
    type State is (Unmounted, Mounted, File_Opened);
 
    FSBlock_Size : constant := 2048;
+   subtype FSBlock_Length is Index_Type range 0 .. FSBlock_Size;
    subtype FSBlock_Index is Index_Type range 0 .. FSBlock_Size - 1;
 
    type FSBlock_Count is range 0 .. 2 ** 32 - 1;
    subtype FSBlock is FSBlock_Count range 0 .. FSBlock_Count'Last - 1;
    type FSBlock_Logical is new FSBlock;
 
+   type FS_Record is record
+      Block    : FSBlock := 0;
+      Offset   : FSBlock_Length := 0;
+      Size     : FSBlock_Length := 0;
+   end record
+   with
+      Dynamic_Predicate =>
+         Size <= FSBlock_Size - Offset;
+
    subtype Directory_Record_Range is Index_Type range 0 .. 32;
    subtype Directory_Record is Buffer_Type (Directory_Record_Range);
    subtype Directory_Record_Offset is FSBlock_Index
       range 0 .. FSBlock_Size - Directory_Record'Length;
 
    -- We'll use the absolute position of the dir record
-   type Inode_Index is record
-      Block : FSBlock := 0;
-      Offset : Directory_Record_Offset := 0;
-   end record;
+   subtype Inode_Index is FS_Record
+   with
+      Dynamic_Predicate => Inode_Index.Offset <= Directory_Record_Offset'Last;
    type Inode_Length is range 0 .. FSBlock_Count'Last * FSBlock_Size;
 
    type Mount_State is record