add Ada wrapper for C_devread
Signed-off-by: Thomas Heijligen <src@posteo.de>
diff --git a/src/fs-filo-dev.adb b/src/fs-filo-dev.adb
index f07bb28..97c7d1b 100644
--- a/src/fs-filo-dev.adb
+++ b/src/fs-filo-dev.adb
@@ -5,15 +5,19 @@
Offset : in Natural;
Success : out Boolean)
is
- --Sector_Size : constant Natural := 512;
- --Sector : constant Interfaces.C.unsigned_long := Offset / Sector_Size;
- --Byte_Offset : constant Interfaces.C.unsigned_long := Offset rem Sector_Size;
- --Byte_Len : constant Interfaces.C.unsigned_long := Buffer'Length;
- --function To_Bool(Item : Interfaces.C.int) return Bool is
- -- (if Item = 0 then False else True);
+ use Interfaces.C;
+
+ Sector : constant unsigned_long := unsigned_long (Offset) / 512;
+ Byte_Offset : constant unsigned_long := unsigned_long (Offset) rem 512;
+ Byte_Len : constant unsigned_long := unsigned_long (Buffer'Length);
+ Buf : constant System.Address := Buffer'Address;
+
+ -- NOTE: C_devread returns 1 on success
+ function To_Success (Item : Interfaces.C.int) return Boolean is
+ (if Item = 1 then True else False);
+
begin
- null;
- --Success := To_Bool (C_devread (Sector, Byte_Offset, Byte_Len, Buffer'Address));
+ Success := To_Success (C_devread (Sector, Byte_Offset, Byte_Len, Buf));
end Read;
end FS.FILO.Dev;