From 4a0892eb269009e1c489c5e4be0cf7381cdc9375 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Pierre=20Andr=C3=A9?= Date: Mon, 23 Jan 2012 18:10:26 +0100 Subject: [PATCH] Implemented a new option -q to avoid updating the progress information (Matthew Boyle) The progress bars complexify the integration of ntfsclone into other tools, the option -q (or --quiet) gets rid of them. --- ntfsprogs/ntfsclone.8.in | 3 +++ ntfsprogs/ntfsclone.c | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ntfsprogs/ntfsclone.8.in b/ntfsprogs/ntfsclone.8.in index 031578fe..b7f44b46 100644 --- a/ntfsprogs/ntfsclone.8.in +++ b/ntfsprogs/ntfsclone.8.in @@ -233,6 +233,9 @@ option. Forces ntfsclone to proceed if the filesystem is marked "dirty" for consistency check. .TP +\fB\-q\fR, \fB\-\-quiet\fR +Do not display any progress-bars during operation. +.TP \fB\-h\fR, \fB\-\-help\fR Show a list of options with a brief description of each one. .SH EXIT CODES diff --git a/ntfsprogs/ntfsclone.c b/ntfsprogs/ntfsclone.c index 2e40f7b6..4ad7ed5d 100644 --- a/ntfsprogs/ntfsclone.c +++ b/ntfsprogs/ntfsclone.c @@ -317,6 +317,7 @@ static void usage(void) " -m, --metadata Clone *only* metadata (for NTFS experts)\n" " --ignore-fs-check Ignore the filesystem check result\n" " -t, --preserve-timestamps Do not clear the timestamps\n" + " -q, --quiet Do not display any progress bars\n" " -f, --force Force to progress (DANGEROUS)\n" " -h, --help Display this help\n" #ifdef DEBUG @@ -332,11 +333,12 @@ static void usage(void) static void parse_options(int argc, char **argv) { - static const char *sopt = "-dfhmo:O:rst"; + static const char *sopt = "-dfhmo:O:qrst"; static const struct option lopt[] = { #ifdef DEBUG { "debug", no_argument, NULL, 'd' }, #endif + { "quiet", no_argument, NULL, 'q' }, { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, { "metadata", no_argument, NULL, 'm' }, @@ -364,6 +366,9 @@ static void parse_options(int argc, char **argv) case 'd': opt.debug++; break; + case 'q': + opt.quiet++; + break; case 'f': opt.force++; break; @@ -499,6 +504,9 @@ static void progress_update(struct progress_bar *p, u64 current) { float percent = p->unit * current; + if (opt.quiet) + return; + if (current != p->stop) { if ((current - p->start) % p->resolution) return;