[Pkg-sysvinit-commits] r1955 - in sysvinit/trunk/debian: . src/initscripts src/initscripts/doc src/initscripts/etc/default src/initscripts/etc/init.d src/initscripts/lib/init src/initscripts/man src/initscripts/share

Kel Modderman kelmo-guest at alioth.debian.org
Sat Apr 16 10:44:44 UTC 2011


Author: kelmo-guest
Date: 2011-04-16 10:44:34 +0000 (Sat, 16 Apr 2011)
New Revision: 1955

Added:
   sysvinit/trunk/debian/src/initscripts/lib/init/tmpfs.sh
Removed:
   sysvinit/trunk/debian/src/initscripts/lib/init/usplash-fsck-functions.sh
Modified:
   sysvinit/trunk/debian/changelog
   sysvinit/trunk/debian/initscripts.postinst
   sysvinit/trunk/debian/src/initscripts/Makefile
   sysvinit/trunk/debian/src/initscripts/doc/README.Debian
   sysvinit/trunk/debian/src/initscripts/etc/default/tmpfs
   sysvinit/trunk/debian/src/initscripts/etc/init.d/checkfs.sh
   sysvinit/trunk/debian/src/initscripts/etc/init.d/checkroot.sh
   sysvinit/trunk/debian/src/initscripts/etc/init.d/mountdevsubfs.sh
   sysvinit/trunk/debian/src/initscripts/etc/init.d/mountkernfs.sh
   sysvinit/trunk/debian/src/initscripts/etc/init.d/mtab.sh
   sysvinit/trunk/debian/src/initscripts/etc/init.d/sendsigs
   sysvinit/trunk/debian/src/initscripts/etc/init.d/umountfs
   sysvinit/trunk/debian/src/initscripts/etc/init.d/umountnfs.sh
   sysvinit/trunk/debian/src/initscripts/lib/init/bootclean.sh
   sysvinit/trunk/debian/src/initscripts/lib/init/mount-functions.sh
   sysvinit/trunk/debian/src/initscripts/lib/init/vars.sh
   sysvinit/trunk/debian/src/initscripts/man/rcS.5
   sysvinit/trunk/debian/src/initscripts/share/default.rcS
