diff options
author | Karel Zak | 2006-12-07 00:26:18 +0100 |
---|---|---|
committer | Karel Zak | 2006-12-07 00:26:18 +0100 |
commit | 2cccd0ff2b26c782dbd05d589b7695cab5e17458 (patch) | |
tree | 45ebc5937d2e083c12b58bdeffc1b1a2046c9598 /fdisk/fdisksgilabel.c | |
parent | Imported from util-linux-2.12b tarball. (diff) | |
download | kernel-qcow2-util-linux-2cccd0ff2b26c782dbd05d589b7695cab5e17458.tar.gz kernel-qcow2-util-linux-2cccd0ff2b26c782dbd05d589b7695cab5e17458.tar.xz kernel-qcow2-util-linux-2cccd0ff2b26c782dbd05d589b7695cab5e17458.zip |
Imported from util-linux-2.12d tarball.
Diffstat (limited to 'fdisk/fdisksgilabel.c')
-rw-r--r-- | fdisk/fdisksgilabel.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/fdisk/fdisksgilabel.c b/fdisk/fdisksgilabel.c index ce05418e5..c9ccd3e39 100644 --- a/fdisk/fdisksgilabel.c +++ b/fdisk/fdisksgilabel.c @@ -696,8 +696,8 @@ create_sgilabel(void) int sysid; } old[4]; int i=0; - long longsectors; /* the number of sectors on the device */ - int res; /* the result from the ioctl */ + unsigned long long llsectors; + int res; /* the result from the ioctl */ int sec_fac; /* the sector factor */ sec_fac = sector_size / 512; /* determine the sector factor */ @@ -709,15 +709,18 @@ create_sgilabel(void) other_endian = (BYTE_ORDER == LITTLE_ENDIAN); - res = ioctl(fd, BLKGETSIZE, &longsectors); + res = disksize(fd, &llsectors); if (!ioctl(fd, HDIO_GETGEO, &geometry)) { heads = geometry.heads; sectors = geometry.sectors; if (res == 0) { /* the get device size ioctl was successful */ - cylinders = longsectors / (heads * sectors); - cylinders /= sec_fac; + unsigned long long llcyls; + llcyls = llsectors / (heads * sectors * sec_fac); + cylinders = llcyls; + if (cylinders != llcyls) /* truncated? */ + cylinders = ~0; } else { /* otherwise print error and use truncated version */ cylinders = geometry.cylinders; |