summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Rajnoha <prajnoha@redhat.com>2015-07-21 10:34:04 +0200
committerPeter Rajnoha <prajnoha@redhat.com>2015-07-21 10:34:04 +0200
commit697fb353dc5ecf813199c598eed07983868fdd56 (patch)
tree0817bfe89423f70d57482c5cad941800a661ab86
parent2a7c2539c63f72d6c50df54f53271e567fa948ee (diff)
downloadlvm2-697fb353dc5ecf813199c598eed07983868fdd56.tar.gz
wiping: log_warn instead of log_error if blkid wipe ignored for a signature
Comply with the rules we have for log_error and log_warn... $ pvcreate /dev/sda1 Failed to get offset of the xfs_external_log signature on /dev/sda1. 1 existing signature left on the device. Aborting pvcreate on /dev/sda1. $ pvcreate /dev/sda1 --force WARNING: Failed to get offset of the xfs_external_log signature on /dev/sda1. Physical volume "/dev/sda1" successfully created
-rw-r--r--lib/device/dev-type.c41
1 files changed, 31 insertions, 10 deletions
diff --git a/lib/device/dev-type.c b/lib/device/dev-type.c
index f9d82b0e3..873e02ebc 100644
--- a/lib/device/dev-type.c
+++ b/lib/device/dev-type.c
@@ -528,12 +528,13 @@ static inline int _type_in_flag_list(const char *type, uint32_t flag_list)
((flag_list & TYPE_DM_SNAPSHOT_COW) && !strcmp(type, "DM_snapshot_cow")));
}
+#define MSG_FAILED_SIG_OFFSET "Failed to get offset of the %s signature on %s."
+#define MSG_FAILED_SIG_LENGTH "Failed to get length of the %s signature on %s."
+
static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
uint32_t types_to_exclude, uint32_t types_no_prompt,
int yes, force_t force)
{
- static const char _msg_failed_offset[] = "Failed to get offset of the %s signature on %s.";
- static const char _msg_failed_length[] = "Failed to get length of the %s signature on %s.";
static const char _msg_wiping[] = "Wiping %s signature on %s.";
const char *offset = NULL, *type = NULL, *magic = NULL,
*usage = NULL, *label = NULL, *uuid = NULL;
@@ -544,21 +545,41 @@ static int _blkid_wipe(blkid_probe probe, struct device *dev, const char *name,
if (_type_in_flag_list(type, types_to_exclude))
return 2;
if (blkid_probe_lookup_value(probe, "SBMAGIC_OFFSET", &offset, NULL)) {
- log_error(_msg_failed_offset, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_OFFSET, type, name);
+ return 0;
+ } else {
+ log_error("WARNING: " MSG_FAILED_SIG_OFFSET, type, name);
+ return 2;
+ }
}
if (blkid_probe_lookup_value(probe, "SBMAGIC", &magic, &len)) {
- log_error(_msg_failed_length, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_LENGTH, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH, type, name);
+ return 2;
+ }
}
} else if (!blkid_probe_lookup_value(probe, "PTTYPE", &type, NULL)) {
if (blkid_probe_lookup_value(probe, "PTMAGIC_OFFSET", &offset, NULL)) {
- log_error(_msg_failed_offset, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_OFFSET, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_OFFSET, type, name);
+ return 2;
+ }
}
if (blkid_probe_lookup_value(probe, "PTMAGIC", &magic, &len)) {
- log_error(_msg_failed_length, type, name);
- return (force < DONT_PROMPT) ? 0 : 2;
+ if (force < DONT_PROMPT) {
+ log_error(MSG_FAILED_SIG_LENGTH, type, name);
+ return 0;
+ } else {
+ log_warn("WARNING: " MSG_FAILED_SIG_LENGTH, type, name);
+ return 2;
+ }
}
usage = "partition table";
} else