diff options
-rw-r--r-- | perl-install/c.pm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/perl-install/c.pm b/perl-install/c.pm index f1904ebc4..80b8b2571 100644 --- a/perl-install/c.pm +++ b/perl-install/c.pm @@ -16,4 +16,24 @@ sub AUTOLOAD() { wantarray() ? @l : $l[0]; } +sub total_sectors { + my ($fd) = @_; + + use log; + log::l("special total_sectors"); + my ($BLKGETSIZE, $BLKGETSIZE64) = (0x1260, 0x80041272); + + open(my $F, "<& $fd") or return; + my $ll = ''; + if (ioctl($F, $BLKGETSIZE64, $ll)) { + my ($v, $v1) = unpack("L2", $ll); + $v1 * 1024 * 1024 * 8 + $v / 512; + } elsif (ioctl($F, $BLKGETSIZE, $ll)) { + log::l("defaulting to BLKGETSIZE"); + unpack("L", $ll); + } else { + 0; + } +}; + 1; |