From f564981d2e5f4d5daad5a6f704dfa22ffaa9cf94 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Sat, 2 Feb 2008 20:57:01 +0100 Subject: [PATCH] mkpart: Don't require a DVH partition name if it's guaranteed to fail. 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): --- parted/parted.c | 21 ++++++++++++++++----- 1 files changed, 16 insertions(+), 5 deletions(-) Index: parted-1.8.8/parted/parted.c =================================================================== --- parted-1.8.8.orig/parted/parted.c +++ parted-1.8.8/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 @@ -708,11 +707,21 @@ do_mkpart (PedDevice** dev) goto error_destroy_disk; } + /* 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); + peek_word = command_line_peek_word (); if (part_type == PED_PARTITION_EXTENDED || (peek_word && isdigit (peek_word[0]))) {