fs-lib/fs-lib.sh: add write_fs_tab()

master
Harald Hoyer 2013-03-06 16:38:59 +01:00
parent 5ac8420abc
commit a1084c02fd
1 changed files with 47 additions and 0 deletions

View File

@ -201,3 +201,50 @@ det_fs() {
fi
echo "$_fs"
}

write_fs_tab() {
local _o
local _rw
local _root
local _rootfstype
local _rootflags
local _fspassno

_fspassno="0"
_root="$1"
_rootfstype="$2"
_rootflags="$3"
[ -z "$_rootfstype" ] && _rootfstype=$(getarg rootfstype=)
[ -z "$_rootflags" ] && _rootflags=$(getarg rootflags=)

[ -z "$_rootfstype" ] && _rootfstype="auto"

if [ -z "$_rootflags" ]; then
_rootflags="ro"
else
_rootflags="ro,$_rootflags"
fi

_rw=0
for _o in $CMDLINE; do
case $_o in
rw)
_rw=1;;
ro)
_rw=0;;
esac
done
if [ "$_rw" = "1" ]; then
_rootflags="$_rootflags,rw"
if ! getargbool 0 rd.skipfsck; then
_fspassno="1"
fi
fi

echo "$_root /sysroot $_rootfstype $_rootflags $_fspassno 0" >> /etc/fstab

if type systemctl >/dev/null 2>/dev/null; then
systemctl daemon-reload
systemctl --no-block start initrd-fs.target
fi
}