diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/MDK/Common/System.pm | 9 |
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, ... ]. |