summaryrefslogtreecommitdiff
path: root/parted
diff options
context:
space:
mode:
authorWang Dong <dongdwdw@linux.vnet.ibm.com>2017-03-24 03:11:08 +0100
committerBrian C. Lane <bcl@redhat.com>2017-05-01 15:05:06 -0700
commitd7a2ff17b15842bf9a3de65ca1ba577bdf568e79 (patch)
tree6631826d8447883521cbfbb263bfbcb119c1f96c /parted
parent21131f62c6f508a5d0c080e025cf7db5df43fc7d (diff)
downloadparted-d7a2ff17b15842bf9a3de65ca1ba577bdf568e79.tar.gz
parted: check the name of partition first when to name a partition
The previous function works well for the labels supporting naming partition, but not for these which don't. If the disk label does not support partition naming, two exceptions will be raised. Even after the first error indicates it does not support name, parted yet asks user for name in iteractive mode. First check if the disk label supports partition naming and if it does, it will continue; otherwise, it will stop and raise an exception. Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com> Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Diffstat (limited to 'parted')
-rw-r--r--parted/parted.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/parted/parted.c b/parted/parted.c
index 6722dc9..c471d49 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -871,6 +871,13 @@ do_name (PedDevice** dev, PedDisk** diskp)
if (!*diskp)
goto error;
+ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_NAME)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("%s disk labels do not support partition name."),
+ (*diskp)->type->name);
+ goto error;
+ }
+
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
goto error;