fsck revision 124616
1284285Sjkim#!/bin/sh 2110010Smarkm# 3110010Smarkm# $NetBSD: fsck,v 1.2 2001/06/18 06:42:35 lukem Exp $ 4142429Snectar# $FreeBSD: head/etc/rc.d/fsck 124616 2004-01-17 10:16:38Z mtm $ 5110010Smarkm# 6110010Smarkm 7110010Smarkm# PROVIDE: fsck 8110010Smarkm# REQUIRE: localswap 9110010Smarkm# KEYWORD: FreeBSD 10110010Smarkm 11110010Smarkm. /etc/rc.subr 12110010Smarkm 13110010Smarkmname="fsck" 14110010Smarkmstart_cmd="fsck_start" 15110010Smarkmstop_cmd=":" 16110010Smarkm 17110010Smarkmstop_boot() 18110010Smarkm{ 19110010Smarkm # Terminate the process (which may include the parent /etc/rc) 20215698Ssimon # if booting directly to multiuser mode. 21215698Ssimon # 22215698Ssimon if [ "$autoboot" = yes ]; then 23215698Ssimon kill -TERM $$ 24215698Ssimon fi 25110010Smarkm exit 1 26110010Smarkm} 27110010Smarkm 28110010Smarkmfsck_start() 29110010Smarkm{ 30110010Smarkm if [ "$autoboot" = no ]; then 31110010Smarkm echo "Fast boot: skipping disk checks." 32110010Smarkm elif [ "$autoboot" = yes ]; then 33110010Smarkm # During fsck ignore SIGQUIT 34110010Smarkm trap : 3 35110010Smarkm 36110010Smarkm echo "Starting file system checks:" 37110010Smarkm case ${OSTYPE} in 38110010Smarkm FreeBSD) 39110010Smarkm if checkyesno background_fsck; then 40110010Smarkm fsck -F -p 41276864Sjkim else 42276864Sjkim fsck -p 43110010Smarkm fi 44110010Smarkm ;; 45215698Ssimon NetBSD) 46215698Ssimon fsck -p 47215698Ssimon ;; 48215698Ssimon esac 49142429Snectar 50215698Ssimon case $? in 51142429Snectar 0) 52142429Snectar ;; 53276864Sjkim 2) 54276864Sjkim stop_boot 55276864Sjkim ;; 56110010Smarkm 4) 57276864Sjkim echo "Rebooting..." 58276864Sjkim reboot 59276864Sjkim echo "Reboot failed; help!" 60276864Sjkim stop_boot 61276864Sjkim ;; 62276864Sjkim 8) 63215698Ssimon case ${OSTYPE} in 64276864Sjkim FreeBSD) 65276864Sjkim if checkyesno fsck_y_enable; then 66276864Sjkim echo "File system preen failed, trying fsck -y." 67276864Sjkim fsck -y 68276864Sjkim case $? in 69215698Ssimon 0) 70276864Sjkim ;; 71110010Smarkm *) 72110010Smarkm echo "Automatic file system check failed; help!" 73110010Smarkm stop_boot 74110010Smarkm ;; 75110010Smarkm esac 76110010Smarkm else 77110010Smarkm echo "Automatic file system check failed; help!" 78110010Smarkm stop_boot 79110010Smarkm fi 80110010Smarkm ;; 81110010Smarkm NetBSD) 82110010Smarkm echo "Automatic file system check failed; help!" 83110010Smarkm stop_boot 84110010Smarkm ;; 85110010Smarkm esac 86110010Smarkm ;; 87110010Smarkm 12) 88110010Smarkm echo "Boot interrupted." 89110010Smarkm stop_boot 90110010Smarkm ;; 91110010Smarkm 130) 92110010Smarkm stop_boot 93110010Smarkm ;; 94110010Smarkm *) 95110010Smarkm echo "Unknown error; help!" 96110010Smarkm stop_boot 97110010Smarkm ;; 98110010Smarkm esac 99110010Smarkm fi 100110010Smarkm} 101110010Smarkm 102110010Smarkmload_rc_config $name 103110010Smarkmrun_rc_command "$1" 104110010Smarkm