[Libguestfs] [PATCH] guestfs_file_arch command

Richard W.M. Jones rjones at redhat.com
Tue Jul 28 13:07:25 UTC 2009


On Tue, Jul 28, 2009 at 01:23:07PM +0100, Matthew Booth wrote:
> Why not use libmagic for this? This looks like a whole lot of voodoo we  
> don't want to be maintaining.

As I understand it (correct me if I'm wrong), libmagic is just a
programmatic way to use file(1), which we already expose.

The problems with file are:

(a) Requires a lot of further parsing to decode what file means, eg:

$ file /bin/ls 
/bin/ls: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, stripped
==> "x86-64"

(b) Can't look inside anything, specifically initrd files.

I think the serious alternative would be to do all of this logic on
the host side, eg. in Lib.pm or in a 'virt-arch' utility:

http://git.et.redhat.com/?p=libguestfs.git;a=blob;f=TODO;h=291d220ae03fc57cdb05816e1193effec76334ef;hb=HEAD#l185

This would make it easier to extend in future, since writing parsing
code in Perl is infinitely easier than writing it in C.

Rich.

-- 
Richard Jones, Emerging Technologies, Red Hat  http://et.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list