[PATCH 1/3] inspect: recognise Debian live images as such
Check for filesystem.squashfs also in /live, since it is where live-build places it. --- src/inspect-fs-cd.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index 407e4f8..eaeaa6f 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -429,7 +429,8 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) * Fedora live CDs which contain the same, but larger file). We * need to unpack this and look inside to tell the difference. */ - if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0) + if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0 || + guestfs_is_file (g, "/live/filesystem.squashfs") > 0) fs->is_live_disk = 1; /* Debian/Ubuntu. */ -- 1.8.3.1
/etc/fstab in installation discs of FreeBSD can have an entry pointing to the mounted CD itself; skip it as it is done with other CD devices in check_fstab. --- src/inspect-fs-unix.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/inspect-fs-unix.c b/src/inspect-fs-unix.c index 8e0f135..a9e5cad 100644 --- a/src/inspect-fs-unix.c +++ b/src/inspect-fs-unix.c @@ -916,10 +916,15 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs) if (spec == NULL) return -1; - /* Ignore /dev/fd (floppy disks) (RHBZ#642929) and CD-ROM drives. */ + /* Ignore /dev/fd (floppy disks) (RHBZ#642929) and CD-ROM drives. + * + * /dev/iso9660/FREEBSD_INSTALL can be found in FreeBSDs installation + * discs. + */ if ((STRPREFIX (spec, "/dev/fd") && c_isdigit (spec[7])) || STREQ (spec, "/dev/floppy") || - STREQ (spec, "/dev/cdrom")) + STREQ (spec, "/dev/cdrom") || + STRPREFIX (spec, "/dev/iso9660/")) continue; snprintf (augpath, sizeof augpath, "%s/file", *entry); -- 1.8.3.1
Check for /boot/loader.rc as "install disc" detection, using it to mark FreeBSD install discs. Also, check for /mfsroot.gz to see whether such disc is also a live one. See also RHBZ#1033207. --- src/inspect-fs-cd.c | 19 ++++++++++++++++++- src/inspect-fs.c | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index eaeaa6f..fff0629 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -327,6 +327,16 @@ check_isolinux_installer_root (guestfs_h *g, struct inspect_fs *fs) return 0; } +/* FreeBSD with /boot/loader.rc. + */ +static int +check_freebsd_installer_root (guestfs_h *g, struct inspect_fs *fs) +{ + fs->type = OS_TYPE_FREEBSD; + + return 0; +} + /* Windows 2003 and similar versions. * * NB: txtsetup file contains Windows \r\n line endings, which guestfs_grep @@ -430,7 +440,8 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) * need to unpack this and look inside to tell the difference. */ if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0 || - guestfs_is_file (g, "/live/filesystem.squashfs") > 0) + guestfs_is_file (g, "/live/filesystem.squashfs") > 0 || + guestfs_is_file (g, "/mfsroot.gz") > 0) fs->is_live_disk = 1; /* Debian/Ubuntu. */ @@ -461,6 +472,12 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) return -1; } + /* FreeBSD. */ + else if (guestfs_is_file (g, "/boot/loader.rc") > 0) { + if (check_freebsd_installer_root (g, fs) == -1) + return -1; + } + /* Windows 2003 64 bit */ else if (guestfs_is_file (g, "/amd64/txtsetup.sif") > 0) { fs->arch = safe_strdup (g, "x86_64"); diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 0473e92..89c9335 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -320,7 +320,8 @@ check_filesystem (guestfs_h *g, const char *mountable, guestfs_is_file (g, "/.discinfo") > 0 || guestfs_is_file (g, "/i386/txtsetup.sif") > 0 || guestfs_is_file (g, "/amd64/txtsetup.sif") > 0 || - guestfs_is_file (g, "/freedos/freedos.ico") > 0)) { + guestfs_is_file (g, "/freedos/freedos.ico") > 0 || + guestfs_is_file (g, "/boot/loader.rc") > 0)) { fs->is_root = 1; fs->format = OS_FORMAT_INSTALLER; if (guestfs___check_installer_root (g, fs) == -1) -- 1.8.3.1
On Thu, Nov 28, 2013 at 02:48:38PM +0100, Pino Toscano wrote:
Check for /boot/loader.rc as "install disc" detection, using it to mark FreeBSD install discs. Also, check for /mfsroot.gz to see whether such disc is also a live one.
See also RHBZ#1033207. --- src/inspect-fs-cd.c | 19 ++++++++++++++++++- src/inspect-fs.c | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index eaeaa6f..fff0629 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -327,6 +327,16 @@ check_isolinux_installer_root (guestfs_h *g, struct inspect_fs *fs) return 0; }
+/* FreeBSD with /boot/loader.rc. + */ +static int +check_freebsd_installer_root (guestfs_h *g, struct inspect_fs *fs) +{ + fs->type = OS_TYPE_FREEBSD; + + return 0; +} + /* Windows 2003 and similar versions. * * NB: txtsetup file contains Windows \r\n line endings, which guestfs_grep @@ -430,7 +440,8 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) * need to unpack this and look inside to tell the difference. */ if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0 || - guestfs_is_file (g, "/live/filesystem.squashfs") > 0) + guestfs_is_file (g, "/live/filesystem.squashfs") > 0 || + guestfs_is_file (g, "/mfsroot.gz") > 0) fs->is_live_disk = 1;
/* Debian/Ubuntu. */ @@ -461,6 +472,12 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) return -1; }
+ /* FreeBSD. */ + else if (guestfs_is_file (g, "/boot/loader.rc") > 0) { + if (check_freebsd_installer_root (g, fs) == -1) + return -1; + }
I think you should just inline this function, makes the code simpler.
/* Windows 2003 64 bit */ else if (guestfs_is_file (g, "/amd64/txtsetup.sif") > 0) { fs->arch = safe_strdup (g, "x86_64"); diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 0473e92..89c9335 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -320,7 +320,8 @@ check_filesystem (guestfs_h *g, const char *mountable, guestfs_is_file (g, "/.discinfo") > 0 || guestfs_is_file (g, "/i386/txtsetup.sif") > 0 || guestfs_is_file (g, "/amd64/txtsetup.sif") > 0 || - guestfs_is_file (g, "/freedos/freedos.ico") > 0)) { + guestfs_is_file (g, "/freedos/freedos.ico") > 0 || + guestfs_is_file (g, "/boot/loader.rc") > 0)) { fs->is_root = 1; fs->format = OS_FORMAT_INSTALLER; if (guestfs___check_installer_root (g, fs) == -1) -- 1.8.3.1
Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On Thursday 28 November 2013 14:12:16 Richard W.M. Jones wrote:
On Thu, Nov 28, 2013 at 02:48:38PM +0100, Pino Toscano wrote:
Check for /boot/loader.rc as "install disc" detection, using it to mark FreeBSD install discs. Also, check for /mfsroot.gz to see whether such disc is also a live one.
See also RHBZ#1033207. ---
src/inspect-fs-cd.c | 19 ++++++++++++++++++- src/inspect-fs.c | 3 ++- 2 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index eaeaa6f..fff0629 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -327,6 +327,16 @@ check_isolinux_installer_root (guestfs_h *g, struct inspect_fs *fs)> return 0;
}
+/* FreeBSD with /boot/loader.rc. + */ +static int +check_freebsd_installer_root (guestfs_h *g, struct inspect_fs *fs) +{ + fs->type = OS_TYPE_FREEBSD; + + return 0; +} +
/* Windows 2003 and similar versions.
* * NB: txtsetup file contains Windows \r\n line endings, which guestfs_grep> @@ -430,7 +440,8 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs)> * need to unpack this and look inside to tell the difference. */
if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0 ||
- guestfs_is_file (g, "/live/filesystem.squashfs") > 0) + guestfs_is_file (g, "/live/filesystem.squashfs") > 0 || + guestfs_is_file (g, "/mfsroot.gz") > 0)
fs->is_live_disk = 1;
/* Debian/Ubuntu. */
@@ -461,6 +472,12 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs)> return -1;
}
+ /* FreeBSD. */ + else if (guestfs_is_file (g, "/boot/loader.rc") > 0) { + if (check_freebsd_installer_root (g, fs) == -1) + return -1; + }
I think you should just inline this function, makes the code simpler.
That is OK too. I added it to follow what has been done for the other OSes/cases, to have an own function in case there is more work to do. It can be split again, if needed, I guess. Sending a v2 of this. -- Pino Toscano
Check for /boot/loader.rc as "install disc" detection, using it to mark FreeBSD install discs. Also, check for /mfsroot.gz to see whether such disc is also a live one. See also RHBZ#1033207. --- src/inspect-fs-cd.c | 8 +++++++- src/inspect-fs.c | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/inspect-fs-cd.c b/src/inspect-fs-cd.c index eaeaa6f..45d7bb5 100644 --- a/src/inspect-fs-cd.c +++ b/src/inspect-fs-cd.c @@ -430,7 +430,8 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) * need to unpack this and look inside to tell the difference. */ if (guestfs_is_file (g, "/casper/filesystem.squashfs") > 0 || - guestfs_is_file (g, "/live/filesystem.squashfs") > 0) + guestfs_is_file (g, "/live/filesystem.squashfs") > 0 || + guestfs_is_file (g, "/mfsroot.gz") > 0) fs->is_live_disk = 1; /* Debian/Ubuntu. */ @@ -461,6 +462,11 @@ guestfs___check_installer_root (guestfs_h *g, struct inspect_fs *fs) return -1; } + /* FreeBSD with /boot/loader.rc. */ + else if (guestfs_is_file (g, "/boot/loader.rc") > 0) { + fs->type = OS_TYPE_FREEBSD; + } + /* Windows 2003 64 bit */ else if (guestfs_is_file (g, "/amd64/txtsetup.sif") > 0) { fs->arch = safe_strdup (g, "x86_64"); diff --git a/src/inspect-fs.c b/src/inspect-fs.c index 0473e92..89c9335 100644 --- a/src/inspect-fs.c +++ b/src/inspect-fs.c @@ -320,7 +320,8 @@ check_filesystem (guestfs_h *g, const char *mountable, guestfs_is_file (g, "/.discinfo") > 0 || guestfs_is_file (g, "/i386/txtsetup.sif") > 0 || guestfs_is_file (g, "/amd64/txtsetup.sif") > 0 || - guestfs_is_file (g, "/freedos/freedos.ico") > 0)) { + guestfs_is_file (g, "/freedos/freedos.ico") > 0 || + guestfs_is_file (g, "/boot/loader.rc") > 0)) { fs->is_root = 1; fs->format = OS_FORMAT_INSTALLER; if (guestfs___check_installer_root (g, fs) == -1) -- 1.8.3.1
On Thu, Nov 28, 2013 at 03:49:14PM +0100, Pino Toscano wrote:
Check for /boot/loader.rc as "install disc" detection, using it to mark FreeBSD install discs. Also, check for /mfsroot.gz to see whether such disc is also a live one.
As this fixes RHBZ#1033207, I changed the summary line to include this bug number (the rest of the patch is identical). This is to ensure that the 'bugs-in-changelog.sh' script will pick up the bug and put it into the release notes for 1.26 automatically. I have pushed all three upstream. Thanks for your contribution! Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
participants (2)
-
Pino Toscano -
Richard W.M. Jones