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>
This commit is contained in:
parent
0d71a25998
commit
5fcdf204b0
|
@ -32,6 +32,10 @@ The command unshare(1) now allows set user ID and group ID by new command line
|
||||||
options -S/--setuid and -G/--setgid; and new options -R/--root and -w/--wd
|
options -S/--setuid and -G/--setgid; and new options -R/--root and -w/--wd
|
||||||
allows to set root and working directory (like nsenter(1)).
|
allows to set root and working directory (like nsenter(1)).
|
||||||
|
|
||||||
|
The command fstrim(8) does not suppress some well known trimming warnings by
|
||||||
|
default anymore. It's necessary to explicitly use a new command line option
|
||||||
|
--quiet (recommended for crond or systemd).
|
||||||
|
|
||||||
The command lscpu(1) now prints 'Frequency boost' and 'Vulnerability' fields.
|
The command lscpu(1) now prints 'Frequency boost' and 'Vulnerability' fields.
|
||||||
The caches calculation has been modified to print summary from all system caches
|
The caches calculation has been modified to print summary from all system caches
|
||||||
rather than per code numbers.
|
rather than per code numbers.
|
||||||
|
|
|
@ -113,10 +113,8 @@ static int fstrim_filesystem(struct fstrim_control *ctl, const char *path, const
|
||||||
case EBADF:
|
case EBADF:
|
||||||
case ENOTTY:
|
case ENOTTY:
|
||||||
case EOPNOTSUPP:
|
case EOPNOTSUPP:
|
||||||
if (ctl->quiet) {
|
|
||||||
rc = 1;
|
rc = 1;
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
rc = -errno;
|
rc = -errno;
|
||||||
}
|
}
|
||||||
|
@ -325,8 +323,11 @@ static int fstrim_all(struct fstrim_control *ctl)
|
||||||
* This is reason why we ignore EOPNOTSUPP and ENOTTY errors
|
* This is reason why we ignore EOPNOTSUPP and ENOTTY errors
|
||||||
* from discard ioctl.
|
* from discard ioctl.
|
||||||
*/
|
*/
|
||||||
if (fstrim_filesystem(ctl, tgt, src) < 0)
|
rc = fstrim_filesystem(ctl, tgt, src);
|
||||||
|
if (rc < 0)
|
||||||
cnt_err++;
|
cnt_err++;
|
||||||
|
else if (rc == 1 && !ctl->quiet)
|
||||||
|
warnx(_("%s: the discard operation is not supported"), tgt);
|
||||||
}
|
}
|
||||||
|
|
||||||
ul_unref_path(wholedisk);
|
ul_unref_path(wholedisk);
|
||||||
|
@ -451,7 +452,7 @@ int main(int argc, char **argv)
|
||||||
return fstrim_all(&ctl); /* MNT_EX_* codes */
|
return fstrim_all(&ctl); /* MNT_EX_* codes */
|
||||||
|
|
||||||
rc = fstrim_filesystem(&ctl, path, NULL);
|
rc = fstrim_filesystem(&ctl, path, NULL);
|
||||||
if (rc == 1)
|
if (rc == 1 && !ctl.quiet)
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue