4 # Required-Start: checkroot
8 # Short-Description: Update mtab file.
9 # Description: Update the mount program's mtab file after
10 # all local filesystems have been mounted.
14 # The main purpose of this script is to update the mtab file to reflect
15 # the fact that virtual filesystems were mounted early on, before mtab
19 ## We don't need this on SLP platform
20 [ -e /etc/init.d/.slp ] && exit 0
27 [ -f /etc/default/devpts ] && . /etc/default/devpts
30 [ -f /etc/default/tmpfs ] && . /etc/default/tmpfs
34 . /lib/lsb/init-functions
35 . /lib/init/mount-functions.sh
39 # $3 - mount name/device
50 if ! mountpoint -q $2 < /dev/null
63 if ! grep -E -sq "^([^ ]+) +$2 +" /etc/mtab < /dev/null
65 mount -f -t $1 $OPTS $4 $NAME $2 < /dev/null
71 MTAB_PATH="$(readlink -f /etc/mtab || :)"
74 # Assume that /proc/ is not writable
77 # Only update mtab if it is known to be writable
78 # Note that the touch program is in /usr/bin
79 #if ! touch "$MTAB_PATH" >/dev/null 2>&1
85 [ -L /etc/mtab ] && MTAB_PATH="$(readlink /etc/mtab)"
88 log_failure_msg "Cannot initialize ${MTAB_PATH}."
90 log_failure_msg "Cannot initialize /etc/mtab."
94 log_failure_msg "Illegal mtab location '${MTAB_PATH}'."
99 # Initialize mtab file if necessary
101 if [ ! -f /etc/mtab ]
106 if selinux_enabled && [ -x /sbin/restorecon ] && [ -r /etc/mtab ]
113 [ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
114 domtab tmpfs /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
116 domtab proc /proc "proc" -onodev,noexec,nosuid
117 if grep -E -qs "sysfs\$" /proc/filesystems
119 domtab sysfs /sys sysfs -onodev,noexec,nosuid
121 if [ yes = "$RAMRUN" ] ; then
123 [ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
124 domtab tmpfs /var/run "varrun" -omode=0755,nosuid$RUN_OPT
126 if [ yes = "$RAMLOCK" ] ; then
128 [ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
129 domtab tmpfs /var/lock "varlock" -omode=1777,nodev,noexec,nosuid$LOCK_OPT
131 if [ -d /proc/bus/usb ]
133 domtab usbfs /proc/bus/usb "procbususb"
137 domtab tmpfs /dev "udev" -omode=0755
141 [ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE"
142 domtab tmpfs /dev/shm tmpfs -onosuid,nodev$SHM_OPT
143 domtab devpts /dev/pts "devpts" -onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE
145 # Add everything else in /proc/mounts into /etc/mtab, with
146 # special exceptions.
147 exec 9<&0 0</proc/mounts
148 while read FDEV FDIR FTYPE FOPTS REST
151 /lib/modules/*/volatile)
155 # Not really useful to show in 'df',
156 # and it isn't accessible for non-root
161 domtab "$FTYPE" "$FDIR" "$FDEV" "-o$FOPTS"
170 restart|reload|force-reload)
171 echo "Error: argument '$1' not supported" >&2
178 echo "Usage: mountall-mtab.sh [start|stop]" >&2