On Wednesday 24 February 2016 16:38:59 Daniel P. Berrange wrote:
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).
I know -- the case here was about Docker images without /etc/fstab.
If you want Linux then how about /lib/ld-linux.so.2 which exists
on any Linux with ELF library support.
Well, that is not universally available: on my Fedora 23 it doesn't
exist, and indeed:
$ env LC_ALL=C readelf -l /bin/ls \
| perl -n -e 'if (/program interpreter: (.*)]/) { print $1 . "\n";
}'
/lib64/ld-linux-x86-64.so.2
--
Pino Toscano