diff options
author | Pascal Rigaux <pixel@mandriva.com> | 2006-01-12 10:19:40 +0000 |
---|---|---|
committer | Pascal Rigaux <pixel@mandriva.com> | 2006-01-12 10:19:40 +0000 |
commit | 597e9ea6f8fe597bd7c0600b17534f9c428dc8eb (patch) | |
tree | 6d4beb0b3e545de162a58b4d58a946a98fe9bf8c | |
parent | e1707b82b47a732ce2928da268b6db83fdad984e (diff) | |
download | drakx-597e9ea6f8fe597bd7c0600b17534f9c428dc8eb.tar drakx-597e9ea6f8fe597bd7c0600b17534f9c428dc8eb.tar.gz drakx-597e9ea6f8fe597bd7c0600b17534f9c428dc8eb.tar.bz2 drakx-597e9ea6f8fe597bd7c0600b17534f9c428dc8eb.tar.xz drakx-597e9ea6f8fe597bd7c0600b17534f9c428dc8eb.zip |
use BLKGETSIZE64 to allow detecting partitions bigger than 2TB, and use
"double" instead of "unsigned int" (nb: it means we will use doubles instead
of ints for computing things, this works quite nicely up to 100_000TB
doing this in perl so that there is no need to recompile stuff.so
-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; |