[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [Libguestfs] [PATCH] guestfs_file_arch command

On 28/07/09 14:07, Richard W.M. Jones wrote:
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"

I don't disagree that it's a very unpleasant api. However it does encapsulate a level of testing and coverage which we couldn't possibly hope to achieve. I would be inclined to work with it anyway.

It might also be worth raising with upstream that access to the structured data parsed using the magic DB would be desirable. In the mean time, we might have to grep a list of possible strings from source.

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

It will decompress a file before inspecting it. See file -z, or MAGIC_COMPRESS in libmagic. However, it won't allow you to inspect a single file within a cpio archive. In this case I would extract the file manually, then inspect it using libmagic.

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:


I don't have a strong opinion on host vs appliance.

Matthew Booth, RHCA, RHCSS
Red Hat Engineering, Virtualisation Team

M:       +44 (0)7977 267231
GPG ID:  D33C3490
GPG FPR: 3733 612D 2D05 5458 8A8A 1600 3441 EA19 D33C 3490

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]