[Libguestfs] [PATCH] inspect: check also /etc/hosts for detecting Linux root (RHBZ#1203898)

Pino Toscano ptoscano at redhat.com
Wed Feb 24 16:31:32 UTC 2016


Use /etc/hosts as alternative of /etc/fstab to detect whether a partition
represents the root of a Linux installation; the latter might not exist
in smaller/special installations like Docker images.
---
 src/inspect-fs.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index 02fdb2a..ad175f8 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -217,7 +217,8 @@ check_filesystem (guestfs_h *g, const char *mountable,
            (is_dir_bin ||
             (guestfs_is_symlink (g, "/bin") > 0 &&
              guestfs_is_dir (g, "/usr/bin") > 0)) &&
-           guestfs_is_file (g, "/etc/fstab") > 0) {
+           (guestfs_is_file (g, "/etc/fstab") > 0 ||
+            guestfs_is_file (g, "/etc/hosts") > 0)) {
     fs->is_root = 1;
     fs->format = OS_FORMAT_INSTALLED;
     if (guestfs_int_check_linux_root (g, fs) == -1)
-- 
2.5.0




More information about the Libguestfs mailing list