Listing 2: Calculate cylinders
my $Cylinders;
my $Geometry = `/sbin/sfdisk -g /dev/hda`;
chomp $Geometry;
my ($Junk,$Temp) = split(/\: /,$Geometry,2);
my ($Cyl,$Heads,$Sec) = split(/\, /,$Temp,3);
($Cyl,$Junk) = split(/ /,$Cyl,2);
($Heads,$Junk) = split(/ /,$Heads,2);
($Sec,$Junk) = split(/ /,$Sec,2);
my $Total = $Heads*$Sec*$Cyl;
if (grep($_ < 1, ($Heads,$Sec,$Cyl)))
{
print "ERROR, /dev/hda $Heads,$Sec,$Cyl, no detection of hard drive\n";
print "Using command, /sbin/sfdisk -g /dev/hda";
print "Press enter to quit.\n";
$R = <STDIN>;
exit;
}
my $Cylinders;
if ($Sec > 0) {$Cylinders = $Total/255/$Sec;}
if ($Cylinders =~ /\./)
{($Cylinders,$Junk) = split(/\./,$Cylinders,2);}
|