1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

raid: easier prompt message

Use  printf capability of 'prompt()' funtions so use literal
when building this message.
This commit is contained in:
Zdenek Kabelac 2024-05-04 20:30:10 +02:00
parent 91991e3cc1
commit 099a4e2146

View File

@ -6426,22 +6426,13 @@ static int _conversion_options_allowed(const struct lv_segment *seg_from,
!yes && !yes &&
strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */ strcmp((*segtype_to)->name, SEG_TYPE_NAME_MIRROR) && /* "mirror" is prompted for later */
!_is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */ !_is_same_level(seg_from->segtype, *segtype_to)) { /* Prompt here for takeover */
const char *basic_fmt = "Are you sure you want to convert %s LV %s"; unsigned diff_seg = (seg_from->segtype != *segtype_to);
const char *type_fmt = " to %s type";
const char *question_fmt = "? [y/n]: ";
char *fmt;
size_t sz = strlen(basic_fmt) + ((seg_from->segtype == *segtype_to) ? 0 : strlen(type_fmt)) + strlen(question_fmt) + 1;
if (!(fmt = dm_pool_alloc(seg_from->lv->vg->cmd->mem, sz))) if (yes_no_prompt("Are you sure you want to convert %s LV %s%s%s%s? [y/n]: ",
return_0; lvseg_name(seg_from), display_lvname(seg_from->lv),
(diff_seg) ? " to " : "",
if (dm_snprintf(fmt, sz, "%s%s%s", basic_fmt, (seg_from->segtype == *segtype_to) ? "" : type_fmt, question_fmt) < 0) { (diff_seg) ? (*segtype_to)->name : "",
log_error("dm_snprintf failed."); (diff_seg) ? " type" : "") == 'n') {
return 0;
}
if (yes_no_prompt(fmt, lvseg_name(seg_from), display_lvname(seg_from->lv),
(*segtype_to)->name) == 'n') {
log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv)); log_error("Logical volume %s NOT converted.", display_lvname(seg_from->lv));
r = 0; r = 0;
} }