11.1Sjoerg#!/bin/sh 21.1Sjoerg# 31.6Sapb# $NetBSD: fsck_root,v 1.6 2011/09/20 12:13:21 apb Exp $ 41.1Sjoerg# 51.1Sjoerg 61.1Sjoerg# PROVIDE: fsck_root 71.1Sjoerg 81.1Sjoerg$_rc_subr_loaded . /etc/rc.subr 91.1Sjoerg 101.1Sjoergname="fsck_root" 111.1Sjoergstart_cmd="fsck_root_start" 121.1Sjoergstop_cmd=":" 131.2Sapbfstab_file=/etc/fstab 141.1Sjoerg 151.1Sjoergfsck_root_start() 161.1Sjoerg{ 171.1Sjoerg if [ -e /fastboot ]; then 181.1Sjoerg echo "Fast boot: skipping disk checks." 191.1Sjoerg return 201.1Sjoerg fi 211.1Sjoerg trap : 2 # Ignore SIGINT, SIGQUIT, so we 221.1Sjoerg trap : 3 # enter single-user mode on failure. 231.1Sjoerg 241.6Sapb # Do nothing if root file system has fs_passno=0 in /etc/fstab, 251.6Sapb # or if root file system is not mentioned in /etc/fstab, or if 261.6Sapb # root file system seems to be a network mount. 271.6Sapb root_in_fstab=false 281.2Sapb while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno 291.2Sapb do 301.6Sapb # skip comment or blank line 311.6Sapb case "${fs_spec}" in 321.6Sapb \#*|'') continue ;; 331.6Sapb esac 341.6Sapb 351.6Sapb # fs_freq and fs_passno default to 0 if not specified 361.6Sapb : ${fs_freq:=0} ${fs_passno:=0} 371.6Sapb 381.6Sapb case "${fs_file},${fs_passno}" in 391.6Sapb /,0) 401.2Sapb echo "Not checking /: fs_passno = 0 in ${fstab_file}" 411.2Sapb return 421.2Sapb ;; 431.6Sapb /,*) 441.6Sapb root_in_fstab=true 451.6Sapb case "${fs_spec}" in 461.3Schristos *:*) 471.6Sapb echo "Not checking /: network mount" 481.3Schristos return 491.3Schristos ;; 501.3Schristos esac 511.2Sapb ;; 521.2Sapb esac 531.4Smrg done < "${fstab_file}" 541.6Sapb 551.6Sapb if $root_in_fstab; then 561.6Sapb echo "Starting root file system check:" 571.6Sapb fsck $fsck_flags / 581.6Sapb handle_fsck_error "$?" 591.6Sapb return 601.6Sapb else 611.6Sapb echo "Not checking /: not listed in ${fstab_file}" 621.6Sapb fi 631.1Sjoerg} 641.1Sjoerg 651.1Sjoergload_rc_config $name 661.1Sjoergrun_rc_command "$1" 67