summaryrefslogtreecommitdiff
path: root/ftl_format.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-05-08 12:27:25 -0400
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>2013-07-01 08:55:55 +0300
commitdbe0fd17f2323f108715db0bd0f734e9563e40d8 (patch)
tree0e2342e773045ee2e7f937c1eec5250dbc0810f1 /ftl_format.c
parent8b4786830174e06bc27810f15c76f72cb3e951d9 (diff)
mtd-utils: new prompt() helper for talking to the user
We've got a few tools that prompt the user for "yes/no" questions. Add a common helper to simplify the various implementations. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Diffstat (limited to 'ftl_format.c')
-rw-r--r--ftl_format.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/ftl_format.c b/ftl_format.c
index 0f69b8f..b58677f 100644
--- a/ftl_format.c
+++ b/ftl_format.c
@@ -51,6 +51,7 @@
#include <mtd/mtd-user.h>
#include <mtd/ftl-user.h>
#include <mtd_swab.h>
+#include "common.h"
/*====================================================================*/
@@ -164,15 +165,9 @@ static int format_partition(int fd, int quiet, int interrogate,
fflush(stdout);
}
- if (interrogate) {
- char str[3];
- printf("This will destroy all data on the target device. "
- "Confirm (y/n): ");
- if (fgets(str, 3, stdin) == NULL)
+ if (interrogate)
+ if (!prompt("This will destroy all data on the target device. Confirm?", false))
return -1;
- if ((strcmp(str, "y\n") != 0) && (strcmp(str, "Y\n") != 0))
- return -1;
- }
/* Create basic block allocation table for control blocks */
nbam = ((mtd.erasesize >> hdr.BlockSize) * sizeof(u_int)