From 4a9f15db997ad0bd274676922bf92a6fa2a3e9f4 Mon Sep 17 00:00:00 2001 From: Thierry Vignaud Date: Fri, 7 Dec 2012 07:04:39 +0000 Subject: document that typeFromMagic() accepts function refs --- lib/MDK/Common/System.pm | 9 +++++++++ 1 file changed, 9 insertions(+) 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, ... ]. -- cgit v1.2.1