summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorThierry Vignaud <tv@mageia.org>2012-12-07 07:04:39 +0000
committerThierry Vignaud <tv@mageia.org>2012-12-07 07:04:39 +0000
commit4a9f15db997ad0bd274676922bf92a6fa2a3e9f4 (patch)
tree1926dc696b8b65f8e6853b1983fce72a85ad271c /lib
parent844d3a1dbf49c9124e020f74b3712f9bd3013aa6 (diff)
downloadperl-MDK-Common-4a9f15db997ad0bd274676922bf92a6fa2a3e9f4.tar
perl-MDK-Common-4a9f15db997ad0bd274676922bf92a6fa2a3e9f4.tar.gz
perl-MDK-Common-4a9f15db997ad0bd274676922bf92a6fa2a3e9f4.tar.bz2
perl-MDK-Common-4a9f15db997ad0bd274676922bf92a6fa2a3e9f4.tar.xz
perl-MDK-Common-4a9f15db997ad0bd274676922bf92a6fa2a3e9f4.zip
document that typeFromMagic() accepts function refs
Diffstat (limited to 'lib')
-rw-r--r--lib/MDK/Common/System.pm9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/MDK/Common/System.pm b/lib/MDK/Common/System.pm
index 4ab336d..2b4b71e 100644
--- a/lib/MDK/Common/System.pm
+++ b/lib/MDK/Common/System.pm
@@ -39,6 +39,15 @@ find the first corresponding magic in FILENAME. eg of LIST:
[ 'empty', 0, "\0\0\0\0" ],
[ 'grub', 0, "\xEBG", 0x17d, "stage1 \0" ],
[ 'lilo', 0x2, "LILO" ],
+ sub { my ($F) = @_;
+ #- standard grub has no good magic (Mageia's grub is patched to have "GRUB" at offset 6)
+ #- so scanning a range of possible places where grub can have its string
+ my ($min, $max, $magic) = (0x176, 0x181, "GRUB \0");
+ my $tmp;
+ sysseek($F, 0, 0) && sysread($F, $tmp, $max + length($magic)) or return;
+ substr($tmp, 0, 2) eq "\xEBH" or return;
+ index($tmp, $magic, $min) >= 0 && "grub";
+ },
where each entry is [ magic_name, offset, string, offset, string, ... ].