blob: 32e31fe480320b543efd5bc9ec86bbb183a3c7bc [file] [log] [blame]
Nico Huber1d7727f2023-11-30 15:58:46 +01001package FS.FILO.Ext2 is
2
Nico Huber57d3a852023-12-04 15:42:40 +01003 type T is private;
Nico Huber1d7727f2023-11-30 15:58:46 +01004
Nico Huber57d3a852023-12-04 15:42:40 +01005 function Is_Mounted (State : T) return Boolean;
6 function Is_Open (State : T) return Boolean
Nico Huber1d7727f2023-11-30 15:58:46 +01007 with
Nico Huber57d3a852023-12-04 15:42:40 +01008 Post => (if Is_Open'Result then Is_Mounted (State));
Nico Huber1d7727f2023-11-30 15:58:46 +01009
Nico Huber57d3a852023-12-04 15:42:40 +010010 procedure Mount
11 (State : in out T;
12 Part_Len : in Partition_Length;
13 Success : out Boolean)
Nico Huber1d7727f2023-11-30 15:58:46 +010014 with
Nico Huber57d3a852023-12-04 15:42:40 +010015 Pre => not Is_Mounted (State),
16 Post => Success = Is_Mounted (State);
Nico Huber1d7727f2023-11-30 15:58:46 +010017
Nico Huber57d3a852023-12-04 15:42:40 +010018 procedure Open
19 (State : in out T;
20 File_Len : out File_Length;
21 File_Path : in String;
22 Success : out Boolean)
Nico Huber1d7727f2023-11-30 15:58:46 +010023 with
Nico Huber57d3a852023-12-04 15:42:40 +010024 Pre => Is_Mounted (State) and not Is_Open (State),
25 Post => Success = Is_Open (State);
26
27 procedure Close (State : in out T)
28 with
29 Pre => Is_Open (State),
30 Post => Is_Mounted (State);
31
32 procedure Read
33 (State : in out T;
34 File_Len : in File_Length;
35 File_Pos : in out File_Offset;
36 Buf : out Buffer_Type;
37 Len : out Natural)
38 with
39 Pre => Is_Open (State),
40 Post => Is_Open (State);
41
42private
43 type State is (Unmounted, Mounted, File_Opened);
44
Nico Huber26f71832023-12-05 16:26:56 +010045 -- maximum block size is 64KiB (2^16):
46 subtype Log_Block_Size is Positive range 10 .. 16;
47
48 subtype Inode_Size is Positive range 128 .. Positive (Unsigned_16'Last);
49 subtype Desc_Size is Positive range 32 .. Positive (Unsigned_16'Last);
50
Nico Huber57d3a852023-12-04 15:42:40 +010051 type T is record
52 S : State;
Nico Huber26f71832023-12-05 16:26:56 +010053 Part_Len : Partition_Length := 0;
54 First_Data_Block : Block_Offset := 0;
55 Block_Size_Bits : Log_Block_Size := 10;
56 Inodes_Per_Group : Positive := 1;
57 Inode_Size : Ext2.Inode_Size := Ext2.Inode_Size'First;
58 Desc_Size : Ext2.Desc_Size := Ext2.Desc_Size'First;
59 Feature_Extents : Boolean := False;
60 Feature_64Bit : Boolean := False;
Nico Huber57d3a852023-12-04 15:42:40 +010061 end record;
Nico Huber1d7727f2023-11-30 15:58:46 +010062
63end FS.FILO.Ext2;