#!/bin/sh # # $NetBSD: fsck_root,v 1.6 2011/09/20 12:13:21 apb Exp $ # # PROVIDE: fsck_root $_rc_subr_loaded . /etc/rc.subr name="fsck_root" start_cmd="fsck_root_start" stop_cmd=":" fstab_file=/etc/fstab fsck_root_start() { if [ -e /fastboot ]; then echo "Fast boot: skipping disk checks." return fi trap : 2 # Ignore SIGINT, SIGQUIT, so we trap : 3 # enter single-user mode on failure. # Do nothing if root file system has fs_passno=0 in /etc/fstab, # or if root file system is not mentioned in /etc/fstab, or if # root file system seems to be a network mount. root_in_fstab=false while read fs_spec fs_file fs_vfstype fs_mntops fs_freq fs_passno do # skip comment or blank line case "${fs_spec}" in \#*|'') continue ;; esac # fs_freq and fs_passno default to 0 if not specified : ${fs_freq:=0} ${fs_passno:=0} case "${fs_file},${fs_passno}" in /,0) echo "Not checking /: fs_passno = 0 in ${fstab_file}" return ;; /,*) root_in_fstab=true case "${fs_spec}" in *:*) echo "Not checking /: network mount" return ;; esac ;; esac done < "${fstab_file}" if $root_in_fstab; then echo "Starting root file system check:" fsck $fsck_flags / handle_fsck_error "$?" return else echo "Not checking /: not listed in ${fstab_file}" fi } load_rc_config $name run_rc_command "$1" |