1#!/bin/sh 2# 3# $NetBSD: fsck,v 1.9 2008/03/02 21:31:30 tron Exp $ 4# 5 6# PROVIDE: fsck 7# REQUIRE: localswap 8 9$_rc_subr_loaded . /etc/rc.subr 10 11name="fsck" 12start_cmd="fsck_start" 13stop_cmd=":" 14 15fsck_start() 16{ 17 if [ -e /fastboot ]; then 18 echo "Fast boot: skipping disk checks." 19 return 20 fi 21 trap : 2 # Ignore SIGINT, SIGQUIT, so we 22 trap : 3 # enter single-user mode on failure. 23 24 echo "Starting file system checks:" 25 fsck $fsck_flags 26 local fsck_error="$?" 27 case $fsck_error in 28 0) # OK 29 return 30 ;; 31 2) # Needs re-run, still fs errors 32 echo "file systems still have errors; re-run fsck manually!" 33 ;; 34 4) # Root modified 35 echo "Root filesystem was modified, rebooting ..." 36 reboot 37 echo "Reboot failed; help!" 38 ;; 39 8) # Check failed 40 echo "Automatic file system check failed; help!" 41 ;; 42 12) # Got signal 43 echo "Boot interrupted." 44 ;; 45 *) 46 echo "Unknown error $fsck_error; help!" 47 ;; 48 esac 49 stop_boot 50} 51 52load_rc_config $name 53run_rc_command "$1" 54