util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] libfdisk: (sun) move aligning of the first sector before availability check
@ 2017-11-09  3:37 Mikhail Vorobyov
  2017-11-16 13:14 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Mikhail Vorobyov @ 2017-11-09  3:37 UTC (permalink / raw)
  To: util-linux

So it will check a sector which would be actualy used as the first sector
of the partition.
---
 libfdisk/src/sun.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c
index d10fea0d7..7ffd364f4 100644
--- a/libfdisk/src/sun.c
+++ b/libfdisk/src/sun.c
@@ -566,6 +566,19 @@ static int sun_add_partition(
 			if (fdisk_use_cylinders(cxt))
 				first *= fdisk_get_units_per_sector(cxt);
 
+			if (!fdisk_use_cylinders(cxt)) {
+				/* Starting sector has to be properly aligned */
+				int cs = cxt->geom.heads * cxt->geom.sectors;
+				int x = first % cs;
+
+				if (x) {
+					fdisk_info(cxt, _("Aligning the first sector from %u to %u "
+							  "to be on cylinder boundary."),
+							first, first + cs - x);
+					first += cs - x;
+				}
+			}
+
 			/* ewt asks to add: "don't start a partition at cyl 0"
 			   However, edmundo@rano.demon.co.uk writes:
 			   "In addition to having a Sun partition table, to be able to
@@ -593,20 +606,6 @@ static int sun_add_partition(
 		}
 	}
 
-
-	if (!fdisk_use_cylinders(cxt)) {
-		/* Starting sector has to be properly aligned */
-		int cs = cxt->geom.heads * cxt->geom.sectors;
-		int x = first % cs;
-
-		if (x) {
-			fdisk_info(cxt, _("Aligning the first sector from %u to %u "
-					  "to be on cylinder boundary."),
-					first, first + cs - x);
-			first += cs - x;
-		}
-	}
-
 	stop = cxt->geom.cylinders * cxt->geom.heads * cxt->geom.sectors;	/* ancient */
 	stop2 = stop;
 	for (i = 0; i < cxt->label->nparts_max; i++) {
-- 
2.13.6

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

end of thread, other threads:[~2017-11-16 13:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-09  3:37 [PATCH v2 1/2] libfdisk: (sun) move aligning of the first sector before availability check Mikhail Vorobyov
2017-11-16 13:14 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).