Log:
* Non-maintainer upload.
* Support for new top-level directory /run to replace /var/run,
  /var/lock, /dev/shm and /lib/init/rw as a place to store transient
  writable data which should not be preserved across a system
  reboot (Closes: #186892, #616571, #620191).  /run fixes existing
  issues with RAMRUN and RAMLOCK options using tmpfs on /var/run and
  /var/lock (Closes: #423405, #481546, #564635, #607136, #620735).
  Additionally, /run/shm replaces /dev/shm and may share the same
  tmpfs as /run if RAMSHM is set to "no" in /etc/default/rcS.  /tmp
  may also be configured to be a tmpfs if RAMTMP is set to "yes" in
  /etc/default/rcS.  /tmp may also be configured to use /run directly if
  it is symlinked to /run/tmp, for example.
  Summary:
    /var/run ?\226?\134?\146 /run
    /var/lock ?\226?\134?\146 /run/lock
    /dev/shm ?\226?\134?\146 /run/shm
    /lib/init/rw ?\226?\134?\146 /run (not transitioned automatically)
    /dev/.* ?\226?\134?\146 /run (not transitioned automatically)
  These changes do not take effect until the system is rebooted as
  is currently done for /lib/init/rw setup.  Prior to a reboot, the
  paths are made available via bind/nullfs/firmlink mounts, depending on
  the platform.  Following a reboot, the old paths will be converted to
  symlinks, or bind/nullfs/firmlink mounts where symlinking is not
  possible, to allow access via either the old or new paths, to permit
  programs using the old paths to transition to use the new paths for
  wheezy.
  - debian/initscripts.postinst:
    Take chroot detection logic from udev postinst (existing logic was
    broken).  Add detection logic for vserver environments and Hurd.
    Trigger reboot to complete transition.
    If the system has not yet transitioned to a tmpfs-based /run, set up
    bind mounts as follows:
      /var/run ?\226?\134?\146 /run
      /var/lock ?\226?\134?\146 /run/lock
      /dev/shm ?\226?\134?\146 /run/shm
    On reboot, the system will complete the migration to a tmpfs-based
    /run; this creates the directory heierachy from the old paths to
    enable the use of the new /run paths prior to a restart.  This means
    packages may transition to using /run with a versioned dependency
    upon initscripts.
    Remove special handling for RAMRUN and RAMLOCK, which is now taken
    care of by /run.
    If in a chroot environment, just create symlinks from the new names
    to the existing locations, since otherwise the changes would be
    lost, and since rcS scripts aren't run the transition won't
    complete.
  - debian/src/initscripts/Makefile:
    Provide top-level /run.
  - debian/src/initscripts/doc/README.Debian:
    Document new use of RUN_SIZE and LOCK_SIZE.
    Document use of /run rather than /lib/init/rw.
    Document use of SHM_SIZE and TMP_SIZE.
  - debian/src/initscripts/etc/init.d/checkroot.sh:
    Use /run in place of /lib/init/rw.
  - debian/src/initscripts/etc/default/tmpfs:
    Document TMPFS_SIZE, RUN_SIZE and LOCK_SIZE (Closes: #483643).
    Document TMP_SIZE and SHM_SIZE.
  - debian/src/initscripts/etc/init.d/mountkernfs.sh:
    Create /run, /run/sendsigs.omit.d and /run/lock.
    Mount /run/lock as a separate tmpfs if RAMLOCK=yes.
    /run/lock has 01777 permissions to match /var/lock.
    Mount /tmp as a separate tmpfs if RAMTMP=yes or / is being mounted
    read-only (Closes: #503805, #585543).
    Drop mounting of /var/run and /var/lock.
  - debian/src/initscripts/etc/init.d/mountdevsubfs.sh:
    Create /run/shm.  Mount /run/shm as a separate tmpfs if RAMSHM=yes.
  - debian/src/initscripts/etc/init.d/mtab.sh:
    domtab mirrors behaviour of domount in mount-functions exactly, to
    prevent duplicate mounts (required for bind mount support).
    Bind mount /run/init and drop mounting of /var/run.  Mount /run/lock
    in place of /var/lock.
    Mount /tmp if RAMTMP=yes.
    Mount /run/shm if RAMSHM=yes.
  - debian/src/initscripts/etc/init.d/sendsigs:
    Use new paths:
      files: /run/sendsigs.omit /lib/init/rw/sendsigs.omit
      dirs: /run/sendsigs.omit.d/ /lib/init/rw/sendsigs.omit.d/
  - debian/src/initscripts/etc/init.d/umountfs:
    Ignore /run.  Continue to ignore /lib/init/rw in order to handle
    clean shutdown.  No longer ignore /var/run and /var/lock.
  - debian/src/initscripts/etc/init.d/umountnfs.sh:
    Check for presence of .ramfs than configuration variable when
    skipping /var/run and /var/lock.
    Ignore /run.  Continue to ignore /lib/init/rw in order to handle
    clean shutdown.  No longer ignore /var/run and /var/lock.
  - debian/src/initscripts/lib/init/bootclean.sh
    Don't clean /var/run and /var/lock (Closes: #378776).  Because
    these directories are now a tmpfs, cleaning no longer makes sense.
  - debian/src/initscripts/lib/init/tmpfs.sh:
    Read /etc/default/tmpfs and provide defaults if unset.
  - debian/src/initscripts/lib/init/mount-functions.sh:
    Support bind mounts in domount() (Closes: #353943).
    Drop support for mounting /var/run and /var/lock as separate
    tmpfs filesystems.  Symlink /var/run to /run and /var/lock to
    /run/lock if possible.  If /var/run and /var/lock are directories,
    attempt to remove and symlink if successful, or else bind mount.
  - debian/src/initscripts/lib/init/vars.sh:
    Read /etc/default/rcS and provide defaults if unset.
  - debian/src/initscripts/man/rcS.5:
    Drop documentation of RAMRUN.
    Update documentation for RAMLOCK (Closes: #406685).
    Document RAMTMP and RAMSHM.
  - debian/src/initscripts/share/default.rcS:
    Remove RAMRUN.
    Add RAMSHM and RAMTMP.
    RAMLOCK, RAMSHM and RAMTMP default to enabled for new installs.
* Remove dead usplash support code (Closes: #599241, #599734, #612594).
* Add comments to /etc/default/rcS (Closes: #530582).
Hurd portability for initscripts postinst and init scripts.
Hurd does not currently support tmpfs mounts, but will do in the
future.  Use firmlinks in place of bind mounts.

Modified: sysvinit/trunk/debian/changelog
===================================================================
--- sysvinit/trunk/debian/changelog	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/changelog	2011-04-16 10:44:34 UTC (rev 1955)
@@ -1,3 +1,126 @@
+sysvinit (2.88dsf-13.3) experimental; urgency=low
+
+  [ Roger Leigh ]
+  * Non-maintainer upload.
+  * Support for new top-level directory /run to replace /var/run,
+    /var/lock, /dev/shm and /lib/init/rw as a place to store transient
+    writable data which should not be preserved across a system
+    reboot (Closes: #186892, #616571, #620191).  /run fixes existing
+    issues with RAMRUN and RAMLOCK options using tmpfs on /var/run and
+    /var/lock (Closes: #423405, #481546, #564635, #607136, #620735).
+    Additionally, /run/shm replaces /dev/shm and may share the same
+    tmpfs as /run if RAMSHM is set to "no" in /etc/default/rcS.  /tmp
+    may also be configured to be a tmpfs if RAMTMP is set to "yes" in
+    /etc/default/rcS.  /tmp may also be configured to use /run directly if
+    it is symlinked to /run/tmp, for example.
+    Summary:
+      /var/run → /run
+      /var/lock → /run/lock
+      /dev/shm → /run/shm
+      /lib/init/rw → /run (not transitioned automatically)
+      /dev/.* → /run (not transitioned automatically)
+    These changes do not take effect until the system is rebooted as
+    is currently done for /lib/init/rw setup.  Prior to a reboot, the
+    paths are made available via bind/nullfs/firmlink mounts, depending on
+    the platform.  Following a reboot, the old paths will be converted to
+    symlinks, or bind/nullfs/firmlink mounts where symlinking is not
+    possible, to allow access via either the old or new paths, to permit
+    programs using the old paths to transition to use the new paths for
+    wheezy.
+    - debian/initscripts.postinst:
+      Take chroot detection logic from udev postinst (existing logic was
+      broken).  Add detection logic for vserver environments and Hurd.
+      Trigger reboot to complete transition.
+      If the system has not yet transitioned to a tmpfs-based /run, set up
+      bind mounts as follows:
+        /var/run → /run
+        /var/lock → /run/lock
+        /dev/shm → /run/shm
+      On reboot, the system will complete the migration to a tmpfs-based
+      /run; this creates the directory heierachy from the old paths to
+      enable the use of the new /run paths prior to a restart.  This means
+      packages may transition to using /run with a versioned dependency
+      upon initscripts.
+      Remove special handling for RAMRUN and RAMLOCK, which is now taken
+      care of by /run.
+      If in a chroot environment, just create symlinks from the new names
+      to the existing locations, since otherwise the changes would be
+      lost, and since rcS scripts aren't run the transition won't
+      complete.
+    - debian/src/initscripts/Makefile:
+      Provide top-level /run.
+    - debian/src/initscripts/doc/README.Debian:
+      Document new use of RUN_SIZE and LOCK_SIZE.
+      Document use of /run rather than /lib/init/rw.
+      Document use of SHM_SIZE and TMP_SIZE.
+    - debian/src/initscripts/etc/init.d/checkroot.sh:
+      Use /run in place of /lib/init/rw.
+    - debian/src/initscripts/etc/default/tmpfs:
+      Document TMPFS_SIZE, RUN_SIZE and LOCK_SIZE (Closes: #483643).
+      Document TMP_SIZE and SHM_SIZE.
+    - debian/src/initscripts/etc/init.d/mountkernfs.sh:
+      Create /run, /run/sendsigs.omit.d and /run/lock.
+      Mount /run/lock as a separate tmpfs if RAMLOCK=yes.
+      /run/lock has 01777 permissions to match /var/lock.
+      Mount /tmp as a separate tmpfs if RAMTMP=yes or / is being mounted
+      read-only (Closes: #503805, #585543).
+      Drop mounting of /var/run and /var/lock.
+    - debian/src/initscripts/etc/init.d/mountdevsubfs.sh:
+      Create /run/shm.  Mount /run/shm as a separate tmpfs if RAMSHM=yes.
+    - debian/src/initscripts/etc/init.d/mtab.sh:
+      domtab mirrors behaviour of domount in mount-functions exactly, to
+      prevent duplicate mounts (required for bind mount support).
+      Bind mount /run/init and drop mounting of /var/run.  Mount /run/lock
+      in place of /var/lock.
+      Mount /tmp if RAMTMP=yes.
+      Mount /run/shm if RAMSHM=yes.
+    - debian/src/initscripts/etc/init.d/sendsigs:
+      Use new paths:
+        files: /run/sendsigs.omit /lib/init/rw/sendsigs.omit
+        dirs: /run/sendsigs.omit.d/ /lib/init/rw/sendsigs.omit.d/
+    - debian/src/initscripts/etc/init.d/umountfs:
+      Ignore /run.  Continue to ignore /lib/init/rw in order to handle
+      clean shutdown.  No longer ignore /var/run and /var/lock.
+    - debian/src/initscripts/etc/init.d/umountnfs.sh:
+      Check for presence of .ramfs than configuration variable when
+      skipping /var/run and /var/lock.
+      Ignore /run.  Continue to ignore /lib/init/rw in order to handle
+      clean shutdown.  No longer ignore /var/run and /var/lock.
+    - debian/src/initscripts/lib/init/bootclean.sh
+      Don't clean /var/run and /var/lock (Closes: #378776).  Because
+      these directories are now a tmpfs, cleaning no longer makes sense.
+    - debian/src/initscripts/lib/init/tmpfs.sh:
+      Read /etc/default/tmpfs and provide defaults if unset.
+    - debian/src/initscripts/lib/init/mount-functions.sh:
+      Support bind mounts in domount() (Closes: #353943).
+      Drop support for mounting /var/run and /var/lock as separate
+      tmpfs filesystems.  Symlink /var/run to /run and /var/lock to
+      /run/lock if possible.  If /var/run and /var/lock are directories,
+      attempt to remove and symlink if successful, or else bind mount.
+    - debian/src/initscripts/lib/init/vars.sh:
+      Read /etc/default/rcS and provide defaults if unset.
+    - debian/src/initscripts/man/rcS.5:
+      Drop documentation of RAMRUN.
+      Update documentation for RAMLOCK (Closes: #406685).
+      Document RAMTMP and RAMSHM.
+    - debian/src/initscripts/share/default.rcS:
+      Remove RAMRUN.
+      Add RAMSHM and RAMTMP.
+      RAMLOCK, RAMSHM and RAMTMP default to enabled for new installs.
+
+  [ Michael Biebl ]
+  * Remove dead usplash support code (Closes: #599241, #599734, #612594).
+
+  [ Martin F. Krafft ]
+  * Add comments to /etc/default/rcS (Closes: #530582).
+
+  [ Samuel Thibault ]
+  Hurd portability for initscripts postinst and init scripts.
+  Hurd does not currently support tmpfs mounts, but will do in the
+  future.  Use firmlinks in place of bind mounts.
+
+ -- Roger Leigh <rleigh at debian.org>  Sat, 16 Apr 2011 01:17:29 +0100
+
 sysvinit (2.88dsf-13.2) unstable; urgency=low
 
   * Non-maintainer upload.

Modified: sysvinit/trunk/debian/initscripts.postinst
===================================================================
--- sysvinit/trunk/debian/initscripts.postinst	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/initscripts.postinst	2011-04-16 10:44:34 UTC (rev 1955)
@@ -16,13 +16,73 @@
 
 umask 022
 
-chrooted() {
-  if [ -r /proc/1/root ]; then
-    return 1
-  fi
-  return 0
+guest_environment() {
+	case "$(uname -s)" in
+		GNU)
+			if [ "$(stat -c %d /)" = 3 ]
+			then
+				# /'s pid is 3, this is the real root.
+				return 1
+			fi
+			;;
+		*)
+			if [ "$(stat -c %d/%i /)" = "$(stat -Lc %d/%i /proc/1/root 2>/dev/null)" ];
+			then
+				# the devicenumber/inode pair of / is
+				# the same as that of /sbin/init's
+				# root, so we're *not* in a chroot and
+				# hence return false.
+			    return 1
+			fi
+			if [ -e /proc/self/vinfo ]; then
+				# If XID: 0 is found, we're a vserver
+				# host, *not* a guest, hence return
+				# false
+				if grep '^XID:[[:space:]]*0$' /proc/self/vinfo 2>&1 >/dev/null; then
+					return 1
+				fi
+			fi
+			;;
+	esac
+
+	return 0
 }
 
+bind_mount ()
+{
+	SRC=$1
+	DEST=$2
+
+	FSTYPE=""
+	OPTS=""
+
+	case "$(uname -s)" in
+		Linux)     FSTYPE=$SRC; OPTS="-orw -obind" ;;
+		*FreeBSD)  FSTYPE=nullfs; OPTS="-orw" ;;
+		GNU)       FSTYPE=firmlink ;;
+		*)         FSTYPE=none ;;
+	esac
+
+	# Bind mount $SRC on $DEST
+	if mount -t $FSTYPE "$SRC" "$DEST" $OPTS ; then
+		return 0
+	fi
+
+	return 1
+}
+
+compat_link () {
+	SRC=$1
+	DEST=$2
+
+	echo "guest environment detected: Linking $DEST to $SRC"
+	( rm -fr $DEST &&
+	  ln -fs $SRC $DEST) ||
+	  { echo "Can't symlink $DEST to $SRC; please fix manually."; return 1; }
+
+	return 0
+}
+
 #
 # Initialize rcS default file.
 #
@@ -118,38 +178,96 @@
 done
 
 #
-# Create /var/run and /var/lock on the root partition to make sure
-# they are available when RAMRUN or RAMLOCK is enabled.
-# If mount fail (like in a vserver environment), just clean up and ignore
-# it.  The admins enabling RAMRUN and RAMLOCK will have to create the
-# directories themselves in this case.
+# Setup /run if not already in use.  Note that the intent here is to
+# make the existing /var/run and /var/lock available as /run,
+# /run/lock, respectively.  When the system is next restarted, a
+# proper /run tmpfs will be set up.  The bind mounts set up here are
+# intended to recreate the directory hierarchy using the existing
+# locations in order that packages may transition to using /run
+# without a system restart.
 #
-if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-22" && ! chrooted
-then
-	# We need to quickly bind / to another location so we can make them
-	# just in case /var is a mountpoint or a symlink to one.
-	mkdir -p /.root
-	if mount -n --bind / /.root ; then
-		if [ -L /.root/var ] && [ ! -d /.root/var ] ; then
-			# No use trying if /var is a relative symlink.  It is not
-			# going to work.
-			:
-		else
-			mkdir -p /.root/var/run /.root/var/lock
+
+# Device and inode of directories:
+svarrun="$(/usr/bin/stat -L --format="%d %i" /var/run)"
+svarlock="$(/usr/bin/stat -L --format="%d %i" /var/lock)"
+sdevshm="$(/usr/bin/stat -L --format="%d %i" /dev/shm)"
+# May not exist yet
+srun="$(/usr/bin/stat -L --format="%d %i" /run 2>/dev/null || :)"
+srunlock="$(/usr/bin/stat -L --format="%d %i" /run/lock 2>/dev/null || :)"
+srunshm="$(/usr/bin/stat -L --format="%d %i" /run/shm 2>/dev/null || :)"
+# If in a chroot or vserver environment (i.e. a guest, which does not
+# run rcS scripts), do not do any messing around with mounts, and
+# don't migrate /var/run, /var/lock or /dev/shm.  Bind mounting would
+# not work in a chroot, because the migration would only be
+# temporary--the rcS scripts are not guaranteed to run, so we must do
+# the migration by hand at this point.  We create symlinks from the
+# new locations to the old locations, which should be safe.  The
+# sysadmin should, if they care, move the old locations to the new
+# locations and create compatibilty symlinks at their convenience
+# following the upgrade.
+if guest_environment; then
+	if [ ! -f /run/.ramfs ] && [ "$svarrun" != "$srun" ]; then
+		# Symlink /var/run from /run
+		if compat_link /var/run /run; then
+			# Symlink /var/lock from /run/lock
+			if [ "$svarlock" != "$srunlock" ]; then
+				compat_link /var/lock /run/lock
+			fi
+
+			# Symlink /dev/shm from /run/shm
+			if [ "$sdevshm" != "$srunshm" ]; then
+				compat_link /dev/shm /run/shm
+			fi
 		fi
-		umount /.root
 	fi
-	rmdir /.root
+# Not a chroot.  If /run/.run-transition does not exist then
+# skip.  /run/.run-transition should not exist either before
+# or after the transition.  This file is used to ensure we
+# don't perform the initial migration more than once if
+# initscripts is upgraded again before a system restart (and
+# hence transition completion).
+elif [ ! -f /run/.run-transition ]; then
+	# If /run/.ramfs exists, then a ramfs already exists,
+	# and we assume it's all set up correctly.  If the
+	# device/inode are the same, it's not set up entirely
+	# correctly, but a bind mount already exists for some
+	# reason, so again assume set up is not required.
+	if [ ! -f /run/.ramfs ] && [ "$svarrun" != "$srun" ]; then
+		# Bind mount /var/run on /run
+		if bind_mount /var/run /run; then
+			# Bind mount /var/lock on /run/lock
+			[ -d /run/lock ] || mkdir /run/lock
+			if [ "$svarlock" != "$srunlock" ]; then
+				bind_mount /var/lock /run/lock
+			fi
+
+			# Bind mount /dev/shm on /run/shm
+			[ -d /run/shm ] || mkdir /run/shm
+			if [ "$sdevshm" != "$srunshm" ]; then
+				bind_mount /dev/shm /run/shm
+			fi
+		fi
+	fi
+
+	# Create a /run/.run-transition stamp file.  This is
+	# to ensure we don't repeat the above setup if the
+	# package is upgraded again prior to a system reboot.
+	# On reboot, it will be deleted by the init scripts
+	# and the transition will be completed.  This means
+	# the transition will complete at the sysadmin's
+	# convenience, since the system will function
+	# identically before and after a reboot.
+	echo "Please reboot to complete migration to tmpfs-based /run" > /run/.run-transition
 fi
 
 #
-# When installing for the first time or upgrading from version before
-# 2.86.ds1-27, a reboot is needed to make the /lib/init/rw/ tmpfs
-# available.  Flag this using notify-reboot-required.  Not mounting it
-# here as it creates problem for debootstrap, vservers, pbuilder and
-# cowbuilder.
+# When installing for the first time or upgrading from a version
+# before or equal to 2.88dsf-14, a reboot is needed to make the /run
+# tmpfs available.  Flag this using notify-reboot-required.  /run is
+# available in some form before the reboot, so the need for a reboot
+# isn't particularly urgent.
 #
-if dpkg --compare-versions "$PREV_VER" lt "2.86.ds1-27" \
+if dpkg --compare-versions "$PREV_VER" le "2.88dsf-14" \
  && [ -x /usr/share/update-notifier/notify-reboot-required ]; then
 	/usr/share/update-notifier/notify-reboot-required
 fi

Modified: sysvinit/trunk/debian/src/initscripts/Makefile
===================================================================
--- sysvinit/trunk/debian/src/initscripts/Makefile	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/Makefile	2011-04-16 10:44:34 UTC (rev 1955)
@@ -10,6 +10,11 @@
 all:
 
 install:
+	# TODO: Replace /lib/init/rw directory with symbolic link to
+	# /run.  This requires the directory to be empty and unused,
+	# so needs doing post-wheezy.  If the migration to /run is
+	# complete, could be removed entirely.
+	$(INSTALL) -d $(DESTDIR)/run/.
 	$(INSTALL) -d $(DESTDIR)/lib/init/rw/.
 	$(INSTALL) -d $(DESTDIR)/var/lib/initscripts/.
 	$(INSTALL) -d $(DESTDIR)/var/lib/urandom/.

Modified: sysvinit/trunk/debian/src/initscripts/doc/README.Debian
===================================================================
--- sysvinit/trunk/debian/src/initscripts/doc/README.Debian	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/doc/README.Debian	2011-04-16 10:44:34 UTC (rev 1955)
@@ -2,39 +2,47 @@
 -----
 
 Tmpfs can be used as virtual memory filesystem. glibc 2.2 and above
-expects a tmpfs to be mounted at /dev/shm for POSIX shared memory,
-this is done automatically by /etc/init.d/mountdevsubfs.sh early in
-the boot process. You can limit tmpfs max size by setting the
-SHM_SIZE variable to a desired size in the /etc/default/tmpfs file
-to prevent tmpfs from using up all system memory.
+expects a tmpfs to be mounted at /dev/shm (/run/shm) for POSIX shared
+memory, this is done automatically by /etc/init.d/mountdevsubfs.sh
+early in the boot process. You can limit tmpfs max size by setting the
+SHM_SIZE variable to a desired size in the /etc/default/tmpfs file to
+prevent tmpfs from using up all system memory.
 
-A tmpfs can also be mounted over /var/run/ and /var/lock/. This can
-be achieved by setting the RAMRUN and RAMLOCK variables to "yes" in
-the /etc/default/rcS file. A size limit for the tmpfs filesystem
-mounted over /var/run/ and /var/lock/ can be set via the RUN_SIZE
-and LOCK_SIZE variables in the /etc/default/tmpfs file.
+A size limit for the tmpfs filesystem mounted over /run can be set via
+the RUN_SIZE variable in the /etc/default/tmpfs file.  Likewise, a
+size limit for the tmpfs filesystem mounted over /run/lock can be set
+via the LOCK_SIZE variable (if enabled with RAMLOCK=yes) and for
+/run/shm via the SHM_SIZE variable (if enabled with RAMSHM=yes).
+Additionally, a size limit for the tmpfs filesystem mounted over /tmp
+can be set via the TMP_SIZE variable (if enabled with RAMTMP=yes).
+Note that /tmp may be a symlink to e.g. /run/tmp, making it possible
+to use a single tmpfs for all writable filesystems other than /var;
+the directory pointed to by the symlink will be created if it does not
+already exist.
 
 If TMPFS_SIZE is set in /etc/default/tmpfs, it will be used as the
-default value for SHM_SIZE, RUN_SIZE and LOCK_SIZE. Otherwise, kernel
-defaults are used.
+default value for SHM_SIZE, RUN_SIZE, LOCK_SIZE and
+TMP_SIZE. Otherwise, kernel defaults are used.
 
 
 sendsigs process omission interface
 -----------------------------------
 
-Since initscripts package version 2.86.ds1-48, /etc/init.d/sendsigs
-is able to omit processes from being killed by killall5(8). Process
-id's listed in /var/run/sendsigs.omit, /lib/init/rw/sendsigs.omit or
-any file in the /lib/init/rw/sendsigs.omit.d/ directory will be
-omitted by sendsigs.
+Since initscripts package version 2.86.ds1-48, /etc/init.d/sendsigs is
+able to omit processes from being killed by killall5(8). Process id's
+listed in /run/sendsigs.omit, /lib/init/rw/sendsigs.omit or any file
+in the /run/sendsigs.omit.d/ or /lib/init/rw/sendsigs.omit.d/
+directories will be omitted by sendsigs.  Note use of /lib/init/rw is
+deprecated and will be removed; users of /lib/init/rw must migrate to
+/run.
 
-The recommended practise for adding a process id for omission is to
-create a file in /lib/init/rw/sendsigs.omit.d/<package name>
-containing the process id that is to be omitted by sendsigs.
+The recommended practice for adding a process id for omission is to
+create a file in /run/sendsigs.omit.d/<package name> containing the
+process id that is to be omitted by sendsigs.
 
-This feature is only to be used for processes that need to be
-running when remote file systems are umounted, and that have
-current working directory set to a directory in the root file system.
+This feature is only to be used for processes that need to be running
+when remote file systems are umounted, and that have current working
+directory set to a directory in the root file system.
 
 
 /sys in /etc/fstab

Modified: sysvinit/trunk/debian/src/initscripts/etc/default/tmpfs
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/default/tmpfs	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/default/tmpfs	2011-04-16 10:44:34 UTC (rev 1955)
@@ -1,6 +1,48 @@
-# SHM_SIZE sets the maximum size (in bytes) that the /dev/shm tmpfs can use.
-# If this is not set then the size defaults to the value of TMPFS_SIZE
-# if that is set; otherwise to the kernel's default.
+# Defaults for tmpfs filesystems mounted in early boot, before
+# filesystems from /etc/fstab are mounted.
 #
-# The size will be rounded down to a multiple of the page size, 4096 bytes.
+# _SIZE variables are the maximum size (in bytes) that tmpfs
+# filesystems can use.  The size will be rounded down to a multiple of
+# the page size, 4096 bytes.  If no size is set, TMPFS_SIZE will be
+# used as the default.
+
+# TMPFS_SIZE: maximum size for all tmpfs filesystems if no specific
+# size is provided.  If no value is provided here, the kernel default
+# will be used.
+TMPFS_SIZE=20%
+
+# RUN_SIZE: maximum size of /run (/var/run)
+#
+# Defaults to 10% core memory; the size required varies widely
+# depending upon the demands of the software being run; this heuristic
+# scales /run usage on system size.  Samba in particular has been seen
+# to use at least 50MiB in a large heavily used server.  Typical usage
+# is hundreds of KiB, maximum is tens of MiB.
+RUN_SIZE=10%
+
+# LOCK_SIZE: maximum size of /run/lock (/var/lock)
+#
+# Typical usage: tens of KiB; maximum hundreds of KiB.  Default of
+# 5MiB should ensure the limit is never reached.
+LOCK_SIZE=5242880 # 5MiB
+
+# SHM_SIZE: maximum size of /run/shm (/dev/shm)
+#
+# No default size; the size required varies widely depending upon the
+# demands of the software being run.
 SHM_SIZE=
+
+# TMP_SIZE: maximum size of /tmp
+#
+# No default size.
+TMP_SIZE=
+
+# RW_SIZE: maximum size of /lib/init/rw
+#
+# Note /lib/init/rw is deprecated and programs using is are migrating
+# to use /run.  It will be removed once all users have migrated to
+# /run.
+# Typical usage: tens of KiB.  Default of 5MiB should ensure the limit
+# is never reached.
+RW_SIZE=5242880 # 5 MiB
+

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/checkfs.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/checkfs.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/checkfs.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -19,7 +19,6 @@
 
 . /lib/lsb/init-functions
 . /lib/init/splash-functions-base
-. /lib/init/usplash-fsck-functions.sh
 . /lib/init/swap-functions.sh
 
 do_start () {
@@ -95,19 +94,10 @@
 		if [ "$VERBOSE" = no ]
 		then
 			log_action_begin_msg "Checking file systems"
-			if usplash_running; then
-			    PROGRESS_FILE=`mktemp` || exit 1
-			    set -m
-			    logsave -s $FSCK_LOGFILE fsck -C3 -R -A $fix $force $FSCKTYPES_OPT >/dev/console 2>&1 3>$PROGRESS_FILE &
-			    set +m
-			    usplash_progress "$PROGRESS_FILE"
-			    rm -f $PROGRESS_FILE
-			else
-			    splash_start_indefinite
-			    logsave -s $FSCK_LOGFILE fsck $spinner -R -A $fix $force $FSCKTYPES_OPT
-			    FSCKCODE=$?
-			    splash_stop_indefinite
-			fi
+			splash_start_indefinite
+			logsave -s $FSCK_LOGFILE fsck $spinner -R -A $fix $force $FSCKTYPES_OPT
+			FSCKCODE=$?
+			splash_stop_indefinite
 
 			if [ "$FSCKCODE" -gt 1 ]
 			then

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/checkroot.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/checkroot.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/checkroot.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -22,7 +22,6 @@
 . /lib/lsb/init-functions
 . /lib/init/mount-functions.sh
 . /lib/init/splash-functions-base
-. /lib/init/usplash-fsck-functions.sh
 
 do_start () {
 	#
@@ -35,64 +34,8 @@
 	KERNEL="$(uname -s)"
 	MACHINE="$(uname -m)"
 
-	#
-	# Read /etc/fstab, looking for:
-	# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the
-	# 	device node,
-	# 2) Swap that is on a md device or a file that may be on a md 
-	# 	device,
-	#
+	read_fstab
 
-	exec 9<&0 </etc/fstab
-
-	fstabroot=/dev/root
-	rootdev=none
-	roottype=none
-	rootopts=defaults
-	rootmode=rw
-	rootcheck=no
-	swap_on_lv=no
-	swap_on_file=no
-
-	while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK
-	do
-		case "$DEV" in
-		  ""|\#*)
-			continue;
-			;;
-		  /dev/mapper/*)
-			[ "$FSTYPE" = "swap" ] && swap_on_lv=yes
-			;;
-		  /dev/*)
-			;;
-		  LABEL=*|UUID=*)
-			if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
-			then
-				DEV="$(findfs "$DEV")"
-			fi
-			;;
-		  /*)
-			[ "$FSTYPE" = "swap" ] && swap_on_file=yes
-			;;
-		  *)
-			;;
-		esac
-		[ "$MTPT" != "/" ] && continue
-		rootdev="$DEV"
-		fstabroot="$DEV"
-		rootopts="$OPTS"
-		roottype="$FSTYPE"
-		( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && rootcheck=yes
-		( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && rootcheck=no
-		case "$OPTS" in
-		  ro|ro,*|*,ro|*,ro,*)
-			rootmode=ro
-			;;
-		esac
-	done
-
-	exec 0<&9 9<&-
-
 	#
 	# Activate the swap device(s) in /etc/fstab. This needs to be done
 	# before fsck, since fsck can be quite memory-hungry.
@@ -137,7 +80,7 @@
 	#
 	# Does the root device in /etc/fstab match with the actual device ?
 	# If not we try to use the /dev/root alias device, and if that
-	# fails we create a temporary node in /lib/init/rw.
+	# fails we create a temporary node in /run.
 	#
 	if [ "$rootcheck" = yes ]
 	then
@@ -150,11 +93,11 @@
 				rootdev=/dev/root
 			else
 				if \
-					rm -f /lib/init/rw/rootdev \
-					&& mknod -m 600 /lib/init/rw/rootdev b ${rdev%:*} ${rdev#*:} \
-					&& [ -e /lib/init/rw/rootdev ]
+					rm -f /run/rootdev \
+					&& mknod -m 600 /run/rootdev b ${rdev%:*} ${rdev#*:} \
+					&& [ -e /run/rootdev ]
 				then
-					rootdev=/lib/init/rw/rootdev
+					rootdev=/run/rootdev
 				else
 					rootfatal=yes
 				fi
@@ -169,7 +112,7 @@
 	then
 		log_failure_msg "The device node $rootdev for the root filesystem is missing or incorrect 
 or there is no entry for the root filesystem listed in /etc/fstab. 
-The system is also unable to create a temporary node in /lib/init/rw. 
+The system is also unable to create a temporary node in /run. 
 This means you have to fix the problem manually."
 		log_warning_msg "A maintenance shell will now be started. 
 CONTROL-D will terminate this shell and restart the system."
@@ -267,19 +210,10 @@
 		if [ "$VERBOSE" = no ]
 		then
 			log_action_begin_msg "Checking root file system"
-			if [ "$roottype" = "ext2" -o "$roottype" = "ext3" -o "$roottype" = "ext4" ] && usplash_running; then
-			    PROGRESS_FILE=`mktemp -p /lib/init/rw` || PROGRESS_FILE=/lib/init/rw/checkroot_fsck
-			    set -m
-			    logsave -s $FSCK_LOGFILE fsck -C3 $force $fix -t $roottype $rootdev >/dev/console 2>&1 3>$PROGRESS_FILE &
-			    set +m
-			    usplash_progress "$PROGRESS_FILE"
-			    rm -f $PROGRESS_FILE
-			else
-			    splash_start_indefinite
-			    logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -t $roottype $rootdev
-			    FSCKCODE=$?
-			    splash_stop_indefinite
-			fi
+			splash_start_indefinite
+			logsave -s $FSCK_LOGFILE fsck $spinner $force $fix -t $roottype $rootdev
+			FSCKCODE=$?
+			splash_stop_indefinite
 			if [ "$FSCKCODE" = 0 ]
 			then
 				log_action_end_msg 0
@@ -385,9 +319,9 @@
 	fi
 
 	#
-	# Remove /lib/init/rw/rootdev if we created it.
+	# Remove /run/rootdev if we created it.
 	#
-	rm -f /lib/init/rw/rootdev
+	rm -f /run/rootdev
 }
 
 do_status () {

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/mountdevsubfs.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/mountdevsubfs.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/mountdevsubfs.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -19,27 +19,34 @@
 TTYMODE=620
 [ -f /etc/default/devpts ] && . /etc/default/devpts
 
-TMPFS_SIZE=
-[ -f /etc/default/tmpfs ] && . /etc/default/tmpfs
-
 KERNEL="$(uname -s)"
 
+. /lib/init/vars.sh
+. /lib/init/tmpfs.sh
+
 . /lib/lsb/init-functions
 . /lib/init/mount-functions.sh
 
+
 do_start () {
 	#
-	# Mount a tmpfs on /dev/shm
+	# Mount a tmpfs on /run/shm
 	#
-	if [ ! -d /dev/shm ]
+	if [ ! -d /run/shm ]
 	then
-		mkdir --mode=755 /dev/shm
-		[ -x /sbin/restorecon ] && /sbin/restorecon /dev/shm
+		mkdir --mode=755 /run/shm
+		[ -x /sbin/restorecon ] && /sbin/restorecon /run/shm
 	fi
-	SHM_OPT=
-	[ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE"
-	domount tmpfs shmfs /dev/shm tmpfs -onosuid,nodev$SHM_OPT
 
+	if [ yes = "$RAMSHM" ] ; then
+		SHM_OPT=
+		[ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE"
+		[ "${SHM_MODE:=$TMPFS_MODE}" ] && SHM_OPT="$SHM_OPT,mode=$SHM_MODE"
+		domount tmpfs shmfs /run/shm tmpfs "-onosuid,nodev$SHM_OPT"
+	else
+		chmod 1777 /run/shm
+	fi
+
 	#
 	# Mount /dev/pts
 	#
@@ -50,7 +57,7 @@
 			mkdir --mode=755 /dev/pts
 			[ -x /sbin/restorecon ] && /sbin/restorecon /dev/pts
 		fi
-		domount devpts "" /dev/pts devpts -onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE
+		domount devpts "" /dev/pts devpts "-onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE"
 	fi
 }
 

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/mountkernfs.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/mountkernfs.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/mountkernfs.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -13,29 +13,85 @@
 
 PATH=/sbin:/bin
 . /lib/init/vars.sh
+. /lib/init/tmpfs.sh
 
 . /lib/lsb/init-functions
 . /lib/init/mount-functions.sh
 
-[ -f /etc/default/tmpfs ] && . /etc/default/tmpfs
+do_start () {
+	# Needed to determine if root is being mounted read-only.
+	read_fstab
 
-do_start () {
 	#
 	# Get some writable area available before the root is checked
 	# and remounted.
 	#
 	RW_OPT=
 	[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
-	domount tmpfs "" /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
+	[ "${RW_MODE:=$TMPFS_MODE}" ] && RW_OPT="$RW_OPT,mode=$RW_MODE"
+	domount tmpfs shmfs /lib/init/rw tmpfs "-onosuid$RW_OPT"
 	touch /lib/init/rw/.ramfs
 
+	RUN_OPT=
+	[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
+	[ "${RUN_MODE:=$TMPFS_MODE}" ] && RUN_OPT="$RUN_OPT,mode=$RUN_MODE"
+	domount tmpfs shmfs /run tmpfs "-onosuid$RUN_OPT"
+	touch /run/.ramfs
+
+	# Make lock directory as the replacement for /var/lock
+	mkdir --mode=755 /run/lock
+
+	# Mount /run/lock as tmpfs if enabled.  This prevents user DoS
+	# of /run by filling /run/lock at the expense of using an
+	# additional tmpfs.
+	if [ yes = "$RAMLOCK" ] ; then
+		LOCK_OPT=
+		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
+		[ "${LOCK_MODE:=$TMPFS_MODE}" ] && LOCK_OPT="$LOCK_OPT,mode=$LOCK_MODE"
+		domount tmpfs shmfs /run/lock tmpfs "-onodev,noexec,nosuid$LOCK_OPT"
+	else
+		chmod 1777 /run/lock
+	fi
+
+	touch /run/lock/.ramfs
+
+	# If /tmp is a symlink, make sure the linked-to directory exists.
+	if [ -L /tmp ] && [ ! -d /tmp ]; then
+		TMPPATH="$(readlink /tmp)"
+		mkdir -p --mode=755 "$TMPPATH"
+	fi
+
+	# If root is read only, default to mounting a tmpfs on /tmp,
+	# unless one is due to be mounted from fstab.
+	if [ rw != "$rootmode" ]; then
+		if will_mount /tmp ; then
+			:
+		else
+			RAMTMP="yes"
+		fi
+	fi
+
+	# Mount /tmp as tmpfs if enabled.
+	if [ yes = "$RAMTMP" ] ; then
+		TMP_OPT=
+		[ "${TMP_SIZE:=$TMPFS_SIZE}" ] && TMP_OPT=",size=$TMP_SIZE"
+		[ "${TMP_MODE:=$TMPFS_MODE}" ] && TMP_OPT="$TMP_OPT,mode=$TMP_MODE"
+		domount tmpfs shmfs /tmp tmpfs "-onodev,nosuid$TMP_OPT"
+	else
+		chmod 1777 /tmp
+	fi
+
 	# Make pidfile omit directory for sendsigs
-	mkdir /lib/init/rw/sendsigs.omit.d/
+	# Note: /run transition: Move from /lib/init/rw to /run.
+	# /lib/init/rw will be removed following transition of
+	# /lib/init/rw users to /run.
+	mkdir --mode=755 /lib/init/rw/sendsigs.omit.d/
+	mkdir --mode=755 /run/sendsigs.omit.d/
 
 	#
 	# Mount proc filesystem on /proc
 	#
-	domount proc "" /proc proc -onodev,noexec,nosuid
+	domount proc "" /proc proc "-onodev,noexec,nosuid"
 
 	#
 	# Mount sysfs on /sys
@@ -43,22 +99,8 @@
 	# Only mount sysfs if it is supported (kernel >= 2.6)
 	if grep -E -qs "sysfs\$" /proc/filesystems
 	then
-		domount sysfs "" /sys sysfs -onodev,noexec,nosuid
+		domount sysfs "" /sys sysfs "-onodev,noexec,nosuid"
 	fi
-
-	# Mount /var/run and /var/lock as tmpfs if enabled
-	if [ yes = "$RAMRUN" ] ; then
-		RUN_OPT=
-		[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
-		domount tmpfs "" /var/run varrun -omode=0755,nosuid$RUN_OPT
-		touch /var/run/.ramfs
-	fi
-	if [ yes = "$RAMLOCK" ] ; then
-		LOCK_OPT=
-		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
-		domount tmpfs "" /var/lock varlock -omode=1777,nodev,noexec,nosuid$LOCK_OPT
-		touch /var/lock/.ramfs
-	fi
 }
 
 case "$1" in

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/mtab.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/mtab.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/mtab.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -18,52 +18,124 @@
 
 PATH=/sbin:/bin
 . /lib/init/vars.sh
+. /lib/init/tmpfs.sh
 
 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
+# Note any changes here must also be made in domount in mount-functions.
+# $1: file system type
+# $2: alternative file system type (or empty string if none)
+# $3: mount point
+# $4: mount device name
+# $5... : extra mount program options
 domtab ()
 {
-	# Directory present?
-	if [ ! -d $2 ]
+	MTPT="$3"
+	KERNEL="$(uname -s)"
+	# Figure out filesystem type
+	FSTYPE=
+	OPTS=
+	if [ "$1" = proc ]
 	then
+		case "$KERNEL" in
+			Linux|GNU) FSTYPE=proc;;
+			*FreeBSD)  FSTYPE=linprocfs ;;
+			*)         FSTYPE=procfs ;;
+		esac
+	elif [ "$1" = bind ]
+	then
+		case "$KERNEL" in
+			Linux)     FSTYPE=$4; OPTS="-obind" ;;
+			*FreeBSD)  FSTYPE=nullfs ;;
+			GNU)       FSTYPE=firmlink ;;
+			*)         FSTYPE=none ;;
+		esac
+	elif [ "$1" = tmpfs ]
+	then # always accept tmpfs, to mount /run before /proc
+		case "$KERNEL" in
+			GNU)	FSTYPE=none ;; # for now
+			*)	FSTYPE=$1 ;;
+		esac
+	elif grep -E -qs "$1\$" /proc/filesystems
+	then
+		FSTYPE=$1
+	elif grep -E -qs "$2\$" /proc/filesystems
+	then
+		FSTYPE=$2
+	fi
+
+	if [ ! "$FSTYPE" ]
+	then
+		if [ "$2" ]
+		then
+			log_warning_msg "Filesystem types '$1' and '$2' are not supported. Skipping mount."
+		else
+			log_warning_msg "Filesystem type '$1' is not supported. Skipping mount."
+		fi
 		return
 	fi
 
-	# Not mounted?
-	if ! mountpoint -q $2 < /dev/null
+	# We give file system type as device name if not specified as
+	# an argument
+	if [ "$4" ] ; then
+	    DEVNAME=$4
+	else
+	    DEVNAME=$FSTYPE
+	fi
+
+	# Get the options from /etc/fstab.
+	if [ -f /etc/fstab ]
 	then
+		exec 9<&0 </etc/fstab
+
+		while read TAB_DEV TAB_MTPT TAB_FSTYPE TAB_OPTS TAB_REST
+		do
+			case "$TAB_DEV" in ""|\#*) continue ;; esac
+			[ "$MTPT" = "$TAB_MTPT" ] || continue
+			[ "$FSTYPE" = "$TAB_FSTYPE" ] || continue
+			case "$TAB_OPTS" in
+			  noauto|*,noauto|noauto,*|*,noauto,*)
+				exec 0<&9 9<&-
+				return
+				;;
+			  ?*)
+				OPTS="$OPTS -o$TAB_OPTS"
+				;;
+			esac
+			break
+		done
+
+		exec 0<&9 9<&-
+	fi
+
+	if [ ! -d "$MTPT" ]
+	then
 		return
 	fi
 
-	if [ -n "$3" ]
+	if ! mountpoint -q "$MTPT"
 	then
-		NAME="$3"
-	else
-		NAME="$1"
+		return # Not mounted
 	fi
 
 	# Already recorded?
-	if ! grep -E -sq "^([^ ]+) +$2 +" /etc/mtab < /dev/null
+	if ! grep -E -sq "^([^ ]+) +$MTPT +" /etc/mtab < /dev/null
 	then
-		mount -f -t $1 $OPTS $4 $NAME $2 < /dev/null
+		mount -f -t $FSTYPE $5 $OPTS $DEVNAME $MTPT < /dev/null
 	fi
 }
 
 do_start () {
+	# Needed to determine if root is being mounted read-only.
+	read_fstab
+
 	DO_MTAB=""
 	MTAB_PATH="$(readlink -f /etc/mtab || :)"
 	case "$MTAB_PATH" in
@@ -108,40 +180,58 @@
 	# S02mountkernfs.sh
 	RW_OPT=
 	[ "${RW_SIZE:=$TMPFS_SIZE}" ] && RW_OPT=",size=$RW_SIZE"
-	domtab tmpfs /lib/init/rw tmpfs -omode=0755,nosuid$RW_OPT
+	[ "${RW_MODE:=$TMPFS_MODE}" ] && RW_OPT="$RW_OPT,mode=$RW_MODE"
+	domtab tmpfs shmfs /lib/init/rw tmpfs "-onosuid$RW_OPT"
 
-	domtab proc /proc "proc" -onodev,noexec,nosuid
-	if grep -E -qs "sysfs\$" /proc/filesystems
-	then
-		domtab sysfs /sys sysfs -onodev,noexec,nosuid
-	fi
-	if [ yes = "$RAMRUN" ] ; then
-		RUN_OPT=
-		[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
-		domtab tmpfs /var/run "varrun" -omode=0755,nosuid$RUN_OPT
-	fi
+	RUN_OPT=
+	[ "${RUN_SIZE:=$TMPFS_SIZE}" ] && RUN_OPT=",size=$RUN_SIZE"
+	[ "${RUN_MODE:=$TMPFS_MODE}" ] && RUN_OPT="$RUN_OPT,mode=$RUN_MODE"
+	domtab tmpfs shmfs /run tmpfs "-onosuid$RUN_OPT"
+
 	if [ yes = "$RAMLOCK" ] ; then
 		LOCK_OPT=
 		[ "${LOCK_SIZE:=$TMPFS_SIZE}" ] && LOCK_OPT=",size=$LOCK_SIZE"
-		domtab tmpfs /var/lock "varlock" -omode=1777,nodev,noexec,nosuid$LOCK_OPT
+		[ "${LOCK_MODE:=$TMPFS_MODE}" ] && LOCK_OPT="$LOCK_OPT,mode=$LOCK_MODE"
+		domtab tmpfs shmfs /run/lock tmpfs "-onodev,noexec,nosuid$LOCK_OPT"
 	fi
+
+	if [ yes = "$RAMTMP" ] || [ rw != "$rootmode" ] ; then
+		TMP_OPT=
+		[ "${TMP_SIZE:=$TMPFS_SIZE}" ] && TMP_OPT=",size=$TMP_SIZE"
+		[ "${TMP_MODE:=$TMPFS_MODE}" ] && TMP_OPT="$TMP_OPT,mode=$TMP_MODE"
+		domtab tmpfs shmfs /tmp tmpfs "-onodev,nosuid$TMP_OPT"
+	fi
+
+	domtab proc "" /proc proc "-onodev,noexec,nosuid"
+
+	if grep -E -qs "sysfs\$" /proc/filesystems
+	then
+		domtab sysfs "" /sys sysfs "-onodev,noexec,nosuid"
+	fi
+
 	if [ -d /proc/bus/usb ]
 	then
-		domtab usbfs /proc/bus/usb "procbususb"
+		domtab usbfs "" /proc/bus/usb "procbususb"
 	fi
 
 	# S03udev
-	domtab tmpfs /dev "udev" -omode=0755
+	domtab tmpfs "" /dev "udev" "-omode=0755"
 
 	# S04mountdevsubfs
-	SHM_OPT=
-	[ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE"
-	domtab tmpfs /dev/shm tmpfs -onosuid,nodev$SHM_OPT
-	domtab devpts /dev/pts "devpts" -onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE
+	if [ yes = "$RAMSHM" ] ; then
+		SHM_OPT=
+		[ "${SHM_SIZE:=$TMPFS_SIZE}" ] && SHM_OPT=",size=$SHM_SIZE"
+		[ "${SHM_MODE:=$TMPFS_MODE}" ] && SHM_OPT="$SHM_OPT,mode=$SHM_MODE"
+		domtab tmpfs "" /dev/shm tmpfs "-onosuid,nodev$SHM_OPT"
+	fi
+	if [ "$KERNEL" = Linux ]
+	then
+		domtab devpts "" /dev/pts "devpts" "-onoexec,nosuid,gid=$TTYGRP,mode=$TTYMODE"
+	fi
 
 	# Add everything else in /proc/mounts into /etc/mtab, with
 	# special exceptions.
-	exec 9<&0 0</proc/mounts
+	exec 8<&0 0</proc/mounts
 	while read FDEV FDIR FTYPE FOPTS REST
 	do
 		case "$FDIR" in
@@ -155,9 +245,9 @@
 				continue
 				;;
 		esac
-		domtab "$FTYPE" "$FDIR" "$FDEV" "-o$FOPTS"
+		domtab "$FTYPE" "" "$FDIR" "$FDEV" "-o$FOPTS"
 	done
-	exec 0<&9 9<&-
+	exec 0<&8 8<&-
 }
 
 case "$1" in

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/sendsigs
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/sendsigs	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/sendsigs	2011-04-16 10:44:34 UTC (rev 1955)
@@ -27,9 +27,10 @@
 do_stop () {
 	OMITPIDS=
 
-	# The /var/run/sendsigs.omit file is used to be compatible
-	# with Ubuntu.
-	for omitfile in /var/run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
+	# Note: /run transition: Now using /run in place of /var/run;
+	# /lib/init/rw will be removed following transition of
+	# /lib/init/rw users to /run.
+	for omitfile in /run/sendsigs.omit /lib/init/rw/sendsigs.omit; do
 		if [ -e $omitfile ]; then
 			for pid in $(cat $omitfile); do
 				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
@@ -40,14 +41,20 @@
 	# Load sendsigs.omit.d/packagename files too, to make it
 	# possible for scripts that need to modify the list of pids at
 	# run time without race conditions.
-	if [ -d /lib/init/rw/sendsigs.omit.d/ ]; then
-		for pidfile in /lib/init/rw/sendsigs.omit.d/*; do
-			[ -f "$pidfile" ] || continue
-			for pid in $(cat $pidfile); do
-				OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+	# Note: /run transition: both /run and /lib/init/rw are used
+	# at present during the transition to /run; /lib/init/rw will
+	# be removed following transition of /lib/init/rw users to
+	# /run.
+	for omitdir in /run/sendsigs.omit.d /lib/init/rw/sendsigs.omit.d; do
+		if [ -d "${omitdir}" ]; then
+			for pidfile in "${omitdir}/"*; do
+				[ -f "$pidfile" ] || continue
+				for pid in $(cat $pidfile); do
+					OMITPIDS="${OMITPIDS:+$OMITPIDS }-o $pid"
+				done
 			done
-		done
-	fi
+		fi
+	done
 
 	# Upstart jobs have their own "stop on" clauses that sends
 	# SIGTERM/SIGKILL just like this, so if they're still running,

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/umountfs
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/umountfs	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/umountfs	2011-04-16 10:44:34 UTC (rev 1955)
@@ -27,19 +27,9 @@
 	do
 		echo "$PROTECTED_MOUNTS" | grep -qs "^$DEV $MTPT " && continue
 		case "$MTPT" in
-		  /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/dev/.static/dev|/proc/*|/sys|/sys/*|/lib/init/rw)
+		  /|/proc|/dev|/.dev|/dev/pts|/dev/shm|/dev/.static/dev|/proc/*|/sys|/sys/*|/run|/run/*|/lib/init/rw)
 			continue
 			;;
-		  /var/run)
-			if [ yes = "$RAMRUN" ] ; then
-				continue
-			fi
-			;;
-		  /var/lock)
-			if [ yes = "$RAMLOCK" ] ; then
-				continue
-			fi
-			;;
 		esac
 		case "$FSTYPE" in 
 		  proc|procfs|linprocfs|sysfs|usbfs|usbdevfs|devpts)

Modified: sysvinit/trunk/debian/src/initscripts/etc/init.d/umountnfs.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/etc/init.d/umountnfs.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/etc/init.d/umountnfs.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -36,7 +36,7 @@
 	halt -w
 
 	# Remove bootclean flag files (precaution against symlink attacks)
-	rm -f /tmp/.clean /var/lock/.clean /var/run/.clean
+	rm -f /tmp/.clean
 
 	#
 	# Make list of points to unmount in reverse order of their creation
@@ -48,19 +48,9 @@
 	while read -r DEV MTPT FSTYPE OPTS REST
 	do
 		case "$MTPT" in
-		  /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/lib/init/rw)
+		  /|/proc|/dev|/dev/pts|/dev/shm|/proc/*|/sys|/run|/run/*|/lib/init/rw)
 			continue
 			;;
-		  /var/run)
-			if [ yes = "$RAMRUN" ] ; then
-				continue
-			fi
-			;;
-		  /var/lock)
-			if [ yes = "$RAMLOCK" ] ; then
-				continue
-			fi
-			;;
 		esac
 		case "$FSTYPE" in
 		  nfs|nfs4|smbfs|ncp|ncpfs|cifs|coda|ocfs2|gfs)

Modified: sysvinit/trunk/debian/src/initscripts/lib/init/bootclean.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/lib/init/bootclean.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/lib/init/bootclean.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -2,7 +2,7 @@
 #
 # bootclean
 #
-# Clean /tmp.  Clean /var/run and /var/lock if not mounted as tmpfs
+# Clean /tmp.
 #
 # DO NOT RUN AFTER S:55bootmisc.sh and do not run this script directly
 # in runlevel S. Instead write an initscript to call it.
@@ -111,60 +111,12 @@
 	return 0
 }
 
-clean_lock() {
-	if [ yes = "$RAMLOCK" ] ; then
-	    return 0
-	fi
-
-	cd /var/lock || { log_failure_msg "bootclean: Could not cd to /var/lock." ; return 1 ; }
-
-	[ "$VERBOSE" = no ] || log_action_begin_msg "Cleaning /var/lock"
-	report_err()
-	{
-		if [ "$VERBOSE" = no ]
-		then
-			log_failure_msg "bootclean: Failure cleaning /var/lock."
-		else
-			log_action_end_msg 1 "bootclean: Failure cleaning /var/lock"
-		fi
-	}
-	find . ! -type d -delete \
-		|| { report_err ; return 1 ; }
-	[ "$VERBOSE" = no ] || log_action_end_msg 0
-	mkflagfile /var/lock/.clean || return 1
-	return 0
-}
-
-clean_run() {
-	if [ yes = "$RAMRUN" ] ; then
-	    return 0
-	fi
-
-	cd /var/run || { log_action_end_msg 1 "bootclean: Could not cd to /var/run." ; return 1 ; }
-
-	[ "$VERBOSE" = no ] || log_action_begin_msg "Cleaning /var/run"
-	report_err()
-	{
-		if [ "$VERBOSE" = no ]
-		then
-			log_failure_msg "bootclean: Failure cleaning /var/run."
-		else
-			log_action_end_msg 1 "bootclean: Failure cleaning /var/run"
-		fi
-	}
-	find . ! -xtype d ! -name utmp ! -name innd.pid -delete \
-		|| { report_err ; return 1 ; }
-	[ "$VERBOSE" = no ] || log_action_end_msg 0
-	mkflagfile /var/run/.clean || return 1
-	return 0
-}
-
 which find >/dev/null 2>&1 || exit 1
 log_begin_msg "Cleaning up temporary files..."
 
 # If there are flag files that have not been created by root
 # then remove them
-for D in /tmp /var/run /var/lock
+for D in /tmp
 do
 	if [ -f $D/.clean ]
 	then
@@ -180,11 +132,9 @@
 	fi
 done
 
-[ -f /tmp/.clean ] && [ -f /var/run/.clean ] && [ -f /var/lock/.clean ] && { log_end_msg 0 ; exit 0 ; }
+[ -f /tmp/.clean ] && { log_end_msg 0 ; exit 0 ; }
 
 ES=0
 [ -d /tmp ] && ! [ -f /tmp/.clean ] && { clean_tmp || ES=1 ; }
-[ -d /var/run ] && ! [ -f /var/run/.clean ] && { clean_run || ES=1 ; }
-[ -d /var/lock ] && ! [ -f /var/lock/.clean ] && { clean_lock || ES=1 ; }
 log_end_msg $ES
 exit $ES

Modified: sysvinit/trunk/debian/src/initscripts/lib/init/mount-functions.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/lib/init/mount-functions.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/lib/init/mount-functions.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -21,8 +21,87 @@
 	which selinuxenabled >/dev/null 2>&1 && selinuxenabled
 }
 
+# Read /etc/fstab, looking for:
+# 1) The root filesystem, resolving LABEL=*|UUID=* entries to the
+# 	device node,
+# 2) Swap that is on a md device or a file that may be on a md
+# 	device,
+read_fstab () {
+	exec 9<&0 </etc/fstab
 
+	fstabroot=/dev/root
+	rootdev=none
+	roottype=none
+	rootopts=defaults
+	rootmode=rw
+	rootcheck=no
+	swap_on_lv=no
+	swap_on_file=no
+
+	while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK
+	do
+		case "$DEV" in
+		  ""|\#*)
+			continue;
+			;;
+		  /dev/mapper/*)
+			[ "$FSTYPE" = "swap" ] && swap_on_lv=yes
+			;;
+		  /dev/*)
+			;;
+		  LABEL=*|UUID=*)
+			if [ "$MTPT" = "/" ] && [ -x /sbin/findfs ]
+			then
+				DEV="$(findfs "$DEV")"
+			fi
+			;;
+		  /*)
+			[ "$FSTYPE" = "swap" ] && swap_on_file=yes
+			;;
+		  *)
+			;;
+		esac
+		[ "$MTPT" != "/" ] && continue
+		rootdev="$DEV"
+		fstabroot="$DEV"
+		rootopts="$OPTS"
+		roottype="$FSTYPE"
+		( [ "$PASS" != 0 ] && [ "$PASS" != "" ]   ) && rootcheck=yes
+		( [ "$FSTYPE" = "nfs" ] || [ "$FSTYPE" = "nfs4" ] ) && rootcheck=no
+		case "$OPTS" in
+		  ro|ro,*|*,ro|*,ro,*)
+			rootmode=ro
+			;;
+		esac
+	done
+
+	exec 0<&9 9<&-
+}
+
+will_mount () {
+	exec 9<&0 </etc/fstab
+
+	found=1 # Not found
+
+	while read DEV MTPT FSTYPE OPTS DUMP PASS JUNK
+	do
+		case "$DEV" in
+		  ""|\#*)
+			continue;
+			;;
+		esac
+		if [ "$MTPT" = "$1" ]; then
+			found=0; # Found
+		fi
+	done
+
+	exec 0<&9 9<&-
+
+	return $found
+}
+
 # Called before mtab is writable to mount kernel and device file systems.
+# Note any changes here must also be made in domtab in mtab.sh.
 # $1: file system type
 # $2: alternative file system type (or empty string if none)
 # $3: mount point
@@ -33,6 +112,7 @@
 	KERNEL="$(uname -s)"
 	# Figure out filesystem type
 	FSTYPE=
+	OPTS=
 	if [ "$1" = proc ]
 	then
 		case "$KERNEL" in
@@ -40,9 +120,20 @@
 			*FreeBSD)  FSTYPE=linprocfs ;;
 			*)         FSTYPE=procfs ;;
 		esac
+	elif [ "$1" = bind ]
+	then
+		case "$KERNEL" in
+			Linux)     FSTYPE=$4; OPTS="-obind" ;;
+			*FreeBSD)  FSTYPE=nullfs ;;
+			GNU)       FSTYPE=firmlink ;;
+			*)         FSTYPE=none ;;
+		esac
 	elif [ "$1" = tmpfs ]
-	then # always accept tmpfs, to mount /lib/init/rw before /proc
-		FSTYPE=$1
+	then # always accept tmpfs, to mount /run before /proc
+		case "$KERNEL" in
+			GNU)	FSTYPE=none ;; # for now
+			*)	FSTYPE=$1 ;;
+		esac
 	elif grep -E -qs "$1\$" /proc/filesystems
 	then
 		FSTYPE=$1
@@ -71,14 +162,13 @@
 	fi
 
 	# Get the options from /etc/fstab.
-	OPTS=
 	if [ -f /etc/fstab ]
 	then
 		exec 9<&0 </etc/fstab
 
 		while read TAB_DEV TAB_MTPT TAB_FSTYPE TAB_OPTS TAB_REST
 		do
-			case "$TAB_DEV" in (""|\#*) continue ;; esac
+			case "$TAB_DEV" in ""|\#*) continue ;; esac
 			[ "$MTPT" = "$TAB_MTPT" ] || continue
 			[ "$FSTYPE" = "$TAB_FSTYPE" ] || continue
 			case "$TAB_OPTS" in
@@ -87,7 +177,7 @@
 				return
 				;;
 			  ?*)
-				OPTS="-o$TAB_OPTS"
+				OPTS="$OPTS -o$TAB_OPTS"
 				;;
 			esac
 			break
@@ -121,45 +211,85 @@
 #
 pre_mountall ()
 {
-	# We may end up mounting something over top of /var, either directly
-	# or because /var is a symlink to something that's mounted.  So keep
-	# copies of the /var/run and /var/lock mounts elsewhere on the root
-	# filesystem so they can be moved back.
-	if [ yes = "$RAMRUN" ] ; then
-		mkdir /lib/init/rw/var.run
-		mount -n --bind /var/run /lib/init/rw/var.run
-	fi
-	if [ yes = "$RAMLOCK" ] ; then
-		mkdir /lib/init/rw/var.lock
-		mount -n --bind /var/lock /lib/init/rw/var.lock
-	fi
+	# RAMRUN and RAMLOCK on /var/run and /var/lock are obsoleted by
+	# /run.  Note that while RAMRUN is no longer used (/run is always
+	# a tmpfs), RAMLOCK is still functional, but will cause a second
+	# tmpfs to be mounted on /run/lock.
+	:
 }
 
 #
-# Restore /var/run and /var/lock mountpoints if something was mounted
-# as /var/.  Avoid mounting them back over themselves if nothing was
-# mounted as /var/ by checking if /var/run/ and /var/lock/ are still
-# mount points.  Enabling RAMRUN and RAMLOCK while listing /var/run or
-# /var/lock in /etc/fstab is not supported.
+# Migrate a directory to /run and create compatibility symlink or bind
+# mount.
 #
-post_mountall ()
+run_migrate ()
 {
-	if [ yes = "$RAMRUN" ] ; then
-		[ -d /var/run ] || mkdir /var/run
-		if mountpoint -q /var/run ; then
-			umount /lib/init/rw/var.run
-		else
-			mount -n --move /lib/init/rw/var.run /var/run
+	OLD=$1
+	RUN=$2
+
+	KERNEL="$(uname -s)"
+	OPTS=""
+	case "$KERNEL" in
+		Linux)     FSTYPE=none OPTS="-orw -obind";;
+		*FreeBSD)  FSTYPE=nullfs OPTS="-orw" ;;
+		GNU)       FSTYPE=firmlink ;;
+		*)         FSTYPE=none ;;
+	esac
+
+	# If both directories are the same, we don't need to do
+	# anything further.
+	sold="$(/usr/bin/stat -L --format="%d %i" "$OLD")"
+	srun="$(/usr/bin/stat -L --format="%d %i" "$RUN")"
+	if [ "$sold" = "$srun" ]; then
+		return 0
+	fi
+
+	# Try to remove if a directory.  Note this is safe because the
+	# system is not yet fully up, and nothing is allowed to use
+	# them yet.  If the user explicitly mounted a filesystem here,
+	# it will be cleaned out, but this would happen later on when
+	# bootclean runs in any case.
+	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
+		rm -fr "$OLD" 2>/dev/null || true
+	fi
+
+	# If removal failed (directory still exists), set up bind mount.
+	if [ ! -L "$OLD" ] && [ -d "$OLD" ] ; then
+		if [ "$OLD" != "/tmp" ]; then
+			log_warning_msg "Filesystem mounted on $OLD; setting up compatibility bind mount."
+			log_warning_msg "Please remove this mount from /etc/fstab; it is no longer needed, and it is preventing completion of the transition to $RUN."
 		fi
-		rmdir /lib/init/rw/var.run
-	fi
-	if [ yes = "$RAMLOCK" ] ; then
-		[ -d /var/lock ] || mkdir /var/lock
-		if mountpoint -q /var/lock ; then
-			umount /lib/init/rw/var.lock
+		mount -t $FSTYPE "$RUN" "$OLD" $OPTS
+	else
+		# Create symlink if not already present.
+		if [ -L "$OLD" ] && [ "$(readlink "$OLD")" = "$RUN" ]; then
+			:
 		else
-			mount -n --move /lib/init/rw/var.lock /var/lock
+			ln -fs "$RUN" "$OLD"
 		fi
-		rmdir /lib/init/rw/var.lock
 	fi
+
+	return 0
 }
+
+#
+# For compatibility, create /var/run and /var/lock symlinks to /run
+# and /run/lock, respectively.
+#
+post_mountall ()
+{
+	# /var/run and /var/lock are now /run and /run/lock,
+	# respectively.  Cope with filesystems being deliberately
+	# mounted on /var/run and /var/lock.  We will create bind
+	# mounts from /run and /run/lock to /var/run and /var/lock if
+	# we can't remove the /var/run and /var/lock directories, or
+	# else simply create symlinks.  For example, in the case that
+	# the user has explicitly mounted filesystems on /var/run or
+	# /var/lock, we bind mount over the top of them.  Where no
+	# filesystems are mounted, we replace the directory with a
+	# symlink where possible.
+
+	run_migrate /var/run /run
+	run_migrate /var/lock /run/lock
+	run_migrate /dev/shm /run/shm
+}

Added: sysvinit/trunk/debian/src/initscripts/lib/init/tmpfs.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/lib/init/tmpfs.sh	                        (rev 0)
+++ sysvinit/trunk/debian/src/initscripts/lib/init/tmpfs.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -0,0 +1,32 @@
+#
+# Set tmpfs vars
+#
+
+# Set defaults for /etc/default/tmpfs, in case any options are
+# commented out which are needed for booting.  So that an empty or
+# outdated file missing newer options works correctly, set the default
+# values here.
+
+TMPFS_SIZE=20%
+TMPFS_MODE=755
+
+RUN_SIZE=10%
+RUN_MODE=755
+
+LOCK_SIZE=5242880 # 5MiB
+LOCK_MODE=1777
+
+SHM_SIZE=
+SHM_MODE=1777
+
+TMP_SIZE=
+TMP_MODE=1777
+
+RW_SIZE=5242880 # 5 MiB
+RW_MODE=755
+
+
+# Source conffile
+if [ -f /etc/default/tmpfs ]; then
+    . /etc/default/tmpfs
+fi

Deleted: sysvinit/trunk/debian/src/initscripts/lib/init/usplash-fsck-functions.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/lib/init/usplash-fsck-functions.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/lib/init/usplash-fsck-functions.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -1,178 +0,0 @@
-#
-# Functions for reporting fsck progress in usplash
-#
-# (C) 2008 Canonical Ltd.
-# Author: Martin Pitt <martin.pitt at ubuntu.com>
-#
-
-# convert a "pass cur max" progress triple from fsck to a progress percentage
-# based on calc_percent() from e2fsck
-fsck_progress_to_percent() {
-    if [ $1 = 1 ]; then
-        PERCENT=$(($2 * 70 / $3))
-    elif [ $1 = 2 ]; then
-        PERCENT=$(($2 * 20 / $3 + 70))
-    elif [ $1 = 3 ]; then
-        PERCENT=$(($2 * 2 / $3 + 90))
-    elif [ $1 = 4 ]; then
-        PERCENT=$(($2 * 3 / $3 + 92))
-    elif [ $1 = 5 ]; then
-        PERCENT=$(($2 * 5 / $3 + 95))
-    else
-        PERCENT=100
-    fi
-}
-
-# read current fsck status ($PASS, $CUR, $MAX) from file descriptor 4
-# this assumes that fsck was started in the background ($!)
-get_fsck_status()
-{
-        local a b c S
-
-        unset a
-        # only consider the last line
-        while true; do
-            PASS=$a
-            CUR=$b
-            MAX=$c
-            read a b c rest <&4
-            if [ -n "$PASS" ] && [ -z "$a" ]; then
-                break;
-            fi
-
-            # if we did not read anything, check if the process is still
-            # actually running, or just waiting to be reaped
-            if [ -z "$PASS" ] && [ -z "$a" ]; then
-                S=`ps -o state --no-headers -p $!` || break
-                [ "$S" != "Z" ] || break
-                # do not spin while waiting for fsck to start up
-                sleep 0.1
-            fi
-        done
-}
-
-# Set $NAME to a human readable description of which partitions are currently
-# being checked. Set $CLEAN if this is only a routine check on clean
-# partitions which can be skipped.
-get_checked_names ()
-{
-        local DEVS DUMP LABEL
-
-        FSCKPROCS=$(ps --no-headers -C 'fsck.ext2 fsck.ext3 fsck.ext4 fsck.ext4dev' -o pid,args | grep /dev)
-        DEVS=$(echo "$FSCKPROCS" | sed 's_^.*\(/dev/[^[:space:]]*\).*$_\1_')
-        FSCKPIDS=$(echo "$FSCKPROCS" | sed 's_^[[:space:]]*\([[:digit:]]\+\).*$_\1_')
-
-        if [ -z "$DEVS" ]; then
-            unset NAME
-            return 0
-        fi
-
-        CLEAN=1
-        unset NAME
-        for DEV in $DEVS; do
-            DUMP=$(dumpe2fs -h $DEV)
-            if ! echo "$DUMP" | grep -q 'state:[[:space:]]*clean$'; then
-                unset CLEAN
-            fi
-
-            LABEL=$(blkid $DEV | sed -rn '/LABEL="([^"]+)"/ { s/^.*LABEL="//; s/".*$//; p }')
-            [ -z "$NAME" ] || NAME="$NAME, "
-            if [ -n "$LABEL" ]; then
-                NAME="$NAME$LABEL ($DEV)"
-            else
-                NAME="$NAME$DEV"
-            fi
-        done
-}
-
-# Return true if usplash is active
-usplash_running() {
-    if pidof usplash ; then
-	return 0
-    else
-	return 1
-    fi
-}
-
-# Read fsck progress from file $1 and display progress in usplash.
-usplash_progress() {
-        exec 4<$1
-        unset CANCEL
-        ESCAPE=`/bin/echo -ne "\x1B"`
-        FIRST=1
-        PREVPERCENT=0
-
-        while true; do
-            sleep 0.5
-            get_fsck_status
-            [ -n "$PASS" ] || break
-
-            fsck_progress_to_percent "$PASS" "$CUR" "$MAX"
-
-            # check if fsck advanced to the next drive
-            if [ "$PREVPERCENT" -gt "$PERCENT" ]; then
-                if [ -n "$CANCEL" ]; then
-                    usplash_write "STATUS skip                                                        "
-                else
-                    usplash_write "STATUS                                                             "
-                fi
-                FIRST=1
-            fi
-            PREVPERCENT=$PERCENT
-
-            # lazy initialization of output and progress report on the first
-            # progress line that we receive; this avoids starting the output
-            # for clean or non-ext[234] partitions
-            if [ -n "$FIRST" ]; then
-                usplash_write "TIMEOUT 0"
-
-                # show which device is being checked
-                get_checked_names
-                [ -n "$NAME" ] || break
-
-                usplash_write "VERBOSE on"
-                if [ "$CLEAN" ]; then
-                    usplash_write "TEXT Routine check of drives: $NAME..."
-                    usplash_write "TEXT Press ESC to skip"
-                else
-                    usplash_write "TEXT Unclean shutdown, checking drives:"
-                    usplash_write "TEXT $NAME..."
-                fi
-
-                unset FIRST
-            fi
-
-            usplash_write "STATUS $PERCENT% (stage $PASS/5, $CUR/$MAX)                       "
-            echo "Checking drive $NAME: $PERCENT% (stage $PASS/5, $CUR/$MAX)" >/dev/console
-
-            # ESC interrupts check for clean drives
-            if [ -n "$CLEAN" ]; then
-                if FAIL_NO_USPLASH=1 usplash_write "INPUTCHAR"; then
-                    read ch < /dev/.initramfs/usplash_outfifo
-                    if [ "$ch" = "$ESCAPE" ]; then
-                        kill $FSCKPIDS
-                        CANCEL=1
-                        continue # there might be more drives, so do not break
-                    fi
-                fi
-            fi
-        done
-
-        if [ -n "$CANCEL" ]; then
-            usplash_write "STATUS skip                                                        "
-        else
-            usplash_write "STATUS                                                             "
-        fi
-        usplash_write "VERBOSE default"
-        usplash_write "TEXT Drive checks finished."
-        usplash_write "TIMEOUT 15"
-        wait %1 # to collect fsck's exit code
-        EXITCODE=$?
-        [ -n "$CANCEL" ] && FSCKCODE=0 || FSCKCODE=$EXITCODE
-        if [ "$FSCKCODE" -gt 1 ]; then
-            # non-correctable failure which requires sulogin: quit usplash and
-            # restore stdin/out/err
-            usplash_write "QUIT"
-            exec </dev/console >/dev/console 2>/dev/console
-        fi
-}

Modified: sysvinit/trunk/debian/src/initscripts/lib/init/vars.sh
===================================================================
--- sysvinit/trunk/debian/src/initscripts/lib/init/vars.sh	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/lib/init/vars.sh	2011-04-16 10:44:34 UTC (rev 1955)
@@ -2,6 +2,21 @@
 # Set rcS vars
 #
 
+# Because /etc/default/rcS isn't a conffile, it's never updated
+# automatically.  So that an empty or outdated file missing newer
+# options works correctly, set the default values here.
+TMPTIME=0
+SULOGIN=no
+DELAYLOGIN=no
+UTC=yes
+VERBOSE=no
+FSCKFIX=no
+RAMLOCK=yes
+RAMSHM=yes
+# Defaults to yes in /etc/defaults/rcS, so will be enabled for new
+# installs.
+RAMTMP=no
+
 # Source conffile
 if [ -f /etc/default/rcS ]; then
     . /etc/default/rcS

Modified: sysvinit/trunk/debian/src/initscripts/man/rcS.5
===================================================================
--- sysvinit/trunk/debian/src/initscripts/man/rcS.5	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/man/rcS.5	2011-04-16 10:44:34 UTC (rev 1955)
@@ -97,20 +97,36 @@
 This will tell fsck always to repair the file systems
 without asking for permission.
 
-.IP \fBRAMRUN\fP
-Make /var/run/ available as a ram file system (tmpfs).  Will also disable
-cleaning of /var/run/ during boot.  Set to 'yes' to enable, to 'no' to disable.
-The size of the tmpfs can be controlled using TMPFS_SIZE and RUN_SIZE in
-/etc/default/tmpfs.  Because of this, packages can not expect directories in /var/run
-to exist after boot.  Packages expecting this are buggy and need to be fixed.
-
 .IP \fBRAMLOCK\fP
-Make /var/lock/ available as a ram file system (tmpfs).  Will also disable
-cleaning of /var/lock/ during boot.  Set to 'yes' to enable, to 'no' to disable.
-The size of the tmpfs can be controlled using TMPFS_SIZE and LOCK_SIZE in
-/etc/default/tmpfs.  Because of this, packages can not expect directories in /var/lock
-to exist after boot.  Packages expecting this are buggy and need to be fixed.
+Make /run/lock/ available as a ram file system (tmpfs).  Set to 'yes'
+to enable, to 'no' to disable (defaults to yes).  The size of the
+tmpfs can be controlled using TMPFS_SIZE and LOCK_SIZE in
+/etc/default/tmpfs.  Note that irrespective of this setting /run/lock
+will be located on a tmpfs, either one mounted on /run/lock (if
+RAMLOCK=yes) or one mounted on /run (if RAMLOCK=no), and as a result
+the contents of /var/lock will always be lost on system reboot, and it
+it is no longer explicitly cleaned at boot.  Because of this, packages
+can not expect directories in /var/lock to exist after boot.  Packages
+expecting this are buggy and need to be fixed.  Note that /run/lock
+was previously /var/lock, and a compatibility symlink or bind mount
+will be created to allow the old path to continue to function.
 
+.IP \fBRAMSHM\fP
+Make /run/shm available as a ram file system (tmpfs).  Set to 'yes' to
+enable, to 'no' to disable (defaults to yes).  The size of the tmpfs
+can be controlled using TMPFS_SIZE and SHM_SIZE in /etc/default/tmpfs.
+Because of this, packages can not expect directories in /run/shm to
+exist after boot.  Note that /run/shm was previously /dev/shm, and a
+compatibility symlink or bind mount will be created to allow the old
+path to continue to function.
+
+.IP \fBRAMTMP\fP
+Make /tmp/ available as a ram file system (tmpfs).  Set to 'yes' to
+enable, to 'no' to disable (defaults to yes).  The size of the tmpfs
+can be controlled using TMPFS_SIZE and TMP_SIZE in /etc/default/tmpfs.
+Because of this, packages can not expect directories in /tmp to exist
+after boot.
+
 .IP \fBASYNCMOUNTNFS\fP
 Set this to 'no' to disable asynchronous mounting of network drives
 when the network interfaces are mounted, and instead do it only once when
@@ -119,7 +135,7 @@
 properly in such setup.
 
 .SH NOTE
-The \fBEDITMOTD\fP variable is no longer used.
+The \fBEDITMOTD\fP and \fBRAMRUN\fP variables are no longer used.
 
 .SH AUTHOR
 Miquel van Smoorenburg <miquels at cistron.nl>

Modified: sysvinit/trunk/debian/src/initscripts/share/default.rcS
===================================================================
--- sysvinit/trunk/debian/src/initscripts/share/default.rcS	2011-04-16 10:41:52 UTC (rev 1954)
+++ sysvinit/trunk/debian/src/initscripts/share/default.rcS	2011-04-16 10:44:34 UTC (rev 1955)
@@ -7,11 +7,30 @@
 #
 # This file belongs to the "initscripts" package.
 
+# delete files in /tmp during boot older than x days.
+# '0' means always, -1 or 'infinite' disables the feature
 TMPTIME=0
+
+# spawn sulogin during boot, continue normal boot if not used in 30 seconds
 SULOGIN=no
+
+# do not allow users to log in until the boot has completed
 DELAYLOGIN=no
+
+# assume that the BIOS clock is set to UTC time (recommended)
 UTC=yes
+
+# be more verbose during the boot process
 VERBOSE=no
+
+# automatically repair filesystems with inconsistencies during boot
 FSCKFIX=no
-RAMRUN=no
-RAMLOCK=no
+
+# mount /run/lock as a tmpfs (separately from /run)
+RAMLOCK=yes
+
+# mount /run/shm as a tmpfs (separately from /run)
+RAMSHM=yes
+
+# mount /tmp as a tmpfs
+RAMTMP=yes




More information about the Pkg-sysvinit-commits mailing list