Module Name:    src
Committed By:   jnemeth
Date:           Fri Dec  6 02:31:31 UTC 2013

Modified Files:
        src/sbin/gpt: add.c gpt.8 resize.c

Log Message:
Don't attempt to create/resize an unaligned partition if the attempt
to create/resize an aligned one failed.  This simplifies the code
and prevents surprises.  If the user wants an unaligned partition
in the case where an aligned one fails, they can simply retry the
command without the "-a" option.  This change was requested by
wiz@, and after some thought I agree with it.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/add.c src/sbin/gpt/gpt.8
cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/resize.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.21 src/sbin/gpt/add.c:1.22
--- src/sbin/gpt/add.c:1.21	Thu Nov 28 01:37:14 2013
+++ src/sbin/gpt/add.c	Fri Dec  6 02:31:31 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.21 2013/11/28 01:37:14 jnemeth Exp $");
+__RCSID("$NetBSD: add.c,v 1.22 2013/12/06 02:31:31 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -136,17 +136,15 @@ add(int fd)
 		alignsecs = alignment / secsz;
 		map = map_alloc(block, size, alignsecs);
 		if (map == NULL) {
-			warnx("%s: error: not enough space available on device for an aligned partition", device_name);
-			map = map_alloc(block, size, 0);
-			if (map == NULL) {
-				warnx("%s: error: not enough available on device", device_name);
-				return;
-			}
+			warnx("%s: error: not enough space available on "
+			      "device for an aligned partition", device_name);
+			return;
 		}
 	} else {
 		map = map_alloc(block, size, 0);
 		if (map == NULL) {
-			warnx("%s: error: not enough space available on device", device_name);
+			warnx("%s: error: not enough space available on "
+			      "device", device_name);
 			return;
 		}
 	}
Index: src/sbin/gpt/gpt.8
diff -u src/sbin/gpt/gpt.8:1.21 src/sbin/gpt/gpt.8:1.22
--- src/sbin/gpt/gpt.8:1.21	Sat Nov 30 19:43:53 2013
+++ src/sbin/gpt/gpt.8	Fri Dec  6 02:31:31 2013
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.21 2013/11/30 19:43:53 jnemeth Exp $
+.\" $NetBSD: gpt.8,v 1.22 2013/12/06 02:31:31 jnemeth Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -26,7 +26,7 @@
 .\"
 .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $
 .\"
-.Dd November 30, 2013
+.Dd December 5, 2013
 .Dt GPT 8
 .Os
 .Sh NAME
@@ -110,7 +110,6 @@ option allows the user to specify an ali
 The alignment may have a suffix to indicate its magnitude.
 .Nm
 will attempt to align the partition.
-If it can not, then it will attempt to create an unaligned partition.
 .Pp
 The
 .Fl b Ar blocknr

Index: src/sbin/gpt/resize.c
diff -u src/sbin/gpt/resize.c:1.5 src/sbin/gpt/resize.c:1.6
--- src/sbin/gpt/resize.c:1.5	Thu Nov 28 01:37:14 2013
+++ src/sbin/gpt/resize.c	Fri Dec  6 02:31:31 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: resize.c,v 1.5 2013/11/28 01:37:14 jnemeth Exp $");
+__RCSID("$NetBSD: resize.c,v 1.6 2013/12/06 02:31:31 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -134,12 +134,11 @@ resize(int fd)
 		}
 
 	newsize = map_resize(map, size, alignsecs);
-	if (newsize == 0 && alignment > 0 && size > 0) {
+	if (newsize == 0 && alignment > 0) {
 		warnx("%s: could not resize partition with alignment "
 		      "constraint", device_name);
-		newsize = map_resize(map, size, 0);
-	}
-	if (newsize == 0) {
+		return;
+	} else if (newsize == 0) {
 		warnx("%s: could not resize partition", device_name);
 		return;
 	}

Reply via email to