summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Sandeen2009-02-26 09:53:09 +0100
committerKarel Zak2009-02-26 15:56:41 +0100
commit10e3d0319a009a86a92c26da274e50850da0a9b3 (patch)
treea0af1c9872271ee082415c6cd17f6c757d3b4c95
parentmount: remove useless if-before-free tests (diff)
downloadkernel-qcow2-util-linux-10e3d0319a009a86a92c26da274e50850da0a9b3.tar.gz
kernel-qcow2-util-linux-10e3d0319a009a86a92c26da274e50850da0a9b3.tar.xz
kernel-qcow2-util-linux-10e3d0319a009a86a92c26da274e50850da0a9b3.zip
fdisk: doesn't handle large (4KiB) sectors properly
fdisk (at least with the -u option) does not handle sector sizes other than 512. Address-Red-Hat-Bugzilla: #487227 Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisk/fdisk.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 9504e7ae6..0c8374714 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -212,6 +212,7 @@ unsigned long long sector_offset = 1, extended_offset = 0, sectors;
unsigned int heads,
cylinders,
sector_size = DEFAULT_SECTOR_SIZE,
+ sector_factor = 1,
user_set_sector_size = 0,
units_per_sector = 1,
display_in_cyl_units = 1;
@@ -905,11 +906,10 @@ get_partition_table_geometry(void) {
void
get_geometry(int fd, struct geom *g) {
- int sec_fac;
unsigned long long llsectors, llcyls;
get_sectorsize(fd);
- sec_fac = sector_size / 512;
+ sector_factor = sector_size / 512;
guess_device_type(fd);
heads = cylinders = sectors = 0;
kern_heads = kern_sectors = 0;
@@ -934,7 +934,7 @@ get_geometry(int fd, struct geom *g) {
if (dos_compatible_flag)
sector_offset = sectors;
- llcyls = total_number_of_sectors / (heads * sectors * sec_fac);
+ llcyls = total_number_of_sectors / (heads * sectors * sector_factor);
cylinders = llcyls;
if (cylinders != llcyls) /* truncated? */
cylinders = ~0;
@@ -1640,7 +1640,7 @@ list_disk_geometry(void) {
heads, sectors, cylinders);
if (units_per_sector == 1)
printf(_(", total %llu sectors"),
- total_number_of_sectors / (sector_size/512));
+ total_number_of_sectors / sector_factor);
printf("\n");
printf(_("Units = %s of %d * %d = %d bytes\n"),
str_units(PLURAL),
@@ -2030,7 +2030,7 @@ add_partition(int n, int sys) {
if (display_in_cyl_units || !total_number_of_sectors)
llimit = heads * sectors * cylinders - 1;
else
- llimit = total_number_of_sectors - 1;
+ llimit = (total_number_of_sectors / sector_factor) - 1;
limit = llimit;
if (limit != llimit)
limit = 0x7fffffff;