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

0 views
Skip to first unread message

Nikos Skalkotos

unread,
Dec 2, 2014, 12:16:09 PM12/2/14
to libgu...@redhat.com, synnef...@googlegroups.com
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 <skal...@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

Nikos Skalkotos

unread,
Dec 3, 2014, 9:12:35 AM12/3/14
to libgu...@redhat.com, synnef...@googlegroups.com
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 <skal...@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,
Reply all
Reply to author
Forward
0 new messages