Use /etc/hosts instead 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.
Put an empty /etc/hosts in all the phony Linux guests to keep them
detected as we want.
---
src/inspect-fs.c | 2 +-
test-data/phony-guests/make-archlinux-img.sh | 1 +
test-data/phony-guests/make-coreos-img.sh | 1 +
test-data/phony-guests/make-debian-img.sh | 1 +
test-data/phony-guests/make-fedora-img.pl | 1 +
test-data/phony-guests/make-ubuntu-img.sh | 1 +
6 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/inspect-fs.c b/src/inspect-fs.c
index 02fdb2a..82e1254 100644
--- a/src/inspect-fs.c
+++ b/src/inspect-fs.c
@@ -217,7 +217,7 @@ 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/hosts") > 0) {
fs->is_root = 1;
fs->format = OS_FORMAT_INSTALLED;
if (guestfs_int_check_linux_root (g, fs) == -1)
diff --git a/test-data/phony-guests/make-archlinux-img.sh
b/test-data/phony-guests/make-archlinux-img.sh
index 066df09..f748171 100755
--- a/test-data/phony-guests/make-archlinux-img.sh
+++ b/test-data/phony-guests/make-archlinux-img.sh
@@ -45,6 +45,7 @@ mkdir-p /var/lib/pacman/local/test-package-1:0.1-1
write /etc/fstab "/dev/sda1 / ext4 rw,relatime,data=ordered 0 1"
touch /etc/arch-release
+touch /etc/hosts
write /etc/hostname "archlinux.test"
upload $SRCDIR/archlinux-package /var/lib/pacman/local/test-package-1:0.1-1/desc
diff --git a/test-data/phony-guests/make-coreos-img.sh
b/test-data/phony-guests/make-coreos-img.sh
index 1de2f25..e229926 100755
--- a/test-data/phony-guests/make-coreos-img.sh
+++ b/test-data/phony-guests/make-coreos-img.sh
@@ -76,6 +76,7 @@ write /etc/coreos/update.conf "GROUP=stable"
upload archlinux.release /usr/share/coreos/lsb-release
ln-s ../usr/share/coreos/lsb-release /etc/lsb-release
write /etc/hostname "coreos.invalid"
+touch /etc/hosts
EOF
diff --git a/test-data/phony-guests/make-debian-img.sh
b/test-data/phony-guests/make-debian-img.sh
index 637bd4b..0b4f75e 100755
--- a/test-data/phony-guests/make-debian-img.sh
+++ b/test-data/phony-guests/make-debian-img.sh
@@ -81,6 +81,7 @@ mkdir /var/log
upload debian.fstab /etc/fstab
write /etc/debian_version "5.0.1"
write /etc/hostname "debian.invalid"
+touch /etc/hosts
upload $SRCDIR/debian-packages /var/lib/dpkg/status
diff --git a/test-data/phony-guests/make-fedora-img.pl
b/test-data/phony-guests/make-fedora-img.pl
index 192f48f..b1098ba 100755
--- a/test-data/phony-guests/make-fedora-img.pl
+++ b/test-data/phony-guests/make-fedora-img.pl
@@ -211,6 +211,7 @@ $g->write ('/etc/motd', "Welcome to Fedora release 14
(Phony)\n");
$g->write ('/etc/redhat-release', 'Fedora release 14 (Phony)');
$g->write ('/etc/fedora-release', 'Fedora release 14 (Phony)');
$g->write ('/etc/sysconfig/network', 'HOSTNAME=fedora.invalid');
+$g->touch ('/etc/hosts');
if (-f "fedora.mdadm") {
$g->upload ("fedora.mdadm", '/etc/mdadm.conf');
diff --git a/test-data/phony-guests/make-ubuntu-img.sh
b/test-data/phony-guests/make-ubuntu-img.sh
index a3aa610..b49e8ff 100755
--- a/test-data/phony-guests/make-ubuntu-img.sh
+++ b/test-data/phony-guests/make-ubuntu-img.sh
@@ -72,6 +72,7 @@ upload ubuntu.fstab /etc/fstab
write /etc/debian_version "5.0.1"
upload ubuntu.release /etc/lsb-release
write /etc/hostname "ubuntu.invalid"
+touch /etc/hosts
upload $SRCDIR/debian-packages /var/lib/dpkg/status
--
2.5.0