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
49
elif grep -E -qs "$1\$" /proc/filesystems
52
elif grep -E -qs "$2\$" /proc/filesystems
61
log_warning_msg "Filesystem types '$1' and '$2' are not supported. Skipping mount."
63
log_warning_msg "Filesystem type '$1' is not supported. Skipping mount."
68
# We give file system type as device name if not specified as
76
# Get the options from /etc/fstab.
82
while read TAB_DEV TAB_MTPT TAB_FSTYPE TAB_OPTS TAB_REST
84
case "$TAB_DEV" in (""|\#*) continue ;; esac
85
[ "$MTPT" = "$TAB_MTPT" ] || continue
86
[ "$FSTYPE" = "$TAB_FSTYPE" ] || continue
88
noauto|*,noauto|noauto,*|*,noauto,*)
104
log_warning_msg "Mount point '$MTPT' does not exist. Skipping mount."
108
if mountpoint -q "$MTPT"
110
return # Already mounted
113
if [ "$VERBOSE" != "no" ]; then
114
is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
116
mount -n -t $FSTYPE $5 $OPTS $DEVNAME $MTPT
117
if [ "$FSTYPE" = "tmpfs" -a -x /sbin/restorecon ]; then
118
/sbin/restorecon $MTPT
123
# Preserve /var/run and /var/lock mountpoints
127
# We may end up mounting something over top of /var, either directly
128
# or because /var is a symlink to something that's mounted. So keep
129
# copies of the /var/run and /var/lock mounts elsewhere on the root
130
# filesystem so they can be moved back.
131
if [ yes = "$RAMRUN" ] ; then
132
mkdir /lib/init/rw/var.run
133
mount -n --bind /var/run /lib/init/rw/var.run
135
if [ yes = "$RAMLOCK" ] ; then
136
mkdir /lib/init/rw/var.lock
137
mount -n --bind /var/lock /lib/init/rw/var.lock
142
# Restore /var/run and /var/lock mountpoints if something was mounted
143
# as /var/. Avoid mounting them back over themselves if nothing was
144
# mounted as /var/ by checking if /var/run/ and /var/lock/ are still
145
# mount points. Enabling RAMRUN and RAMLOCK while listing /var/run or
146
# /var/lock in /etc/fstab is not supported.
150
if [ yes = "$RAMRUN" ] ; then
151
[ -d /var/run ] || mkdir /var/run
152
if mountpoint -q /var/run ; then
153
umount /lib/init/rw/var.run
155
mount -n --move /lib/init/rw/var.run /var/run
157
rmdir /lib/init/rw/var.run
159
if [ yes = "$RAMLOCK" ] ; then
160
[ -d /var/lock ] || mkdir /var/lock
161
if mountpoint -q /var/lock ; then
162
umount /lib/init/rw/var.lock
164
mount -n --move /lib/init/rw/var.lock /var/lock
166
rmdir /lib/init/rw/var.lock