summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh')
-rwxr-xr-xmeta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh211
1 files changed, 211 insertions, 0 deletions
diff --git a/meta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh b/meta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh
new file mode 100755
index 0000000000..9e2d3cfc85
--- /dev/null
+++ b/meta/recipes-core/initscripts/initscripts-1.0/jornada7xx/checkroot.sh
@@ -0,0 +1,211 @@
1#
2# checkroot.sh Check to root filesystem.
3#
4# Version: @(#)checkroot.sh 2.84 25-Jan-2002 miquels@cistron.nl
5#
6
7. /etc/default/rcS
8
9#
10# Set SULOGIN in /etc/default/rcS to yes if you want a sulogin to be spawned
11# from this script *before anything else* with a timeout, like SCO does.
12#
13test "$SULOGIN" = yes && sulogin -t 30 $CONSOLE
14
15#
16# Ensure that bdflush (update) is running before any major I/O is
17# performed (the following fsck is a good example of such activity :).
18#
19test -x /sbin/update && update
20
21#
22# Read /etc/fstab.
23#
24exec 9>&0 </etc/fstab
25rootmode=rw
26rootopts=rw
27test "$ENABLE_ROOTFS_FSCK" = yes && rootcheck="yes" || rootcheck="no"
28swap_on_md=no
29devfs=
30while read fs mnt type opts dump pass junk
31do
32 case "$fs" in
33 ""|\#*)
34 continue;
35 ;;
36 /dev/md*)
37 # Swap on md device.
38 test "$type" = swap && swap_on_md=yes
39 ;;
40 /dev/*)
41 ;;
42 *)
43 # Might be a swapfile.
44 test "$type" = swap && swap_on_md=yes
45 ;;
46 esac
47
48 test "$type" = devfs && devfs="$fs"
49
50 # Currently we do not care about the other entries
51 if test "$mnt" = "/"
52 then
53 #echo "[$fs] [$mnt] [$type] [$opts] [$dump] [$pass] [$junk]"
54
55 rootopts="$opts"
56 roottype="$type"
57
58 #The "spinner" is broken on busybox sh
59 TERM=dumb
60
61 test "$pass" = 0 -o "$pass" = "" && rootcheck=no
62
63 # Enable fsck for ext2 and ext3 rootfs, disable for everything else
64 case "$type" in
65 ext3) rootcheck=yes;;
66 *) rootcheck=no;;
67 esac
68
69 if test "$rootcheck" = yes
70 then
71 if ! test -x "/sbin/fsck.${roottype}"
72 then
73 echo -e "\n * * * WARNING: /sbin/fsck.${roottype} is missing! * * *\n"
74 rootcheck=no
75 fi
76 fi
77
78 case "$opts" in
79 ro|ro,*|*,ro|*,ro,*)
80 rootmode=ro
81 ;;
82 esac
83 fi
84done
85exec 0>&9 9>&-
86
87#
88# Activate the swap device(s) in /etc/fstab. This needs to be done
89# before fsck, since fsck can be quite memory-hungry.
90#
91doswap=no
92test -d /proc/1 || mount -n /proc
93case "`uname -r`" in
94 2.[0123].*)
95 if test $swap_on_md = yes && grep -qs resync /proc/mdstat
96 then
97 test "$VERBOSE" != no && echo "Not activating swap - RAID array resyncing"
98 else
99 doswap=yes
100 fi
101 ;;
102 *)
103 doswap=yes
104 ;;
105esac
106if test $doswap = yes
107then
108 test "$VERBOSE" != no && echo "Activating swap"
109 swapon -a 2> /dev/null
110fi
111
112#
113# Check the root filesystem.
114#
115if test -f /fastboot || test $rootcheck = no
116then
117 test $rootcheck = yes && echo "Fast boot, no filesystem check"
118else
119 #
120 # Ensure that root is quiescent and read-only before fsck'ing.
121 #
122 mount -n -o remount,ro /
123 if test $? = 0
124 then
125 if test -f /forcefsck
126 then
127 force="-f"
128 else
129 force=""
130 fi
131 if test "$FSCKFIX" = yes
132 then
133 fix="-y"
134 else
135 fix="-a"
136 fi
137 spinner="-C"
138 case "$TERM" in
139 dumb|network|unknown|"") spinner="" ;;
140 esac
141 test `uname -m` = s390 && spinner="" # This should go away
142 test "$VERBOSE" != no && echo "Checking root filesystem..."
143 fsck $spinner $force $fix /
144 #
145 # If there was a failure, drop into single-user mode.
146 #
147 # NOTE: "failure" is defined as exiting with a return code of
148 # 2 or larger. A return code of 1 indicates that filesystem
149 # errors were corrected but that the boot may proceed.
150 #
151 if test "$?" -gt 1
152 then
153
154 # Since this script is run very early in the boot-process, it should be safe to assume that the
155 # output is printed to VT1. However, some distributions use a bootsplash to hide the "ugly" boot
156 # messages and having the bootsplash "hang" due to a waiting fsck prompt is less than ideal
157 chvt 1
158
159 # Surprise! Re-directing from a HERE document (as in
160 # "cat << EOF") won't work, because the root is read-only.
161 echo
162 echo "fsck failed. Please repair manually and reboot. Please note"
163 echo "that the root filesystem is currently mounted read-only. To"
164 echo "remount it read-write:"
165 echo
166 echo " # mount -n -o remount,rw /"
167 echo
168 echo "CONTROL-D will exit from this shell and REBOOT the system."
169 echo
170 # Start a single user shell on the console
171 /sbin/sulogin $CONSOLE
172 reboot -f
173 fi
174 else
175 echo "*** ERROR! Cannot fsck root fs because it is not mounted read-only!"
176 echo
177 fi
178fi
179
180#
181# If the root filesystem was not marked as read-only in /etc/fstab,
182# remount the rootfs rw but do not try to change mtab because it
183# is on a ro fs until the remount succeeded. Then clean up old mtabs
184# and finally write the new mtab.
185# This part is only needed if the rootfs was mounted ro.
186#
187if [ $(grep rootfs /proc/mounts | awk '{print $4}') = rw ]; then
188 exit 0
189fi
190
191# Add a second check, which seems to be needed for some kernel versions
192if [ $(grep "/dev/root" /proc/mounts | awk '{print $4}') = rw ]; then
193 exit 0
194fi
195
196
197echo "Remounting root file system..."
198mount -n -o remount,$rootmode /
199if test "$rootmode" = rw
200then
201 if test ! -L /etc/mtab
202 then
203 rm -f /etc/mtab~ /etc/nologin
204 : > /etc/mtab
205 fi
206 mount -f -o remount /
207 mount -f /proc
208 test "$devfs" && grep -q '^devfs /dev' /proc/mounts && mount -f "$devfs"
209fi
210
211: exit 0