[PATCH] mkpart: Don't require a DVH partition name if it's guaranteed to fail.

Jim Meyering meyering at redhat.com
Sat Feb 2 19:57:01 UTC 2008


The mkpart command has an undocumented feature whereby it prompts for
(interactive) or requires (-s) a partition name, *regardless* of whether
it already knows the partition type (any thing but 'logical') is
incompatible with a name.

At first I was pissed and simply #if-0'd the offending code.
But in case someone is actually relying on it, I've relented, and
merely remove the prompt/requirement when the partition table type
is "dvh" and the type of the partition in question is not "logical".

* parted/parted.c (do_mkpart):

Signed-off-by: Jim Meyering <meyering at redhat.com>
---
 parted/parted.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/parted/parted.c b/parted/parted.c
index 738151b..f7f6dc3 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -1,7 +1,6 @@
 /*
     parted - a frontend to libparted
-    Copyright (C) 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
-    Free Software Foundation, Inc.
+    Copyright (C) 1999-2003, 2005-2008 Free Software Foundation, Inc.

     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -709,11 +708,23 @@ do_mkpart (PedDevice** dev)
                         goto error_destroy_disk;
         }

+#if 1
+        /* This undocumented _feature_, is next to useless, at least with
+           a dvh partition table, since it makes the "mkpart" command
+           fail unconditionally for a primary partition.  E.g.,
+           mkpart primary any-name xfs 4096s 5000s
+           requires the name, yet always fails, saying that only
+           logical partitions may have names.
+           If you want a name, use parted's separate "name" command.  */
+
         if (ped_disk_type_check_feature (disk->type,
-                                         PED_DISK_TYPE_PARTITION_NAME)) 
+                                         PED_DISK_TYPE_PARTITION_NAME)
+            && ! (strcmp (disk->type->name, "dvh") == 0
+                  && part_type != PED_PARTITION_LOGICAL))
                 part_name = command_line_get_word (_("Partition name?"),
-                                                   "", NULL, 1); 
-                
+                                                   "", NULL, 1);
+#endif
+
         peek_word = command_line_peek_word ();
         if (part_type == PED_PARTITION_EXTENDED
             || (peek_word && isdigit (peek_word[0]))) {
-- 
1.5.4.3.g6752




More information about the parted-devel mailing list