common: check is_pseudofs or has_fsck more reliably

There might be filesystems we can't cover in common,
e.g. out-of-tree ones. Use findmnt / check if the
fsck command exists to make it more reliable.
This commit is contained in:
Mike Yuan 2022-12-20 17:02:29 +08:00
parent 092226862b
commit e13ce65908
No known key found for this signature in database
GPG Key ID: 417471C0A40F58B3
2 changed files with 4 additions and 3 deletions

5
common
View File

@ -436,11 +436,12 @@ dm_name_for_devnode() {
}
fstype_is_pseudofs() {
(( pseudofs_types["$1"] ))
(( pseudofs_types["$1"] )) || findmnt --pseudo "$1" &>/dev/null
}
fstype_has_fsck() {
(( fsck_types["$1"] ))
(( fsck_types["$1"] == 0 )) && return 1
(( fsck_types["$1"] )) || command -v "fsck.$1" &>/dev/null
}
# vim: et ts=2 sw=2 ft=sh:

View File

@ -53,7 +53,7 @@ optstring_apply_quirks() {
# Prune 'relatime' option for any pseudofs. This seems to be a rampant
# default which the kernel often exports even if the underlying filesystem
# doesn't support it. Example: https://bugs.archlinux.org/task/54554.
if awk -v fstype="$fstype" '$1 == fstype { exit 1 }' /proc/filesystems; then
if fstype_is_pseudofs "$fstype"; then
optstring_remove_option "$varname" relatime
fi