iso9660: Handle multiple directory blocks
Directory records cannot span multiple blocks. Instead, a block ends
with an empty directory record. And we have to jump to the next block.
diff --git a/src/filo-fs-iso9660.adb b/src/filo-fs-iso9660.adb
index 110201f..fd12854 100644
--- a/src/filo-fs-iso9660.adb
+++ b/src/filo-fs-iso9660.adb
@@ -225,7 +225,6 @@
Dir_Rec : Directory_Record;
Dir_Rec_Name : Buffer_Type (0 .. File_Name_Max - 1);
Record_Dir_Pos : File_Offset := Dir_Pos;
- Dir_Rec_Length : File_Length;
Len : Natural;
begin
Read
@@ -281,16 +280,25 @@
end if;
end if;
- Dir_Rec_Length := File_Length (Dir_Rec (0));
- if Dir_Rec_Length = 0 or else
- Dir_Pos > File_Length'Last - Dir_Rec_Length or else
- (Dir_Pos + Dir_Rec_Length) mod FSBlock_Size
- > File_Length (Directory_Record_Offset'Last) or else
- Unsigned_64 (Dir_Pos) >= Unsigned_64 (State.Inode.Size) - Unsigned_64 (Dir_Rec_Length)
- then
- return;
- end if;
- Dir_Pos := Dir_Pos + Dir_Rec_Length;
+ declare
+ Dir_Rec_Length : constant File_Length := File_Length (Dir_Rec (0));
+ Block_Gap : constant File_Length := FSBlock_Size - (Dir_Pos mod FSBlock_Size);
+ begin
+ -- End of block?
+ if Dir_Rec_Length = Block_Gap or Dir_Rec_Length = 0 then
+ if Unsigned_64 (Dir_Pos) >= Unsigned_64 (State.Inode.Size) - Unsigned_64 (Block_Gap) then
+ return;
+ else
+ Dir_Pos := Dir_Pos + Block_Gap;
+ end if;
+ else
+ if Unsigned_64 (Dir_Pos) > Unsigned_64 (State.Inode.Size) - Unsigned_64 (Dir_Rec_Length) then
+ return;
+ else
+ Dir_Pos := Dir_Pos + Dir_Rec_Length;
+ end if;
+ end if;
+ end;
end;
end loop;
pragma Assert_And_Cut (Success and Is_Mounted (State));