summaryrefslogtreecommitdiffstats
path: root/sys-utils
diff options
context:
space:
mode:
authorKarel Zak2019-05-09 13:59:54 +0200
committerKarel Zak2019-05-09 13:59:54 +0200
commit5fcdf204b033297486e221a80a7f3c0a30734ceb (patch)
tree13a0ccd16f41e52b3b5a16054bb13b703e72ccf1 /sys-utils
parentbash-completion: add fstrim --quiet (diff)
downloadkernel-qcow2-util-linux-5fcdf204b033297486e221a80a7f3c0a30734ceb.tar.gz
kernel-qcow2-util-linux-5fcdf204b033297486e221a80a7f3c0a30734ceb.tar.xz
kernel-qcow2-util-linux-5fcdf204b033297486e221a80a7f3c0a30734ceb.zip
fstrim: affect only warnings by --quiet
We need the same return code from fstrim_filesystem() independently on --quiet command line option. Addresses: https://github.com/karelzak/util-linux/pull/791 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils')
-rw-r--r--sys-utils/fstrim.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/sys-utils/fstrim.c b/sys-utils/fstrim.c
index 9491079c3..cae38cdff 100644
--- a/sys-utils/fstrim.c
+++ b/sys-utils/fstrim.c
@@ -113,10 +113,8 @@ static int fstrim_filesystem(struct fstrim_control *ctl, const char *path, const
case EBADF:
case ENOTTY:
case EOPNOTSUPP:
- if (ctl->quiet) {
- rc = 1;
- break;
- }
+ rc = 1;
+ break;
default:
rc = -errno;
}
@@ -325,8 +323,11 @@ static int fstrim_all(struct fstrim_control *ctl)
* This is reason why we ignore EOPNOTSUPP and ENOTTY errors
* from discard ioctl.
*/
- if (fstrim_filesystem(ctl, tgt, src) < 0)
+ rc = fstrim_filesystem(ctl, tgt, src);
+ if (rc < 0)
cnt_err++;
+ else if (rc == 1 && !ctl->quiet)
+ warnx(_("%s: the discard operation is not supported"), tgt);
}
ul_unref_path(wholedisk);
@@ -451,7 +452,7 @@ int main(int argc, char **argv)
return fstrim_all(&ctl); /* MNT_EX_* codes */
rc = fstrim_filesystem(&ctl, path, NULL);
- if (rc == 1)
+ if (rc == 1 && !ctl.quiet)
warnx(_("%s: the discard operation is not supported"), path);
return rc == 0 ? EXIT_SUCCESS : EXIT_FAILURE;