summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2021-09-08 16:30:11 -0500
committerDavid Teigland <teigland@redhat.com>2021-09-08 16:30:11 -0500
commitd3d5ec74690fea98cdb0b761870f4baafecf46e8 (patch)
tree41fadddc7beaa5d6ae5b08a0aaa5b84d4b3ede95
parent89595a366554191c3df1a18e1f82b79c450a21ad (diff)
downloadlvm2-dev-dct-pvcreate-f.tar.gz
pvcreate: overwrite partition header with -fdev-dct-pvcreate-f
$ pvcreate /dev/sdc Cannot use /dev/sdc: device is partitioned $ pvcreate -f /dev/sdc Physical volume "/dev/sdc" successfully created.
-rw-r--r--lib/commands/toolcontext.h1
-rw-r--r--lib/filters/filter-partitioned.c3
-rw-r--r--tools/toollib.c10
3 files changed, 14 insertions, 0 deletions
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index 8f11a7714..bab84f1d4 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -197,6 +197,7 @@ struct cmd_context {
unsigned check_devs_used:1; /* check devs used by LVs */
unsigned print_device_id_not_found:1; /* print devices file entries not found */
unsigned ignore_device_name_mismatch:1; /* skip updating devices file names */
+ unsigned filter_partitioned_skip; /* don't use filter-partitioned */
/*
* Devices and filtering.
diff --git a/lib/filters/filter-partitioned.c b/lib/filters/filter-partitioned.c
index 642553ef2..8f468a567 100644
--- a/lib/filters/filter-partitioned.c
+++ b/lib/filters/filter-partitioned.c
@@ -27,6 +27,9 @@ static int _passes_partitioned_filter(struct cmd_context *cmd, struct dev_filter
if (cmd->filter_nodata_only)
return 1;
+ if (cmd->filter_partitioned_skip)
+ return 1;
+
dev->filtered_flags &= ~DEV_FILTERED_PARTITIONED;
ret = dev_is_partitioned(cmd, dev);
diff --git a/tools/toollib.c b/tools/toollib.c
index 9d488c5a7..5f5420825 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -5336,6 +5336,10 @@ int pvcreate_each_device(struct cmd_context *cmd,
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
+ /* pvcreate -f overwrites partitions */
+ if (pp->force && !pp->is_remove)
+ cmd->filter_partitioned_skip = 1;
+
log_debug("Scanning and filtering device args (%u).", dm_list_size(&scan_devs));
label_scan_devs(cmd, cmd->filter, &scan_devs);
@@ -5350,6 +5354,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
}
}
cmd->filter_deviceid_skip = 0;
+ cmd->filter_partitioned_skip = 0;
/*
* Can the command continue if some specified devices were not found?
@@ -5562,6 +5567,9 @@ do_command:
if (cmd->enable_devices_file && !pp->is_remove)
cmd->filter_deviceid_skip = 1;
+ if (pp->force && !pp->is_remove)
+ cmd->filter_partitioned_skip = 1;
+
log_debug("Rescanning and filtering device args with exclusive open");
if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl");
@@ -5575,7 +5583,9 @@ do_command:
dm_list_add(&pp->arg_fail, &pd->list);
}
}
+
cmd->filter_deviceid_skip = 0;
+ cmd->filter_partitioned_skip = 0;
if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
log_debug("No devices to process.");