util-linux-ng/util-linux-ng-2.14-fdisk-4k-II.patch
kzak 24912fbd9d - fix #489672 - flock segfaults when file name is not given (upstream)
- fix #476964 - Mount /var/tmp with tmpfs creates denials
- fix #487227 - fdisk 4KiB hw sectors support (upstream)
- fix #477303 - renice doesn't support -n option (upstream)
2009-03-19 10:11:58 +00:00

63 lines
2.1 KiB
Diff

diff -up util-linux-ng-2.14.2/fdisk/fdisk.c.kzak util-linux-ng-2.14.2/fdisk/fdisk.c
--- util-linux-ng-2.14.2/fdisk/fdisk.c.kzak 2009-03-19 09:59:50.000000000 +0100
+++ util-linux-ng-2.14.2/fdisk/fdisk.c 2009-03-19 09:59:50.000000000 +0100
@@ -216,7 +216,7 @@ unsigned int heads,
units_per_sector = 1,
display_in_cyl_units = 1;
-unsigned long long total_number_of_sectors;
+unsigned long long total_number_of_sectors; /* (!) 512-byte sectors */
#define dos_label (!sun_label && !sgi_label && !aix_label && !mac_label && !osf_label)
int sun_label = 0; /* looking at sun disklabel */
@@ -892,7 +892,7 @@ get_partition_table_geometry(void) {
void
get_geometry(int fd, struct geom *g) {
- unsigned long long llsectors, llcyls;
+ unsigned long long llcyls;
get_sectorsize(fd);
sector_factor = sector_size / 512;
@@ -911,10 +911,8 @@ get_geometry(int fd, struct geom *g) {
pt_sectors ? pt_sectors :
kern_sectors ? kern_sectors : 63;
- if (blkdev_get_sectors(fd, &llsectors) == -1)
- llsectors = 0;
-
- total_number_of_sectors = llsectors;
+ if (blkdev_get_sectors(fd, &total_number_of_sectors) == -1)
+ total_number_of_sectors = 0;
sector_offset = 1;
if (dos_compatible_flag)
@@ -1922,7 +1920,8 @@ check(int n, unsigned int h, unsigned in
static void
verify(void) {
int i, j;
- unsigned long total = 1;
+ unsigned long long total = 1;
+ unsigned long long n_sectors = (total_number_of_sectors / sector_factor);
unsigned long long first[partitions], last[partitions];
struct partition *p;
@@ -1985,12 +1984,12 @@ verify(void) {
}
}
- if (total > total_number_of_sectors)
- printf(_("Total allocated sectors %ld greater than the maximum"
- " %lld\n"), total, total_number_of_sectors);
- else if (total < total_number_of_sectors)
- printf(_("%lld unallocated sectors\n"),
- total_number_of_sectors - total);
+ if (total > n_sectors)
+ printf(_("Total allocated sectors %llu greater than the maximum"
+ " %llu\n"), total, n_sectors);
+ else if (total < n_sectors)
+ printf(_("%lld unallocated %d-byte sectors\n"),
+ n_sectors - total, sector_size);
}
static void