From ef89802e833acadf7ba37448ef1a64b7e0a76bf8 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 31 Mar 2020 12:26:54 +0200 Subject: [PATCH] fstrim: rename --quite to --quite-unsupported We use --verbose together with --quite in service files. It seems confusing, let's make the option more descriptive. Addresses: https://github.com/karelzak/util-linux/issues/1001 Signed-off-by: Karel Zak --- bash-completion/fstrim | 2 +- sys-utils/fstrim.8 | 7 ++++--- sys-utils/fstrim.c | 30 +++++++++++++++--------------- sys-utils/fstrim.service.in | 2 +- 4 files changed, 21 insertions(+), 20 deletions(-) diff --git a/bash-completion/fstrim b/bash-completion/fstrim index 14ebf1429b..075c0817c6 100644 --- a/bash-completion/fstrim +++ b/bash-completion/fstrim @@ -17,7 +17,7 @@ _fstrim_module() -*) OPTS="--all --fstab - --quiet + --quiet-unsupported --offset --length --minimum diff --git a/sys-utils/fstrim.8 b/sys-utils/fstrim.8 index a7adc6a03e..ef6772a962 100644 --- a/sys-utils/fstrim.8 +++ b/sys-utils/fstrim.8 @@ -99,9 +99,10 @@ LVM setup, etc. These reductions would not be reflected in fstrim_range.len .B \-\-length option). .TP -.B \-\-quiet -Suppress trim operation (ioctl) error messages. This option is meant to be used in systemd service -file or in cron scripts to hide warnings that are result of known problems, +.B \-\-quiet\-unsupported +Suppress error messages if trim operation (ioctl) is unsupported. This option +is meant to be used in systemd service file or in cron scripts to hide warnings +that are result of known problems, such as NTFS driver reporting .I Bad file descriptor diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c index 6c84432426..de1ef52e87 100644 --- a/sys-utils/fstrim.c +++ b/sys-utils/fstrim.c @@ -60,7 +60,7 @@ struct fstrim_control { struct fstrim_range range; unsigned int verbose : 1, - quiet : 1, + quiet_unsupp : 1, fstab : 1, dryrun : 1; }; @@ -357,7 +357,7 @@ static int fstrim_all(struct fstrim_control *ctl) rc = fstrim_filesystem(ctl, tgt, src); if (rc < 0) cnt_err++; - else if (rc == 1 && !ctl->quiet) + else if (rc == 1 && !ctl->quiet_unsupp) warnx(_("%s: the discard operation is not supported"), tgt); } mnt_free_iter(itr); @@ -385,14 +385,14 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_("Discard unused blocks on a mounted filesystem.\n"), out); fputs(USAGE_OPTIONS, out); - fputs(_(" -a, --all trim all supported mounted filesystems\n"), out); - fputs(_(" -A, --fstab trim all supported mounted filesystems from /etc/fstab\n"), out); - fputs(_(" -o, --offset the offset in bytes to start discarding from\n"), out); - fputs(_(" -l, --length the number of bytes to discard\n"), out); - fputs(_(" -m, --minimum the minimum extent length to discard\n"), out); - fputs(_(" -v, --verbose print number of discarded bytes\n"), out); - fputs(_(" --quiet suppress trim error messages\n"), out); - fputs(_(" -n, --dry-run does everything, but trim\n"), out); + fputs(_(" -a, --all trim all supported mounted filesystems\n"), out); + fputs(_(" -A, --fstab trim all supported mounted filesystems from /etc/fstab\n"), out); + fputs(_(" -o, --offset the offset in bytes to start discarding from\n"), out); + fputs(_(" -l, --length the number of bytes to discard\n"), out); + fputs(_(" -m, --minimum the minimum extent length to discard\n"), out); + fputs(_(" -v, --verbose print number of discarded bytes\n"), out); + fputs(_(" --quiet-unsupported suppress error messages if trim unsupported\n"), out); + fputs(_(" -n, --dry-run does everything, but trim\n"), out); fputs(USAGE_SEPARATOR, out); printf(USAGE_HELP_OPTIONS(21)); @@ -412,7 +412,7 @@ int main(int argc, char **argv) .range = { .len = ULLONG_MAX } }; enum { - OPT_QUIET = CHAR_MAX + 1 + OPT_QUIET_UNSUPP = CHAR_MAX + 1 }; static const struct option longopts[] = { @@ -424,7 +424,7 @@ int main(int argc, char **argv) { "length", required_argument, NULL, 'l' }, { "minimum", required_argument, NULL, 'm' }, { "verbose", no_argument, NULL, 'v' }, - { "quiet", no_argument, NULL, OPT_QUIET }, + { "quiet-unsupported", no_argument, NULL, OPT_QUIET_UNSUPP }, { "dry-run", no_argument, NULL, 'n' }, { NULL, 0, NULL, 0 } }; @@ -460,8 +460,8 @@ int main(int argc, char **argv) case 'v': ctl.verbose = 1; break; - case OPT_QUIET: - ctl.quiet = 1; + case OPT_QUIET_UNSUPP: + ctl.quiet_unsupp = 1; break; case 'h': usage(); @@ -490,7 +490,7 @@ int main(int argc, char **argv) return EXIT_FAILURE; rc = fstrim_filesystem(&ctl, path, NULL); - if (rc == 1 && !ctl.quiet) + if (rc == 1 && !ctl.quiet_unsupp) warnx(_("%s: the discard operation is not supported"), path); return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE; diff --git a/sys-utils/fstrim.service.in b/sys-utils/fstrim.service.in index b58728ef4c..bf8d3645e4 100644 --- a/sys-utils/fstrim.service.in +++ b/sys-utils/fstrim.service.in @@ -5,7 +5,7 @@ ConditionVirtualization=!container [Service] Type=oneshot -ExecStart=@sbindir@/fstrim --fstab --verbose --quiet +ExecStart=@sbindir@/fstrim --fstab --verbose --quiet-unsupported PrivateDevices=no PrivateNetwork=yes PrivateUsers=no -- 2.39.5