]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: clean return code on --quiet-unsupported
authorKarel Zak <kzak@redhat.com>
Thu, 1 Jul 2021 15:06:34 +0000 (17:06 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 1 Jul 2021 15:23:43 +0000 (17:23 +0200)
This feature is already supported for -a and -A. Let's support it also
when FS specified on command line.

Addresses: https://github.com/systemd/mkosi/pull/721
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fstrim.8.adoc
sys-utils/fstrim.c

index fe1c8d318bfd178d6765d2620dfe989dfcab9abb..66671c2935d915a252e58bdda40cee4e820345b3 100644 (file)
@@ -57,7 +57,7 @@ Verbose execution. With this option *fstrim* will output the number of bytes pas
 *fstrim* will report the same potential discard bytes each time, but only sectors which had been written to between the discards would actually be discarded by the storage device. Further, the kernel block layer reserves the right to adjust the discard ranges to fit raid stripe geometry, non-trim capable devices in a LVM setup, etc. These reductions would not be reflected in fstrim_range.len (the *--length* option).
 
 *--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 _Bad file descriptor_ when device is mounted read-only, or lack of file system support for ioctl FITRIM call.
+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 _Bad file descriptor_ when device is mounted read-only, or lack of file system support for ioctl FITRIM call. This option also cleans exit status when unsupported filesystem specified on fstrim command line.
 
 *-V*, *--version*::
 Display version information and exit.
index 1ca117071a4ff1c7ab8b35dab1b042a549f67d62..d2aec4f715147d46c54970bb86a330686fd57aa1 100644 (file)
@@ -541,7 +541,9 @@ int main(int argc, char **argv)
                return EXIT_FAILURE;
 
        rc = fstrim_filesystem(&ctl, path, NULL);
-       if (rc == 1 && !ctl.quiet_unsupp)
+       if (rc == 1 && ctl.quiet_unsupp)
+               rc = 0;
+       if (rc == 1)
                warnx(_("%s: the discard operation is not supported"), path);
 
        return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;