[Libguestfs] [PATCH 4/5] Fix fstab block device resolution for FreeBSD

Nikos Skalkotos skalkoto at grnet.gr
Tue Dec 2 17:15:59 UTC 2014


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 at 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 3a2f81a..b1a2f8f 100644
--- a/src/inspect-fs-unix.c
+++ b/src/inspect-fs-unix.c
@@ -1620,9 +1620,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




More information about the Libguestfs mailing list