Drop `File_Len` from VFS.Read()
The `File_Len` is never supposed to change outside the FS driver.
diff --git a/src/filo-fs-ext2.adb b/src/filo-fs-ext2.adb
index ace8c6a..ec17fe4 100644
--- a/src/filo-fs-ext2.adb
+++ b/src/filo-fs-ext2.adb
@@ -751,7 +751,6 @@
procedure Read
(State : in out T;
- File_Len : in File_Length;
File_Pos : in out File_Offset;
Buf : out Buffer_Type;
Len : out Natural)
@@ -759,11 +758,11 @@
Pos : Natural;
begin
if State.Inode.Mode = Fast_Link then
- if File_Len > State.Inode.Inline'Length or
- File_Pos >= File_Len then
+ if State.Inode.Size > Inode_Length (State.Inode.Inline'Length) or
+ Inode_Length (File_Pos) >= State.Inode.Size then
Len := 0;
else
- Len := Natural'Min (Buf'Length, Natural (File_Len - File_Pos));
+ Len := Natural'Min (Buf'Length, Natural (State.Inode.Size) - Natural (File_Pos));
end if;
Buf (Buf'First .. Buf'First + Len - 1) :=
State.Inode.Inline (Natural (File_Pos) .. Natural (File_Pos) + Len - 1);
@@ -780,13 +779,13 @@
In_Block : constant Max_Block_Index := Natural (File_Pos mod Block_Size);
Logical : constant FSBlock_Logical := FSBlock_Logical (File_Pos / Block_Size);
In_Block_Space : constant Natural := Natural (Block_Size) - In_Block;
- In_File_Space : constant Natural := Natural (File_Len - File_Pos);
+ In_File_Space : constant Inode_Length := State.Inode.Size - Inode_Length (File_Pos);
In_Buf_Space : constant Natural := Buf'Last - Pos + 1;
Len_Here : Natural;
begin
Len_Here := In_Block_Space;
- if In_File_Space < Len_Here then
- Len_Here := In_File_Space;
+ if In_File_Space < Inode_Length (Len_Here) then
+ Len_Here := Natural (In_File_Space);
end if;
if In_Buf_Space < Len_Here then
Len_Here := In_Buf_Space;
diff --git a/src/filo-fs-ext2.ads b/src/filo-fs-ext2.ads
index ac78bc1..a12c50d 100644
--- a/src/filo-fs-ext2.ads
+++ b/src/filo-fs-ext2.ads
@@ -31,7 +31,6 @@
procedure Read
(State : in out T;
- File_Len : in File_Length;
File_Pos : in out File_Offset;
Buf : out Buffer_Type;
Len : out Natural)
diff --git a/src/filo-fs-vfs.adb b/src/filo-fs-vfs.adb
index 838cddf..a76d84c 100644
--- a/src/filo-fs-vfs.adb
+++ b/src/filo-fs-vfs.adb
@@ -54,7 +54,7 @@
Read_Len : Natural;
begin
if Is_Open (State) then
- Read (State, File_Max, File_Pos, Buffer, Read_Len);
+ Read (State, File_Pos, Buffer, Read_Len);
Set_File_Pos (File_Pos);
else
Read_Len := 0;
diff --git a/src/filo-fs-vfs.ads b/src/filo-fs-vfs.ads
index 500c77b..9e47f6f 100644
--- a/src/filo-fs-vfs.ads
+++ b/src/filo-fs-vfs.ads
@@ -42,7 +42,6 @@
with procedure Read
(State : in out T;
- File_Len : in File_Length;
File_Pos : in out File_Offset;
Buf : out Buffer_Type;
Len : out Natural)