summaryrefslogtreecommitdiff
path: root/scripts/local
blob: 4e01472970f30e60ba96686522b1553e24204355 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Local filesystem mounting			-*- shell-script -*-

# Parameter: Where to mount the filesystem
mountroot ()
{
	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-top"
	run_scripts /scripts/local-top
	[ "$quiet" != "y" ] && log_end_msg

	# If the root device hasn't shown up yet, give it a little while
	# to deal with removable devices
	if [ ! -e "${ROOT}" ]; then
		log_begin_msg "Waiting for root file system..."

		# Default delay is 180s
		if [ -z "${ROOTDELAY}" ]; then
			slumber=180
		else
			slumber=${ROOTDELAY}
		fi
		if [ -x /sbin/usplash_write ]; then
			/sbin/usplash_write "TIMEOUT ${slumber}" || true
		fi

		slumber=$(( ${slumber} * 10 ))
		while [ ${slumber} -gt 0 ] && [ ! -e "${ROOT}" ]; do
			/bin/sleep 0.1
			slumber=$(( ${slumber} - 1 ))
		done

		if [ ${slumber} -gt 0 ]; then
			log_end_msg 0
		else
			log_end_msg 1 || true
		fi
		if [ -x /sbin/usplash_write ]; then
			/sbin/usplash_write "TIMEOUT 15" || true
		fi
	fi

	# We've given up, but we'll let the user fix matters if they can
	while [ ! -e "${ROOT}" ]; do
		echo "ALERT!  ${ROOT} does not exist.  Dropping to a shell!"
		echo "	Check your root= boot argument (cat /proc/cmdline)"
		panic "	Check for missing modules (cat /proc/modules), or device files (ls /dev)"
	done

	# Get the root filesystem type if not set
	if [ -z "${ROOTFSTYPE}" ]; then
		eval $(fstype < ${ROOT})
	else
		FSTYPE=${ROOTFSTYPE}
	fi
	if [ "$FSTYPE" = "unknown" ] && [ -x /lib/udev/vol_id ]; then
		FSTYPE=$(/lib/udev/vol_id -t ${ROOT})
		[ -z "$FSTYPE" ] && FSTYPE="unknown"
	fi

	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-premount"
	run_scripts /scripts/local-premount
	[ "$quiet" != "y" ] && log_end_msg

	if [ ${readonly} = y ]; then
		roflag=-r
	else
		roflag=-w
	fi

	# FIXME This has no error checking
	modprobe ${FSTYPE}

	# FIXME This has no error checking
	# Mount root
	mount ${roflag} -t ${FSTYPE} ${ROOTFLAGS} ${ROOT} ${rootmnt}

	[ "$quiet" != "y" ] && log_begin_msg "Running /scripts/local-bottom"
	run_scripts /scripts/local-bottom
	[ "$quiet" != "y" ] && log_end_msg
}