Take into granted that partition 'c' has a special purpose. It has
always the same size as the enclosing slice and is not mapped under
Linux.
This is a best effort try. The mapping will be incorrect if there is a
gap in the disklabel partitions sequence, e.g. 'b' (swap) partition is
missing but 'd' partition is defined.
Signed-off-by: Nikos Skalkotos <skalkoto(a)grnet.gr>
---
src/inspect-fs-unix.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c
index 18be68b..b3c813d 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -1624,9 +1624,13 @@ resolve_fstab_device (guestfs_h *g, const char *spec, Hash_table
*md_map,
free (slice);
free (part);
+ if (part_i > 2)
+ /* Partition 'c' has the size of the enclosing slice. Not mapped under
Linux. */
+ part_i -= 1;
+
if (disk_i != -1 && disk_i <= 26 &&
slice_i > 0 && slice_i <= 1 /* > 4 .. see comment above */
&&
- part_i >= 0 && part_i < 26) {
+ part_i >= 0 && part_i < 25) {
device = safe_asprintf (g, "/dev/sd%c%d", disk_i + 'a', part_i +
5);
}
}
--
2.1.3
Show replies by date