From 54e91a485a7ed04282e05544844ea36f8b732094 Mon Sep 17 00:00:00 2001 From: "cantab.net!aia21" Date: Sun, 17 Nov 2002 16:12:16 +0000 Subject: [PATCH] Hi, This patch adds the warning Anton requested, -=------------------------=-------------------------------> WARNING: Every sanity checks passed and only the DANGEROUS operations left. Please make sure all your important data had been backed up in case of an unexpected failure! Are you sure you want to proceed (y/[n])? OK quitting. NO CHANGES has been made to your NTFS volume. <----------------------------------------------------------The question will be skipped if the -f (force) used [e.g. for automatic testing]. This patch needs the earlier sent ntfsresize-usage-cleanup.diff patch. Szaka (Logical change 1.11) --- ntfstools/ntfsresize.c | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/ntfstools/ntfsresize.c b/ntfstools/ntfsresize.c index fb20f697..23e74c0b 100644 --- a/ntfstools/ntfsresize.c +++ b/ntfstools/ntfsresize.c @@ -49,6 +49,11 @@ const char *EXEC_NAME = "ntfsresize"; #define NTFS_REPORT_BANNER "\nReport bugs to linux-ntfs-dev@lists.sf.net. " \ "Homepage: http://linux-ntfs.sf.net\n" +#define NTFS_RESIZE_WARNING \ +"WARNING: Every sanity checks passed and only the DANGEROUS \n" \ +"operations left. Please make sure all your important data \n" \ +"had been backed up in case of an unexpected failure!\n" + struct { int verbose; int debug; @@ -132,6 +137,24 @@ void usage() } +/* Copy-paste from e2fsprogs */ +void proceed_question(void) +{ + char buf[256]; + const char *short_yes = "yY"; + + fflush(stdout); + fflush(stderr); + printf("Are you sure you want to proceed (y/[n])? "); + buf[0] = 0; + fgets(buf, sizeof(buf), stdin); + if (strchr(short_yes, buf[0]) == 0) { + printf("OK quitting. NO CHANGES has been made to your NTFS volume.\n"); + exit(1); + } +} + + s64 get_new_volume_size(char *s) { s64 size; @@ -716,7 +739,7 @@ void mount_volume() perr_exit("ntfs_mount failed"); if (vol->flags & VOLUME_IS_DIRTY) - if (!opt.force--) + if (opt.force-- <= 0) err_exit("Volume is dirty. Run chkdsk and " "please try again (or see -f option).\n"); @@ -800,7 +823,10 @@ int main(int argc, char **argv) advise_on_resize(); } - /* FIXME: first do all checks before any write attempt */ + if (opt.force-- <= 0) { + printf(NTFS_RESIZE_WARNING); + proceed_question(); + } prepare_volume_fixup();