summaryrefslogtreecommitdiffstats
path: root/fdisk/sfdisk.c
diff options
context:
space:
mode:
authorGiulio Orsero2011-08-23 12:19:38 +0200
committerKarel Zak2011-08-23 12:19:38 +0200
commitcc393e381def1540db7b1273dde9410bea616b22 (patch)
tree3b27dda2151d92afd29711b346680f5070907b6e /fdisk/sfdisk.c
parentlib: [loopdev.c] correct qsort compare function (diff)
downloadkernel-qcow2-util-linux-cc393e381def1540db7b1273dde9410bea616b22.tar.gz
kernel-qcow2-util-linux-cc393e381def1540db7b1273dde9410bea616b22.tar.xz
kernel-qcow2-util-linux-cc393e381def1540db7b1273dde9410bea616b22.zip
sfdisk: make some tests conditional to !Linux
This patch makes the following tests/actions conditional to "!Linux": - Force cylinders as format instead of MB, even if user asked for MB. This solves a bug where if you use "-L -uM", set 1 as starting MB and the disk is larger than a certain size (about 1GB) the partition would start at sector 1 instead of 1MB due to cyl rounding. - Warn about partitions not starting/ending on cyl boundaries. - Check if CHS is ok. I used the "!Linux" notation since it was already used elsewhere in the code. Signed-off-by: Giulio Orsero <giulioo@pobox.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk/sfdisk.c')
-rw-r--r--fdisk/sfdisk.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c
index 3b861e90a..46245d3f9 100644
--- a/fdisk/sfdisk.c
+++ b/fdisk/sfdisk.c
@@ -1303,7 +1303,7 @@ partitions_ok(struct disk_desc *z) {
* The first partition starts after MBR.
* Logical partitions start slightly after the containing extended partn.
*/
- if (B.cylindersize) {
+ if (B.cylindersize && !Linux) {
for (p = partitions; p < partitions + partno; p++)
if (p->size) {
if (p->start % B.cylindersize != 0
@@ -1313,14 +1313,12 @@ partitions_ok(struct disk_desc *z) {
&& (p->p.start_sect >= B.cylindersize)) {
my_warn(_("Warning: partition %s does not start "
"at a cylinder boundary\n"), PNO(p));
- if (!Linux)
- return 0;
+ return 0;
}
if ((p->start + p->size) % B.cylindersize) {
my_warn(_("Warning: partition %s does not end "
"at a cylinder boundary\n"), PNO(p));
- if (!Linux)
- return 0;
+ return 0;
}
}
}
@@ -1363,7 +1361,7 @@ partitions_ok(struct disk_desc *z) {
b = p->p.begin_chs;
aa = chs_to_longchs(a);
bb = chs_to_longchs(b);
- if (!chs_ok(b, PNO(p), _("start")))
+ if (!Linux && !chs_ok(b, PNO(p), _("start")))
return 0;
if (a.s && !is_equal_chs(a, b))
my_warn(_("partition %s: start: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
@@ -1372,7 +1370,7 @@ partitions_ok(struct disk_desc *z) {
b = p->p.end_chs;
aa = chs_to_longchs(a);
bb = chs_to_longchs(b);
- if (!chs_ok(b, PNO(p), _("end")))
+ if (!Linux && !chs_ok(b, PNO(p), _("end")))
return 0;
if (a.s && !is_equal_chs(a, b))
my_warn(_("partition %s: end: (c,h,s) expected (%ld,%ld,%ld) found (%ld,%ld,%ld)\n"),
@@ -2068,7 +2066,7 @@ read_line(int pno, struct part_desc *ep, char *dev, int interactive,
/* use specified format, but round to cylinders if F_MEGABYTE specified */
format = 0;
- if (B.cylindersize && specified_format == F_MEGABYTE)
+ if (B.cylindersize && specified_format == F_MEGABYTE && !Linux)
format = F_CYLINDER;
orig = (one_only ? &(oldp.partitions[pno]) : 0);