blob: a00e0a460b8afe10bec4cbe944c19107aeb4b08f [file] [log] [blame]
Nico Huber8ec45a12023-12-04 17:11:08 +01001with System;
Nico Huber1d7727f2023-11-30 15:58:46 +01002with Interfaces;
Nico Huber8ec45a12023-12-04 17:11:08 +01003with Interfaces.C;
4with Interfaces.C.Strings;
Nico Huber1d7727f2023-11-30 15:58:46 +01005
6with FS.FILO.Dev;
Nico Huber8ec45a12023-12-04 17:11:08 +01007with FS.FILO.VFS;
8
9use Interfaces.C;
Nico Huber1d7727f2023-11-30 15:58:46 +010010
11package body FS.FILO.Ext2 is
12
Nico Huber57d3a852023-12-04 15:42:40 +010013 function Is_Mounted (State : T) return Boolean is (State.S >= Mounted);
14 function Is_Open (State : T) return Boolean is (State.S = File_Opened);
15
16 procedure Mount
17 (State : in out T;
18 Part_Len : in Partition_Length;
19 Success : out Boolean)
Nico Huber1d7727f2023-11-30 15:58:46 +010020 is
21 begin
22 Success := False;
23 end Mount;
24
Nico Huber57d3a852023-12-04 15:42:40 +010025 procedure Open
26 (State : in out T;
27 File_Len : out File_Length;
28 File_Path : in String;
29 Success : out Boolean)
Nico Huber1d7727f2023-11-30 15:58:46 +010030 is
31 begin
Nico Huber57d3a852023-12-04 15:42:40 +010032 File_Len := 0;
Nico Huber1d7727f2023-11-30 15:58:46 +010033 Success := False;
34 end Open;
35
Nico Huber57d3a852023-12-04 15:42:40 +010036 procedure Close (State : in out T) is
37 begin
38 State.S := Mounted;
39 end Close;
Nico Huber1d7727f2023-11-30 15:58:46 +010040
Nico Huber57d3a852023-12-04 15:42:40 +010041 procedure Read
42 (State : in out T;
43 File_Len : in File_Length;
44 File_Pos : in out File_Offset;
45 Buf : out Buffer_Type;
46 Len : out Natural)
Nico Huber1d7727f2023-11-30 15:58:46 +010047 is
48 begin
Nico Huber57d3a852023-12-04 15:42:40 +010049 Buf := (others => 0);
Nico Huber1d7727f2023-11-30 15:58:46 +010050 Len := 0;
51 end Read;
52
Nico Huber8ec45a12023-12-04 17:11:08 +010053 package C is new VFS (T => T, Initial => (S => Unmounted));
54
55 function C_Mount return int
56 with
57 Export,
58 Convention => C,
59 External_Name => "ext2fs_mount";
60 function C_Mount return int
61 with
62 SPARK_Mode => Off
63 is
64 begin
65 return C.C_Mount;
66 end C_Mount;
67
68 function C_Open (File_Path : Strings.chars_ptr) return int
69 with
70 Export,
71 Convention => C,
72 External_Name => "ext2fs_dir";
73 function C_Open (File_Path : Strings.chars_ptr) return int
74 with
75 SPARK_Mode => Off
76 is
77 begin
78 return C.C_Open (File_Path);
79 end C_Open;
80
81 function C_Read (Buf : System.Address; Len : int) return int
82 with
83 Export,
84 Convention => C,
85 External_Name => "ext2fs_read";
86 function C_Read (Buf : System.Address; Len : int) return int
87 with
88 SPARK_Mode => Off
89 is
90 begin
91 return C.C_Read (Buf, Len);
92 end C_Read;
93
Nico Huber1d7727f2023-11-30 15:58:46 +010094end FS.FILO.Ext2;