]> sourceware.org Git - lvm2.git/commitdiff
toollib: do not accept duplicate device name on pvcreate input 1430114117
authorPeter Rajnoha <prajnoha@redhat.com>
Wed, 28 Aug 2024 08:35:18 +0000 (10:35 +0200)
committerPeter Rajnoha <prajnoha@redhat.com>
Wed, 28 Aug 2024 08:35:18 +0000 (10:35 +0200)
WHATS_NEW
test/shell/pvcreate-operation.sh
tools/toollib.c

index 79b8a42f701144e88f63b2cd4ce3c63c9d3b7056..ddab5e0d7c58429efff8a5c66cd8e885e532ff62 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.03.27 - 
 ==================
+  Do not accept duplicate device names for pvcreate.
 
 Version 2.03.26 - 23rd August 2024
 ==================================
index 5cf4fd67543873f3bd95d775a2a18625b33078c0..df46cfc13169109bb448646361f1cb99bc83828e 100644 (file)
@@ -25,6 +25,10 @@ else
 mdatypes='2'
 fi
 
+# pvcreate fails when the same device appears twice on input
+not pvcreate "$dev1" "$dev1" 2>err
+grep "Duplicate device name found on input" err
+
 for mdatype in $mdatypes
 do
 # pvcreate (lvm$mdatype) refuses to overwrite an mounted filesystem (bz168330)
index 5031b2cc242bfad6547a3e66adcd12349d78aaeb..e34f1e21dcbb4b947b3ffe71a528a641e2c03681 100644 (file)
@@ -5614,6 +5614,11 @@ int pvcreate_each_device(struct cmd_context *cmd,
 
                pv_name = pp->pv_names[i];
 
+               if (_pvcreate_list_find_name(&pp->arg_devices, pv_name)) {
+                       log_error("Duplicate device name found on input: %s.", pv_name);
+                       return 0;
+               }
+
                if (!(pd = dm_pool_zalloc(cmd->mem, sizeof(*pd)))) {
                        log_error("alloc failed.");
                        return 0;
This page took 0.042374 seconds and 5 git commands to generate.