From 989ede4f93242964a747df0eed5a730b1d983030 Mon Sep 17 00:00:00 2001 From: Piotr Karbowski Date: Tue, 31 Jan 2012 00:17:21 +0100 Subject: [PATCH] Remount already-mounted filesystems into rw unless fstab contain ro flag for the particular mount points. --- init.d/localmount.in | 31 +++++++++++++++++++++++++++++++ 1 files changed, 31 insertions(+), 0 deletions(-) diff --git a/init.d/localmount.in b/init.d/localmount.in index 3fbc071..7a9967a 100644 --- a/init.d/localmount.in +++ b/init.d/localmount.in @@ -24,6 +24,37 @@ start() no_netdev="-O no_netdev" fi ebegin "Mounting local filesystems" + + # Remount already-mounted filesystems into rw unless fstab contain ro flag for the particular mount points. + for mountpoint in $(fstabinfo); do + case "${mountpoint}" in + '/'*) + if mountinfo -q "${mountpoint}" && mountinfo -q -o ro "${mountpoint}"; then + case ",$(fstabinfo -o "${mountpoint}")," in + *,ro,*) + : + ;; + *) + case "$RC_UNAME" in + Linux) + if [ "${mountpoint}" = '/' ]; then + local mountopts='-n' + else + unset mountopts + fi + mount ${mountopts} -o remount,rw "${mountpoint}" + ;; + *BSD|DragonFly) + mount -u -o rw "${mountpoint}" + ;; + esac + ;; + esac + fi + ;; + esac + done; unset mountpoint + mount -at "$types" $no_netdev eend $? "Some local filesystem failed to mount" -- 1.7.8.4