Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Don't attempt to create/resize an unaligned partiti...



details:   https://anonhg.NetBSD.org/src/rev/17c93a8535a9
branches:  trunk
changeset: 791843:17c93a8535a9
user:      jnemeth <jnemeth%NetBSD.org@localhost>
date:      Fri Dec 06 02:31:31 2013 +0000

description:
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.

diffstat:

 sbin/gpt/add.c    |  14 ++++++--------
 sbin/gpt/gpt.8    |   5 ++---
 sbin/gpt/resize.c |   9 ++++-----
 3 files changed, 12 insertions(+), 16 deletions(-)

diffs (89 lines):

diff -r dc41f97e3911 -r 17c93a8535a9 sbin/gpt/add.c
--- a/sbin/gpt/add.c    Fri Dec 06 01:33:37 2013 +0000
+++ b/sbin/gpt/add.c    Fri Dec 06 02:31:31 2013 +0000
@@ -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 @@
                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;
                }
        }
diff -r dc41f97e3911 -r 17c93a8535a9 sbin/gpt/gpt.8
--- a/sbin/gpt/gpt.8    Fri Dec 06 01:33:37 2013 +0000
+++ b/sbin/gpt/gpt.8    Fri Dec 06 02:31:31 2013 +0000
@@ -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 @@
 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
diff -r dc41f97e3911 -r 17c93a8535a9 sbin/gpt/resize.c
--- a/sbin/gpt/resize.c Fri Dec 06 01:33:37 2013 +0000
+++ b/sbin/gpt/resize.c Fri Dec 06 02:31:31 2013 +0000
@@ -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 @@
                }
 
        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;
        }



Home | Main Index | Thread Index | Old Index