[Pkg-sysvinit-commits] r837 - in sysvinit/trunk/debian: .
initscripts/etc/init.d initscripts/lib/init
Petter Reinholdtsen
pere at costa.debian.org
Tue Sep 5 22:30:05 UTC 2006
Author: pere
Date: 2006-09-05 22:30:04 +0000 (Tue, 05 Sep 2006)
New Revision: 837
Modified:
sysvinit/trunk/debian/changelog
sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh
sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh
Log:
* Change init.d/mtab.sh to be more self-contained, and update
/etc/mtab with info on all file systems mounted before /etc/mtab
was writable by processing /proc/mounts. Based on patch from
Scott James Remnant and Ubuntu.
Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog 2006-09-05 21:34:19 UTC (rev 836)
+++ sysvinit/trunk/debian/changelog 2006-09-05 22:30:04 UTC (rev 837)
@@ -36,6 +36,10 @@
checkroot, not mountall.
* Move mtab to rcS.d/S12mtab.sh, to make sure it is the first script
to run after checkroot.sh.
+ * Change init.d/mtab.sh to be more self-contained, and update
+ /etc/mtab with info on all file systems mounted before /etc/mtab
+ was writable by processing /proc/mounts. Based on patch from
+ Scott James Remnant and Ubuntu.
-- Petter Reinholdtsen <pere at debian.org> Wed, 26 Jul 2006 11:37:23 +0200
Modified: sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh 2006-09-05 21:34:19 UTC (rev 836)
+++ sysvinit/trunk/debian/initscripts/etc/init.d/mtab.sh 2006-09-05 22:30:04 UTC (rev 837)
@@ -21,12 +21,131 @@
# /dev/pts and /dev/shm.
#
+PATH=/lib/init:/sbin:/bin
+TTYGRP=5
+TTYMODE=620
+[ -f /etc/default/devpts ] && . /etc/default/devpts
+
+TMPFS_SIZE=
+[ -f /etc/default/tmpfs ] && . /etc/default/tmpfs
+
+KERNEL="$(uname -s)"
+
+. /lib/lsb/init-functions
+. /lib/init/mount-functions.sh
+
+# $1 - fstype
+# $2 - mount point
+# $3 - mount name/device
+# $4 - mount options
+domtab ()
+{
+ # Directory present?
+ if [ ! -d $2 ]
+ then
+ return
+ fi
+
+ # Not mounted?
+ if ! mountpoint -q $2
+ then
+ return
+ fi
+
+ if [ -n "$3" ]
+ then
+ NAME="$3"
+ else
+ NAME="$1"
+ fi
+
+ # Already recorded?
+ if ! grep -E -sq "^([^ ]+) +$2 +" /etc/mtab
+ then
+ mount -f -t $1 $OPTS $4 $NAME $2
+ fi
+}
+
+do_start () {
+ DO_MTAB=""
+ MTAB_PATH="$(readlink -f /etc/mtab || :)"
+ case "$MTAB_PATH" in
+ /proc/*)
+ # Assume that /proc/ is not writable
+ ;;
+ /*)
+ # Only update mtab if it is known to be writable
+ # Note that the touch program is in /usr/bin
+ #if ! touch "$MTAB_PATH" >/dev/null 2>&1
+ #then
+ # return
+ #fi
+ ;;
+ "")
+ [ -L /etc/mtab ] && MTAB_PATH="$(readlink /etc/mtab)"
+ if [ "$MTAB_PATH" ]
+ then
+ log_failure_msg "Cannot initialize ${MTAB_PATH}."
+ else
+ log_failure_msg "Cannot initialize /etc/mtab."
+ fi
+ ;;
+ *)
+ log_failure_msg "Illegal mtab location '${MTAB_PATH}'."
+ ;;
+ esac
+
+ #
+ # Initialize mtab file if necessary
+ #
+ if [ ! -f /etc/mtab ]
+ then
+ :> /etc/mtab
+ chmod 644 /etc/mtab
+ fi
+ if selinux_enabled && which restorecon >/dev/null 2>&1 && [ -r /etc/mtab ]
+ then
+ restorecon /etc/mtab
+ fi
+
+ # S02mountkernfs.sh
+ domtab proc /proc "proc" -onodev,noexec,nosuid
+ domtab sysfs /sys "sys" -onodev,noexec,nosuid
+ #domtab usbfs /proc/bus/usb "procbususb" -- disabled in development
+
+ # S03udev
+ domtab tmpfs /dev "udev" -omode=0755
+
+ # S04mountdevsubfs
+ SHM_OPT=
+ [ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT="-osize=$SHM_SIZE"
+ domtab tmpfs /dev/shm "devshm" $SHM_OPT
+ domtab devpts /dev/pts "devpts" -ogid=$TTYGRP,mode=$TTYMODE
+
+ # Add everything else in /proc/mounts into /etc/mtab, with
+ # special exceptions.
+ exec 9<&0 0</proc/mounts
+ while read FDEV FDIR FTYPE FOPTS REST
+ do
+ case "$FDIR" in
+ /lib/modules/*/volatile)
+ FDEV="lrm"
+ ;;
+ /dev/.static/dev)
+ continue # Not really useful to show in 'df'
+ ;;
+ esac
+ domtab "$FTYPE" "$FDIR" "$FDEV" "-o$FOPTS"
+ done
+ exec 0<&9 9<&-
+}
+
case "$1" in
start|"")
- set "start"
- . /etc/init.d/mountkernfs.sh
- set "start"
- . /etc/init.d/mountdevsubfs.sh
+ # Can't source, as it seem to terminate this script too early if I do.
+ /etc/init.d/mountdevsubfs.sh start
+
+ do_start
;;
restart|reload|force-reload)
echo "Error: argument '$1' not supported" >&2
Modified: sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh
===================================================================
--- sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh 2006-09-05 21:34:19 UTC (rev 836)
+++ sysvinit/trunk/debian/initscripts/lib/init/mount-functions.sh 2006-09-05 22:30:04 UTC (rev 837)
@@ -25,52 +25,12 @@
}
+# Called before mtab is writable to mount kernel and device file systems.
# $1: file system type
# $2: alternative file system type (or empty string if none)
# $3: mount point
# $4... : extra mount program options
domount () {
- DO_MTAB=""
- MTAB_PATH="$(readlink -f /etc/mtab || :)"
- case "$MTAB_PATH" in
- /proc/*)
- # Assume that /proc/ is not writable
- ;;
- /*)
- # Only update mtab if it is known to be writable
- # Note that the touch program is in /usr/bin
- if touch "$MTAB_PATH" >/dev/null 2>&1
- then
- DO_MTAB=y
- fi
- ;;
- "")
- [ -L /etc/mtab ] && MTAB_PATH="$(readlink /etc/mtab)"
- if [ "$MTAB_PATH" ]
- then
- log_failure_msg "Cannot initialize ${MTAB_PATH}."
- else
- log_failure_msg "Cannot initialize /etc/mtab."
- fi
- ;;
- *)
- log_failure_msg "Illegal mtab location '${MTAB_PATH}'."
- ;;
- esac
-
- #
- # Initialize mtab file if necessary
- #
- if [ "$DO_MTAB" ] && [ ! -f /etc/mtab ]
- then
- :> /etc/mtab
- chmod 644 /etc/mtab
- fi
- if selinux_enabled && which restorecon >/dev/null 2>&1 && [ -r /etc/mtab ]
- then
- restorecon /etc/mtab
- fi
-
MTPT="$3"
KERNEL="$(uname -s)"
# Figure out filesystem type
@@ -133,25 +93,14 @@
return
fi
- # We give file system type as device name
if mountpoint -q "$MTPT"
then
- # Already mounted
- # Just update mtab, if possible and necessary
- if [ "$DO_MTAB" ] && ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab
- then
- mount -f -t $FSTYPE $OPTS $4 $FSTYPE $MTPT
- fi
- else
- # Not already mounted
+ return # Already mounted
+ fi
+
+ # We give file system type as device name
+ if [ "$VERBOSE" != "no" ]; then
is_empty_dir "$MTPT" >/dev/null 2>&1 || log_warning_msg "Files under mount point '$MTPT' will be hidden."
- # Mount it, updating mtab if possible
- if [ "$DO_MTAB" ]
- then
- mount -t $FSTYPE $OPTS $4 $FSTYPE $MTPT
- else
- mount -n -t $FSTYPE $OPTS $4 $FSTYPE $MTPT
- fi
fi
+ mount -n -t $FSTYPE $OPTS $4 $FSTYPE $MTPT
}
-
More information about the Pkg-sysvinit-commits
mailing list