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 <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-03-31 12:26:54 +02:00
parent a971746370
commit ef89802e83
4 changed files with 21 additions and 20 deletions

View File

@ -17,7 +17,7 @@ _fstrim_module()
-*) -*)
OPTS="--all OPTS="--all
--fstab --fstab
--quiet --quiet-unsupported
--offset --offset
--length --length
--minimum --minimum

View File

@ -99,9 +99,10 @@ LVM setup, etc. These reductions would not be reflected in fstrim_range.len
.B \-\-length .B \-\-length
option). option).
.TP .TP
.B \-\-quiet .B \-\-quiet\-unsupported
Suppress trim operation (ioctl) error messages. This option is meant to be used in systemd service Suppress error messages if trim operation (ioctl) is unsupported. This option
file or in cron scripts to hide warnings that are result of known problems, 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 such as NTFS driver
reporting reporting
.I Bad file descriptor .I Bad file descriptor

View File

@ -60,7 +60,7 @@ struct fstrim_control {
struct fstrim_range range; struct fstrim_range range;
unsigned int verbose : 1, unsigned int verbose : 1,
quiet : 1, quiet_unsupp : 1,
fstab : 1, fstab : 1,
dryrun : 1; dryrun : 1;
}; };
@ -357,7 +357,7 @@ static int fstrim_all(struct fstrim_control *ctl)
rc = fstrim_filesystem(ctl, tgt, src); rc = fstrim_filesystem(ctl, tgt, src);
if (rc < 0) if (rc < 0)
cnt_err++; cnt_err++;
else if (rc == 1 && !ctl->quiet) else if (rc == 1 && !ctl->quiet_unsupp)
warnx(_("%s: the discard operation is not supported"), tgt); warnx(_("%s: the discard operation is not supported"), tgt);
} }
mnt_free_iter(itr); 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(_("Discard unused blocks on a mounted filesystem.\n"), out);
fputs(USAGE_OPTIONS, out); fputs(USAGE_OPTIONS, out);
fputs(_(" -a, --all trim all supported mounted filesystems\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(_(" -A, --fstab trim all supported mounted filesystems from /etc/fstab\n"), out);
fputs(_(" -o, --offset <num> the offset in bytes to start discarding from\n"), out); fputs(_(" -o, --offset <num> the offset in bytes to start discarding from\n"), out);
fputs(_(" -l, --length <num> the number of bytes to discard\n"), out); fputs(_(" -l, --length <num> the number of bytes to discard\n"), out);
fputs(_(" -m, --minimum <num> the minimum extent length to discard\n"), out); fputs(_(" -m, --minimum <num> the minimum extent length to discard\n"), out);
fputs(_(" -v, --verbose print number of discarded bytes\n"), out); fputs(_(" -v, --verbose print number of discarded bytes\n"), out);
fputs(_(" --quiet suppress trim error messages\n"), out); fputs(_(" --quiet-unsupported suppress error messages if trim unsupported\n"), out);
fputs(_(" -n, --dry-run does everything, but trim\n"), out); fputs(_(" -n, --dry-run does everything, but trim\n"), out);
fputs(USAGE_SEPARATOR, out); fputs(USAGE_SEPARATOR, out);
printf(USAGE_HELP_OPTIONS(21)); printf(USAGE_HELP_OPTIONS(21));
@ -412,7 +412,7 @@ int main(int argc, char **argv)
.range = { .len = ULLONG_MAX } .range = { .len = ULLONG_MAX }
}; };
enum { enum {
OPT_QUIET = CHAR_MAX + 1 OPT_QUIET_UNSUPP = CHAR_MAX + 1
}; };
static const struct option longopts[] = { static const struct option longopts[] = {
@ -424,7 +424,7 @@ int main(int argc, char **argv)
{ "length", required_argument, NULL, 'l' }, { "length", required_argument, NULL, 'l' },
{ "minimum", required_argument, NULL, 'm' }, { "minimum", required_argument, NULL, 'm' },
{ "verbose", no_argument, NULL, 'v' }, { "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' }, { "dry-run", no_argument, NULL, 'n' },
{ NULL, 0, NULL, 0 } { NULL, 0, NULL, 0 }
}; };
@ -460,8 +460,8 @@ int main(int argc, char **argv)
case 'v': case 'v':
ctl.verbose = 1; ctl.verbose = 1;
break; break;
case OPT_QUIET: case OPT_QUIET_UNSUPP:
ctl.quiet = 1; ctl.quiet_unsupp = 1;
break; break;
case 'h': case 'h':
usage(); usage();
@ -490,7 +490,7 @@ int main(int argc, char **argv)
return EXIT_FAILURE; return EXIT_FAILURE;
rc = fstrim_filesystem(&ctl, path, NULL); 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); warnx(_("%s: the discard operation is not supported"), path);
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE; return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;

View File

@ -5,7 +5,7 @@ ConditionVirtualization=!container
[Service] [Service]
Type=oneshot Type=oneshot
ExecStart=@sbindir@/fstrim --fstab --verbose --quiet ExecStart=@sbindir@/fstrim --fstab --verbose --quiet-unsupported
PrivateDevices=no PrivateDevices=no
PrivateNetwork=yes PrivateNetwork=yes
PrivateUsers=no PrivateUsers=no