Util-Linux package development
 help / color / mirror / Atom feed
* [PATCH] sfdisk: make some tests conditional to !Linux
@ 2011-08-18  7:30 Giulio
  2011-08-22  8:32 ` Karel Zak
  2011-08-23 10:21 ` Karel Zak
  0 siblings, 2 replies; 5+ messages in thread
From: Giulio @ 2011-08-18  7:30 UTC (permalink / raw)
  To: util-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.

Sorry, I don't use git, hope this is ok.

Signed-off-by: Giulio Orsero <giulioo@pobox.com>
---
--- a/fdisk/sfdisk.c	2011-08-17 17:17:43.000000000 +0200
+++ b/fdisk/sfdisk.c	2011-08-17 22:48:52.000000000 +0200
@@ -1315,7 +1315,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
@@ -1325,14 +1325,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;
 		}
 	    }
     }
@@ -1378,7 +1376,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 (!chs_ok(b, PNO(p), _("start")) && !Linux)
 		return 0;
 	    if (a.s && !is_equal_chs(a, b))
 		my_warn(_
@@ -1388,7 +1386,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 (!chs_ok(b, PNO(p), _("end")) && !Linux)
 		return 0;
 	    if (a.s && !is_equal_chs(a, b))
 		my_warn(_
@@ -2087,7 +2085,7 @@ read_line(int pno, struct part_desc *ep,
 
     /* 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);

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-23 10:21 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-18  7:30 [PATCH] sfdisk: make some tests conditional to !Linux Giulio
2011-08-22  8:32 ` Karel Zak
2011-08-22 18:45   ` Giulio Orsero
2011-08-22 18:46   ` Giulio Orsero
2011-08-23 10:21 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox