2
# Functions used by several mount* scripts in initscripts package
4
# Sourcer must set PATH and include /lib/init in it because
5
# domount() uses the custom readlink program
7
# Sourcer must also source /lib/lsb/init-functions.sh
11
for FILE in $1/* $1/.*
15
"$1/*"|"$1/."|"$1/..") continue ;;
24
which selinuxenabled >/dev/null 2>&1 && selinuxenabled
28
# Called before mtab is writable to mount kernel and device file systems.
29
# $1: file system type
30
# $2: alternative file system type (or empty string if none)
32
# $4: mount device name
33
# $5... : extra mount program options
37
# Figure out filesystem type
42
Linux|GNU) FSTYPE=proc ;;
43
*FreeBSD) FSTYPE=linprocfs ;;
47
then # always accept tmpfs, to mount /lib/init/rw before /proc
50
then # spufs is only relevant on Cell so may be compiled as a kernel module
51
if grep -E -qs "spufs\$" /proc/filesystems || modprobe -q spufs
55
elif grep -E -qs "$1\$" /proc/filesystems
58
elif grep -E -qs "$2\$" /proc/filesystems
67
log_warning_msg "Filesystem types '$1' and '$2' are not supported. Skipping mount."
69
log_warning_msg "Filesystem type '$1' is not supported. Skipping mount."
74
# We give file system type as device name if not specified as
82
# Get the options from /etc/fstab.
88
while read TAB_DEV TAB_MTPT TAB_FSTYPE TAB_OPTS TAB_REST
90
case "$TAB_DEV" in (""|\#*) continue ;; esac
91
[ "$MTPT" = "$TAB_MTPT" ] || continue
92
[ "$FSTYPE" = "$TAB_FSTYPE" ] || continue
94
noauto|*,noauto|noauto,*|*,noauto,*)
110
log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount."
114
if mountpoint -q "$MTPT"
116
return # Already mounted
119
if [ "$VERBOSE" != "no" ]; then
120
is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
122
mount -n -t $FSTYPE $5 $OPTS $DEVNAME $MTPT
123
if [ "$FSTYPE" = "tmpfs" -a -x /sbin/restorecon ]; then
124
/sbin/restorecon $MTPT
129
# Preserve /var/run and /var/lock mountpoints
133
# We may end up mounting something over top of /var, either directly
134
# or because /var is a symlink to something that's mounted. So keep
135
# copies of the /var/run and /var/lock mounts elsewhere on the root
136
# filesystem so they can be moved back.
137
if [ yes = "$RAMRUN" ] ; then
138
mkdir /lib/init/rw/var.run
139
mount -n --bind /var/run /lib/init/rw/var.run
141
if [ yes = "$RAMLOCK" ] ; then
142
mkdir /lib/init/rw/var.lock
143
mount -n --bind /var/lock /lib/init/rw/var.lock
148
# Restore /var/run and /var/lock mountpoints if something was mounted
149
# as /var/. Avoid mounting them back over themselves if nothing was
150
# mounted as /var/ by checking if /var/run/ and /var/lock/ are still
151
# mount points. Enabling RAMRUN and RAMLOCK while listing /var/run or
152
# /var/lock in /etc/fstab is not supported.
156
if [ yes = "$RAMRUN" ] ; then
157
[ -d /var/run ] || mkdir /var/run
158
if mountpoint -q /var/run ; then
159
umount /lib/init/rw/var.run
161
mount -n --move /lib/init/rw/var.run /var/run
163
rmdir /lib/init/rw/var.run
165
if [ yes = "$RAMLOCK" ] ; then
166
[ -d /var/lock ] || mkdir /var/lock
167
if mountpoint -q /var/lock ; then
168
umount /lib/init/rw/var.lock
170
mount -n --move /lib/init/rw/var.lock /var/lock
172
rmdir /lib/init/rw/var.lock