[Libguestfs] [PATCH 3/3, v2] inspect: improve detection of FreeBSD install discs

Pino Toscano ptoscano at redhat.com
Thu Nov 28 14:49:14 UTC 2013


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




More information about the Libguestfs mailing list