summaryrefslogtreecommitdiffstats
path: root/disk-utils/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2014-09-10 12:51:25 +0200
committerKarel Zak2014-10-07 14:55:31 +0200
commit2d12903265367101c51d1b47d98a1457d93cd8ed (patch)
treeeac4b9a52d758fdba187e3f0bff1e536bbc9bf19 /disk-utils/fdisk.c
parentsfdisk: improve UI (diff)
downloadkernel-qcow2-util-linux-2d12903265367101c51d1b47d98a1457d93cd8ed.tar.gz
kernel-qcow2-util-linux-2d12903265367101c51d1b47d98a1457d93cd8ed.tar.xz
kernel-qcow2-util-linux-2d12903265367101c51d1b47d98a1457d93cd8ed.zip
libfdisk: make yes/no dialogs more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fdisk.c')
-rw-r--r--disk-utils/fdisk.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c
index 5fc4a4d81..ab4830302 100644
--- a/disk-utils/fdisk.c
+++ b/disk-utils/fdisk.c
@@ -338,10 +338,18 @@ int ask_callback(struct fdisk_context *cxt, struct fdisk_ask *ask,
break;
case FDISK_ASKTYPE_YESNO:
fputc('\n', stdout);
- fputs(fdisk_ask_get_query(ask), stdout);
- rc = get_user_reply(cxt, _(" [Y]es/[N]o: "), buf, sizeof(buf));
- if (rc == 0)
- fdisk_ask_yesno_set_result(ask, rpmatch(buf));
+ do {
+ int x;
+ fputs(fdisk_ask_get_query(ask), stdout);
+ rc = get_user_reply(cxt, _(" [Y]es/[N]o: "), buf, sizeof(buf));
+ if (rc)
+ break;
+ x = rpmatch(buf);
+ if (x == 1 || x == 0) {
+ fdisk_ask_yesno_set_result(ask, x);
+ break;
+ }
+ } while(1);
DBG(ASK, ul_debug("yes-no ask: reply '%s' [rc=%d]", buf, rc));
break;
case FDISK_ASKTYPE_STRING: