]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: make some tests conditional to !Linux
authorGiulio Orsero <giulioo@gmail.com>
Tue, 23 Aug 2011 10:19:38 +0000 (12:19 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 23 Aug 2011 10:19:38 +0000 (12:19 +0200)
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>
fdisk/sfdisk.c

index 3b861e90a3170b019c22bd8b4cba1940c484031d..46245d3f9389e7d7cfdbc5bcaf5e124017c4f293 100644 (file)
@@ -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);