Express C code `part_length' in 512B blocks (as FILO does)
Signed-off-by: Nico Huber <nico.huber@secunet.com>
diff --git a/src/blockdev.c b/src/blockdev.c
index 2395c45..91879c4 100644
--- a/src/blockdev.c
+++ b/src/blockdev.c
@@ -32,7 +32,7 @@
}
part_start = 0;
- part_length = device_size;
+ part_length = device_size / 512;
return 1;
}
@@ -79,13 +79,13 @@
{
if (start + size <= device_size) {
part_start = start;
- part_length = size;
+ part_length = size / 512;
}
}
void dev_get_partition(unsigned long *start, unsigned long *size)
{
*start = part_start;
- *size = part_length;
+ *size = part_length * 512;
}
diff --git a/src/filo-fs.adb b/src/filo-fs.adb
index 91f86f0..bc4c246 100644
--- a/src/filo-fs.adb
+++ b/src/filo-fs.adb
@@ -18,10 +18,19 @@
Convention => C,
External_Name => "filepos";
+ pragma Warnings
+ (GNAT, Off, "condition can only be False*",
+ Reason => "Depends on `unsigned long` size.");
+ pragma Warnings
+ (GNAT, Off, "condition is always True",
+ Reason => "Depends on `unsigned long` size.");
function Part_Len return Partition_Length
is
- (Partition_Length (Unsigned_64'Min (
- Unsigned_64 (C_Part_Length), Unsigned_64 (Partition_Length'Last))));
+ (if Unsigned_64 (C_Part_Length) <= Unsigned_64 (Partition_Length'Last) / 512
+ then Partition_Length (C_Part_Length) * 512
+ else Partition_Length'Last);
+ pragma Warnings (GNAT, On, "condition can only be False*");
+ pragma Warnings (GNAT, On, "condition is always True");
function File_Max return File_Length is
begin