From e73cf67762f7eb7b0850a74b9610c6e18b64352c Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Thu, 20 Dec 2012 15:33:12 +0000 Subject: [PATCH] inspection: Set fs->device field on swap devices. For some reason the fs->device field was not set for swap devices. Apparently this did not matter before (this bug has existed since at least libguestfs 1.16), but in commit 6ee80b8dac we started to depend on the fs->device field being non-NULL. This resulted in segfaults when inspecting any guest which had a swap device, eg: #0 __strcmp_sse42 () at ../sysdeps/x86_64/multiarch/strcmp-sse42.S:164 #1 0x00007ffff7d740cb in parent_device_already_probed (g=0x703a70, partition=0x6f79b0 "/dev/vda4") at inspect.c:156 #2 0x00007ffff7d73e00 in guestfs__inspect_os (g=0x703a70) at inspect.c:83 #3 0x00007ffff7cee11d in guestfs_inspect_os (g=0x703a70) at actions-1.c:397 This commit sets fs->device to the device name. (Thanks Matthew Booth for first noticing this problem.) --- src/inspect-fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 0b1ba926b..fed77614c 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -112,6 +112,7 @@ guestfs___check_for_filesystem_on (guestfs_h *g, const char *device, if (extend_fses (g) == -1) return -1; fs = &g->fses[g->nr_fses-1]; + fs->device = safe_strdup (g, device); return 0; }