prdhcp.c32: Print DHCP packets
[profile/ivi/syslinux.git] / mbr / checksize.pl
index a364310..4b42327 100755 (executable)
@@ -1,6 +1,7 @@
 ## -----------------------------------------------------------------------
 ##
 ##   Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
+##   Copyright 2009 Intel Corporation; author: H. Peter Anvin
 ##
 ##   This program is free software; you can redistribute it and/or modify
 ##   it under the terms of the GNU General Public License as published by
@@ -20,6 +21,21 @@ use bytes;
 
 ($file, $maxsize, $padsize) = @ARGV;
 
+if (!defined($maxsize)) {
+    # Defaults based on the filename
+    if ($file =~ /^mbr[^0-9a-z]/) {
+       $maxsize = $padsize = 440;
+    } elsif ($file =~ /^gptmbr[^0-9a-z]/) {
+       $maxsize = $padsize = 440;
+    } elsif ($file =~ /^isohdp[fp]x[^0-9a-z]/) {
+       $maxsize = $padsize = 432;
+    } elsif ($file =~ /^altmbr[^0-9a-z]/) {
+       $maxsize = $padsize = 439;
+    } else {
+       die "$0: no default size for filename: $file\n";
+    }
+}
+
 $padsize = $maxsize unless(defined($padsize));
 
 open(FILE, '+<', $file) or die;