/usr/lib/mknbi/dismbr is in mknbi 1.4.4-10.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | #!/usr/bin/perl -w
#
# Quick and dirty program to decode a partition table in MBR
# GPL, July 2000, Ken Yap
#
sub decodechs ($)
{
my ($chs) = @_;
my ($c, $h, $s);
($h, $s, $c) = unpack('CCC', $chs);
$c += ($s & 0xC0) << 2;
$s &= 0x3F;
return ($c, $h, $s);
}
sub dismbr ($)
{
my ($par) = @_;
my ($flags, $chs1, $type, $chs2, $bootseg, $numsegs);
($flags, $chs1, $type, $chs2, $bootseg, $numsegs) =
unpack('Ca3Ca3VV', $par);
printf "%s type:%02x %d/%d/%d-%d/%d/%d boot:%04x sectors:%04x\n",
($flags & 0x80) ? '*' : ' ', $type,
decodechs($chs1), decodechs($chs2),
$bootseg, $numsegs;
}
if ($#ARGV >= 0) {
open(STDIN, "$ARGV[0]") or die "$ARGV[0]: $!\n";
}
binmode(STDIN);
$nread = read(STDIN, $mbr, 512);
(defined($nread) and $nread == 512) or die "Cannot read 512 bytes of MBR\n";
(undef, $par[0], $par[1], $par[2], $par[3], $sig) =
unpack('a446a16a16a16a16v', $mbr);
$sig == 0xAA55 or die "Input is not a MBR\n";
foreach $i (0..3) {
print "$i: ";
dismbr($par[$i]);
}
|