Bernard,
May I suggest a test for the file type, instead of a test for the file
name? There is no requirement that a useable kernel file start with
"vmlinuz".
[EMAIL PROTECTED]/boot% file vmlinu[xz]-2.4.21-27.0.4.EL
vmlinux-2.4.21-27.0.4.EL: ELF 32-bit LSB executable, Intel 80386, version 1
(SYSV), statically linked, stripped
vmlinuz-2.4.21-27.0.4.EL: x86 boot sector
May I suggest the creation of a new function called, "is_kernel", and do
any relevant kernel validation tests in there. We can then call it from
inside the "foreach (@files) {" loop below.
See the attached test script for an example function.
Cheers, -Brian
Thus spake Bernard Li ([EMAIL PROTECTED]):
Author: bli
Date: 2006-01-08 04:44:52 -0600 (Sun, 08 Jan 2006)
New Revision: 3395
Modified:
branches/3.6.x/lib/SystemImager/UseYourOwnKernel.pm
Log:
Make sure that the kernel file starts with "vmlinuz". On RHEL3u5, /boot has
two similiarly named files which fit the original criteria:
/boot/vmlinux-2.4.21-32.EL
/boot/vmlinuz-2.4.21-32.EL
Modified: branches/3.6.x/lib/SystemImager/UseYourOwnKernel.pm
===================================================================
--- branches/3.6.x/lib/SystemImager/UseYourOwnKernel.pm 2006-01-07 05:07:02 UTC
(rev 3394)
+++ branches/3.6.x/lib/SystemImager/UseYourOwnKernel.pm 2006-01-08 10:44:52 UTC
(rev 3395)
@@ -184,18 +184,18 @@
foreach my $dir (@dirs) {
#
- # Check each binary to see if it contains the uname string
+ # Check each binary to see if it contains vmlinuz and the
uname string
#
opendir(DIR, $dir) || die("Can't opendir $dir: $!");
my @files = readdir(DIR);
closedir DIR;
foreach (@files) {
-
- my $file = "$dir/$_";
+ my $kernel = $_;
+ my $file = "$dir/$kernel";
next unless( (-B $file) and (! -d $file) );
my $kernel_release = _get_kernel_release($file);
- return $file if( defined($kernel_release) and
($kernel_release eq $uname_r) );
+ return $file if( defined($kernel_release) and
($kernel_release eq $uname_r) and ($kernel =~ /^vmlinuz/) );
}
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
systemimager-commits mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/systemimager-commits
--
Brian Elliott Finley
Mobile: 630.631.6621
#!/usr/bin/perl -w
use strict;
my $file = "/boot/vmlinuz-2.6.12-10-686";
#my $file = "/tmp/vmlinux-2.4.21-15.0.4.EL";
if( is_kernel($file) ) {
print "$file is a kernel, or close enough.\n";
exit 0;
} else {
print "$file ain't no kernel\n";
exit 1;
}
sub is_kernel {
my $file = shift;
if( ! -B $file ) { return undef; }
if( -d $file ) { return undef; }
my $cmd = "file -b $file";
open(INPUT,"$cmd|") or die("Couldn't run $cmd to get INPUT");
my ($input) = (<INPUT>);
unless( $input =~ m/boot sector/ ) { return undef; }
close(INPUT);
#
# If we've made it down to here, then we consider it a kernel. -BEF-
return 1;
}