Always use the --target flag with findmnt

Prevents problems with bogusly named filesystems, e.g.:

 mount -t tmpfs / /mount/point

Fixes FS#39090.
This commit is contained in:
Dave Reisner 2014-03-01 16:38:21 -05:00
parent ed65f93eb4
commit 869c314159
2 changed files with 4 additions and 4 deletions

View File

@ -4,12 +4,12 @@ run_latehook() {
local usr_source mountopts passno realtab=/new_root/etc/fstab
if [ -f "$realtab" ]; then
if usr_source=$(findmnt -snero source --tab-file="$realtab" /usr); then
mountopts=$(findmnt -snero options --tab-file="$realtab" /usr)
if usr_source=$(findmnt -snero source --tab-file="$realtab" -T /usr); then
mountopts=$(findmnt -snero options --tab-file="$realtab" -T /usr)
# returning the passno column requires util-linux >= 2.23. for
# older versions which do not support this column, always fsck.
passno=$(findmnt -snero passno --tab-file="$realtab" /usr 2>/dev/null)
passno=$(findmnt -snero passno --tab-file="$realtab" -T /usr 2>/dev/null)
if [ -z "$passno" ] || [ "$passno" -gt 0 ]; then
fsck_device "$usr_source"
fi

View File

@ -30,7 +30,7 @@ build() {
done
# detect filesystem for root
if rootfstype=$(findmnt -uno fstype '/'); then
if rootfstype=$(findmnt -uno fstype -T '/'); then
add_if_avail "$rootfstype"
else
error "failed to detect root filesystem"