[Libguestfs] [PATCH] inspect: check also /etc/hosts for detecting Linux root (RHBZ#1203898)
Daniel P. Berrange
berrange at redhat.com
Wed Feb 24 16:38:59 UTC 2016
On Wed, Feb 24, 2016 at 05:31:32PM +0100, Pino Toscano wrote:
> 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)) {
/etc/hosts could be present on any UNIX pretty much (so could /etc/fstab
for that matter).
If you want Linux then how about /lib/ld-linux.so.2 which exists
on any Linux with ELF library support.
> fs->is_root = 1;
> fs->format = OS_FORMAT_INSTALLED;
> if (guestfs_int_check_linux_root (g, fs) == -1)
Regards,
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the Libguestfs
mailing list