On Tuesday 07 November 2006 11:56, Roy Marples wrote:
> A net benefit of this is that we would could remove around 60 lines of code
> which handle the moving of $svcdir to disk whilst the system is active
> (handles locking, timeouts, nice messages, etc)
Attached is the patch that does this and shows exactly what's involved here.
As you can see, the code that currently handles the locking, saving back to
disk, and stuff is very hairy. So this would be a good argument for the
$svcdir always on a ramdisk option.
Thanks
--
Roy Marples <[EMAIL PROTECTED]>
Gentoo/Linux/FreeBSD Developer (baselayout, networking)
Index: init.d/halt.sh
===================================================================
--- init.d/halt.sh (revision 2364)
+++ init.d/halt.sh (working copy)
@@ -119,6 +117,23 @@
stop_addon "${x}"
done
+# If $svcdir is still mounted, preserve it if we can
+if [[ -w ${svclib} ]] && [[ $'\n'$(get_mounts) =~ $'\n'${svcdir}\ ]] ; then
+ tar cpf "${svclib}/init.d.$$.tar" -C "${svcdir}" \
+ depcache deptree netdepcache netdeptree
+ if [[ -n $(fuser -m "${svcdir}" 2>/dev/null) ]] ; then
+ fuser -k -m "${svcdir}" &>/dev/null
+ sleep 2
+ fi
+ umount "${svcdir}" 2>/dev/null
+ rm -rf "${svcdir}"/*
+ # Pipe errors to /dev/null as we may have future timestamps
+ tar xpf "${svclib}/init.d.$$.tar" -C "${svcdir}" 2>/dev/null
+ rm -f "${svclib}/init.d.$$.tar"
+ ls -l ${svcdir}
+ read foo
+fi
+
# Remount the rest read-only
ebegin $"Remounting remaining filesystems readonly"
if [[ $(uname) == "Linux" ]] ; then
Index: sbin/runscript.sh
===================================================================
--- sbin/runscript.sh (revision 2365)
+++ sbin/runscript.sh (working copy)
@@ -12,15 +12,6 @@
# Common functions
[[ ${RC_GOT_FUNCTIONS} != "yes" ]] && . /sbin/functions.sh
-# Sleep until svcdir is unlocked
-while [[ -e ${svcdir}/.locked ]] ; do
- eerror "$0:" $"Sleeping while svcdir is locked"
- sleep 1
-done
-
-# Change dir to $svcdir so we lock it for fuser until we finish
-cd "${svcdir}"
-
# User must be root to run most script stuff (except status)
if [[ ${EUID} != "0" ]] && ! [[ $2 == "status" && $# -eq 2 ]] ; then
eerror "$0:" $"must be root to run init scripts"
Index: sbin/rc
===================================================================
--- sbin/rc (revision 2366)
+++ sbin/rc (working copy)
@@ -441,55 +441,6 @@
# Runlevel end, so clear stale fail list
rm -rf "${svcdir}/failed" &>/dev/null
-# If $svcdir is mounted in ram, save it back to disk and unmount
-# but only if $svclib is writeable.
-if [[ $'\n'$(get_mounts) =~ $'\n'${svcdir}\ && -w ${svclib} ]] ; then
- # Function to show the timeout message
- timeout=
- do_timeout() {
- if [[ -z ${timeout} ]] ; then
- timeout=60
- else
- [[ -n ${ENDCOL} ]] && echo -n $'\e[A'
- fi
-
- ewarn $"Waiting for services to finish, timeout in" \
- "${timeout}" $"seconds" " "
- sleep 1
- ((timeout--))
- [[ ${timeout} -gt 0 ]] && return 0
-
- eerror $"Timed out! Killing some services"
- echo
- fuser -k -m "${svcdir}"
- return 1
- }
-
- while [[ -n $(fuser -m "${svcdir}" 2>/dev/null) ]] ; do
- do_timeout || break
- done
- [[ ${timeout} -le 10 ]] && timeout=10
-
- # Lock svcdir
- touch "${svcdir}/.locked"
- # Wait for processes to finish
- while true ; do
- while [[ -n $(fuser -m "${svcdir}" 2>/dev/null) ]] ; do
- do_timeout || break
- done
- tar cpf "/tmp/init.d.$$.tar.bz2" -C "${svcdir}" .
- umount "${svcdir}" 2>/dev/null && break
- do_timeout
- done
- touch "${svcdir}/.locked"
- rm -rf "${svcdir}"/*
- # Pipe errors to /dev/null as we may have future timestamps
- tar xpf "/tmp/init.d.$$.tar.bz2" -C "${svcdir}" 2>/dev/null
- rm -f "${svcdir}/.locked" "/tmp/init.d.$$.tar.bz2"
-
- [[ $(uname) == "FreeBSD" ]] && mdconfig -d -u 0
-fi
-
# If we were in the boot runlevel, it is done now ...
if [[ -n ${BOOT} ]] ; then
unset BOOT