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;