2 # Copyright 2000, International Business Machines Corporation and others.
5 # This software has been released under the terms of the IBM Public
6 # License. For details, see the LICENSE file in the top-level source
7 # directory or online at http://www.openafs.org/dl/license10.html
11 ##################################################################
14 # bcheckrc (afs) - /sbin/fs/afs/bcheckrc
17 # This file contains scripts/commands necessary to checks
18 # the afs file systems before mounting.
20 # It should be invoked by the generic bcheckrc script only.
28 # Side effects of this test:
31 # Supporting files and Relationship:
32 # i) various "/sbin/fs/afs" commands are used by this script.
33 # ii) generic bcheckrc scrtipt located in the /sbin
34 # directory invokes this script.
37 ##################################################################
40 # Description - This function will check (fsck) all the afs file systems
41 # in the static file system table, /etc/fstab.
43 # Result values - status = 0 for success
44 # status = non-0 for failure
46 # Used (exclusively) by - /sbin/bcheckrc's fsck_afs portion
51 # ROOTSHELL - is the command that gives the user a shell in which
52 # to run fsck interactively. Someday fsck -y should
53 # be fixed to give the right answers to the questions,
54 # rather than always "yes", so this error-prone
55 # interactive fixing business can go away entirely.
60 # set stty (for manual mode)
62 /sbin/stty clocal icanon echo opost onlcr ixon icrnl ignpar erase "^h"
65 # In the remaining part of the function is devoted to the actual
66 # cleaning of the afs file systems.
68 # 1) run fsck -m and determine if any afs file systems
71 # 2) check exit status of fsck -m -
73 # 0 - indicates (and lists) that this afs file
74 # system was verified clean. Continues to
77 # * - indicates and lists the file systems that
78 # were not properly shutdown. File systems
79 # that are corrupt should be fixed before
80 # continuing with the boot.
83 # 3) exit the function with the appropriate return status.
86 # When the file systems are corrupt the following steps are
89 # 1) fsck_afs(1M) command is invoked using the
90 # following command line - "/sbin/fsck -F afs -P -f"
91 # (refer to the fsck_afs(1M) man page)
93 # 2) The following actions are taken according to
94 # the appropriate return values ...
95 # 0 - the corrupt file system was fixed.
96 # Continue with boot'ing.
97 # * - could not automatically fix the
98 # corrupt file system, going into
99 # manual mode (shell).
103 afs_partitions_clean()
105 serverPartition=0 # number of AFS server partitions
107 for name in `/sbin/awk ' $0 ~ /^[ \t]*#/ { next }
108 $3 == "afs" { print $1 }' /etc/fstab`
110 /sbin/fs/hfs/fsck -m $name # check sanity
113 echo Cleaning AFS server partition $name
114 /sbin/fs/afs/fsck -P -f $name
118 echo AFS server partition $name is fixed
122 echo "UNEXPECTED ERROR DURING fsck -P, RUN fsck INTERACT
124 echo "LOGGING IN AS root FOR MANUAL fsck, ENTER ^D WHEN
126 PS1="(in bcheckrc)# "
129 echo "CONTINUING bcheckrc"
138 if [ serverPartition -ne 1 ]
140 echo "NO AFS server partitions found"
148 #*********************************************************************
149 # End of bcheckrc (afs)
150 #*********************************************************************