[PATCH / discussion only] Lib.pm: Add file_architecture command.
(Not to be applied - there is still a bug in the handling of initrd images). This patch does the same as the previous 'file-arch' command, except written in Perl and running on the host. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://et.redhat.com/~rjones/virt-top
On Tue, Jul 28, 2009 at 05:59:14PM +0100, Richard W.M. Jones wrote:
This patch does the same as the previous 'file-arch' command, except written in Perl and running on the host.
Attached is an updated and fixed version of this patch. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html
On 28/07/09 19:03, Richard W.M. Jones wrote:
On Tue, Jul 28, 2009 at 05:59:14PM +0100, Richard W.M. Jones wrote:
This patch does the same as the previous 'file-arch' command, except written in Perl and running on the host.
Attached is an updated and fixed version of this patch.
Looks good. Have you had a chance to test it on RHEL 5? I wouldn't be surprised to discover that the output of file is different. ACK Matt -- 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
On Wed, Jul 29, 2009 at 09:54:51AM +0100, Matthew Booth wrote:
On 28/07/09 19:03, Richard W.M. Jones wrote:
On Tue, Jul 28, 2009 at 05:59:14PM +0100, Richard W.M. Jones wrote:
This patch does the same as the previous 'file-arch' command, except written in Perl and running on the host.
Attached is an updated and fixed version of this patch.
Looks good.
Have you had a chance to test it on RHEL 5? I wouldn't be surprised to discover that the output of file is different.
No - I was planning to do all the RHEL 5 fixes in one block later before 1.0.65 is released. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
Richard W.M. Jones wrote: [Tue Jul 28 2009, 02:03:03PM EDT]
+ foreach my $bin (@_initrd_binaries) { + if (-f "$dir/bin/$bin") { + open PIPE, "file $dir/bin/$bin |"; + local $/ = undef; + $_ = <PIPE>; + if (/ELF.*executable, (.+?),/) { + return _elf_arch_to_canonical ($1); + } + } + }
It might be (ever so) slightly better here to use Perl's backtick operator to slurp the output rather than declaring $/ local prior to calling a function in the same block: foreach my $bin (@_initrd_binaries) { if (-f "$dir/bin/$bin") { $_ = `file $dir/bin/$bin`; if (/ELF.*executable, (.+?),/) { return _elf_arch_to_canonical ($1); } } } Having read through the rest of the code, that's the only thing I could find to comment on... :-) Regards, Aron
On Wed, Jul 29, 2009 at 08:56:19AM -0400, Aron Griffis wrote:
Richard W.M. Jones wrote: [Tue Jul 28 2009, 02:03:03PM EDT]
+ foreach my $bin (@_initrd_binaries) { + if (-f "$dir/bin/$bin") { + open PIPE, "file $dir/bin/$bin |"; + local $/ = undef; + $_ = <PIPE>; + if (/ELF.*executable, (.+?),/) { + return _elf_arch_to_canonical ($1); + } + } + }
It might be (ever so) slightly better here to use Perl's backtick operator to slurp the output rather than declaring $/ local prior to calling a function in the same block:
foreach my $bin (@_initrd_binaries) { if (-f "$dir/bin/$bin") { $_ = `file $dir/bin/$bin`; if (/ELF.*executable, (.+?),/) { return _elf_arch_to_canonical ($1); } } }
Yup, this is better, or even putting local $/ part into its own block: { local $/ = undef; $_ = <PIPE>; } I'll rustle up a fix. Rich. -- Richard Jones, Emerging Technologies, Red Hat http://et.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v
participants (3)
-
Aron Griffis -
Matthew Booth -
Richard W.M. Jones