blob: 73195bacd0c12eb21ed365321334ab67e577394d [file] [log] [blame]
Thomas Heijligena6d63152024-01-29 13:43:40 +00001with FILO.Blockdev;
2
Thomas Heijligen51820372023-12-11 15:29:17 +00003package body FILO.FS.NullFS is
4
Thomas Heijligen51820372023-12-11 15:29:17 +00005 function To_Int (Success : Boolean) return Interfaces.C.int is
6 (if Success then 1 else 0);
7
Thomas Heijligena6d63152024-01-29 13:43:40 +00008 function C_Mount return Interfaces.C.int is
Thomas Heijligen51820372023-12-11 15:29:17 +00009 begin
Thomas Heijligena6d63152024-01-29 13:43:40 +000010 return To_Int (True);
Thomas Heijligen51820372023-12-11 15:29:17 +000011 end C_Mount;
12
13 function C_Read
14 (buf : System.Address;
15 len : Interfaces.C.int)
16 return Interfaces.C.int
17 with SPARK_Mode => Off
18 is
Thomas Heijligen51820372023-12-11 15:29:17 +000019 Buffer : Buffer_Type (0 .. Integer(len) - 1) with Address => buf;
Thomas Heijligena6d63152024-01-29 13:43:40 +000020 Offset : constant Blockdev_Offset := Blockdev_Offset(File_Pos);
Thomas Heijligen51820372023-12-11 15:29:17 +000021 Success : Boolean;
22 begin
Thomas Heijligena6d63152024-01-29 13:43:40 +000023 FILO.Blockdev.Read (Buffer, Offset, Success);
24 return To_Int (Success);
Thomas Heijligen51820372023-12-11 15:29:17 +000025 end C_Read;
26
Thomas Heijligena6d63152024-01-29 13:43:40 +000027
Thomas Heijligen51820372023-12-11 15:29:17 +000028 function C_Dir
Thomas Heijligena6d63152024-01-29 13:43:40 +000029 (Path : System.Address)
Thomas Heijligen51820372023-12-11 15:29:17 +000030 return Interfaces.C.int
31 with SPARK_Mode => Off
32 is
Thomas Heijligena6d63152024-01-29 13:43:40 +000033 First_Byte : Unsigned_8 with Address => Path;
Thomas Heijligen51820372023-12-11 15:29:17 +000034 begin
Thomas Heijligena6d63152024-01-29 13:43:40 +000035 if First_Byte = 0 then
36 return To_Int (True);
37 end if;
38 return To_Int (False);
Thomas Heijligen51820372023-12-11 15:29:17 +000039 end C_Dir;
40
Thomas Heijligen51820372023-12-11 15:29:17 +000041end FILO.FS.NullFS;