| package body FILO.Blockdev is |
| |
| procedure Read |
| (Buffer : in out Buffer_Type; |
| Offset : in Natural; |
| Success : out Boolean) |
| is |
| 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 |
| Success := To_Success (C_devread (Sector, Byte_Offset, Byte_Len, Buf)); |
| end Read; |
| |
| end FILO.Blockdev; |