From 845d92a3070fd017eca7672d5ab6943ff88357e2 Mon Sep 17 00:00:00 2001 From: Kurt J. Bosch Date: Fri, 14 May 2010 12:01:07 +0200 Subject: [PATCH 2/2] Add support for fsck on loop filesystems --- functions | 33 ++++++++++++++++++++++++++++----- rc.shutdown | 12 ++++++++++++ rc.sysinit | 13 ++++++++++--- 3 files changed, 50 insertions(+), 8 deletions(-) diff --git a/functions b/functions index 4847c79..255fe31 100644 --- a/functions +++ b/functions @@ -167,7 +167,7 @@ in_array() { return 1 # Not Found } -# Function for checking filesystems +# Functions for checking filesystems fsck_all() { fsckret=0 if [ -x /sbin/fsck ]; then @@ -187,6 +187,25 @@ fsck_all() { fi } +fsck_loop() { + fsckret=0 + if [ -x /sbin/fsck ]; then + stat_busy "Checking Loop Filesystems" + FSCK_OUT=/dev/stdout + FSCK_ERR=/dev/null + FSCK_FD= + run_hook ${0##*rc.}_prefsckloop + /sbin/fsck -A -T -C$FSCK_FD -a -t $NETFS,opts=loop $FORCEFSCK >$FSCK_OUT 2>$FSCK_ERR + fsckret=$? + if [ ${fsckret} -gt 1 ]; then + stat_fail + else + stat_done + fi + run_hook ${0##*rc.}_postfsckloop + fi +} + # daemons: add_daemon() { @@ -275,10 +294,14 @@ ck_status() { # shutdown_postkillall: after all processes have been killed in rc.shutdown # single_postkillall: after all processes have been killed in rc.single # shutdown_poweroff: directly before powering off in rc.shutdown -# sysinit_prefsck: directly before fsck -A is run in sysinit -# shutdown_prefsck: directly before fsck -A is run in shutdown -# sysinit_postfsck: after fsck -A was run in sysinit -# shutdown_postfsck after fsck -A was run in shutdown +# sysinit_prefsck: directly before fsck -A is run from rc.sysinit +# shutdown_prefsck: directly before fsck -A is run from rc.shutdown +# sysinit_postfsck: after fsck -A was run from rc.sysinit +# shutdown_postfsck after fsck -A was run from rc.shutdown +# sysinit_prefsckloop: directly before fsck -A is run on loop filesystems from rc.sysinit +# shutdown_prefsckloop: directly before fsck -A is run on loop filesystems from rc.shutdown +# sysinit_postfsckloop: after fsck -A was run on loop filesystems from rc.sysinit +# shutdown_postfsckloop: after fsck -A was run on loop filesystems from rc.shutdown # # Make sure to never override the add_hook and run_hook functions via functions.d diff --git a/rc.shutdown b/rc.shutdown index 0460e22..6caec3c 100755 --- a/rc.shutdown +++ b/rc.shutdown @@ -98,6 +98,17 @@ stat_busy "Deactivating Swap" /sbin/swapoff -a stat_done +stat_busy "Unmounting Loop Filesystems" +/bin/umount -a -r -t noramfs,notmpfs,nosysfs,noproc -O no_netdev,loop +stat_done + +fsckret_loop=0 +if [ "$SHUTDOWN_FSCK" = "yes" -o "$SHUTDOWN_FSCK" = "YES" ]; then + FORCEFSCK= + fsck_loop + fsckret_loop=$fsckret +fi + stat_busy "Unmounting Filesystems" /bin/umount -a -r -t noramfs,notmpfs,nosysfs,noproc -O no_netdev stat_done @@ -112,6 +123,7 @@ if [ "$SHUTDOWN_FSCK" = "yes" -o "$SHUTDOWN_FSCK" = "YES" ]; then fsck_all fi +(( fsckret|=fsckret_loop )) if [ ${fsckret} -gt 1 -a ${fsckret} -ne 32 ]; then echo echo "***************** FILESYSTEM CHECK FAILED ****************" diff --git a/rc.sysinit b/rc.sysinit index 1611bb0..e70c369 100755 --- a/rc.sysinit +++ b/rc.sysinit @@ -242,8 +242,8 @@ fsck_reboot() { echo "***************** FILESYSTEM CHECK FAILED ****************" echo "* *" echo "* Please repair manually and reboot. Note that the root *" - echo "* file system is currently mounted read-only. To remount *" - echo "* it read-write type: mount -n -o remount,rw / *" + echo "* file system might be mounted read-only. To remount it *" + echo "* read-write type: mount -n -o remount,rw / *" echo "* When you exit the maintenance shell the system will *" echo "* reboot automatically. *" echo "* *" @@ -274,7 +274,14 @@ if [ -e /proc/mounts ]; then fi run_hook sysinit_premount # now mount all the local filesystems -/bin/mount -a -t $NETFS -O no_netdev +/bin/mount -a -t $NETFS -O no_netdev,noloop +stat_done + +fsck_loop +fsck_reboot + +stat_busy "Mounting Local Loop Filesystems" +/bin/mount -a -t $NETFS -O no_netdev,loop stat_done status "Activating Swap" /sbin/swapon -a -- 1.7.0.3