Hiyas, here is an updated patch that will work with the new module handling.
Regards, Till
diff -ru pm-utils-git-new/pm/functions pm-utils-git/pm/functions
--- pm-utils-git-new/pm/functions 2008-01-29 00:08:00.000000000 +0100
+++ pm-utils-git/pm/functions 2008-01-29 00:04:13.000000000 +0100
@@ -16,7 +16,10 @@
PM_LOGFILE=${PM_LOGFILE:=/var/log/pm-suspend.log}
SUSPEND_MODULES=""
TEMPORARY_CPUFREQ_GOVERNOR="performance"
-LOCKDIR="/tmp/.suspended"
+LOCK="/var/run/pm-utils/lock"
+STATEDIR="/var/run/pm-utils/state"
+SERVICEDIR="/var/run/pm-utils/service"
+MODULEDIR="/Var/run/pm-utils/modules"
# Use c sort order
export LC_COLLATE=C
@@ -37,14 +40,16 @@
source_configs
-take_suspend_lock()
# try to take the lock. Fail if we cannot get it.
try_lock()
{
- # $1 = directory to use as lock directory
- # we use directory creation because the kernel enforces atomicity,
- # and mkdir will fail if the directory already exists.
- mkdir "$1" >/dev/null 2>&1 || return 1
+ # $1 = file to use as lockfile
+ # $2 (optional) content to write to the lockfile,
+ # extra newline will be appended
+ # make sure the directory where the lockfile should be exists
+ mkdir -p ${1%/*}
+ # we use noclobber to make sure there are no race conditions
+ (set -o noclobber; echo "${2}" > "${1}") 2> /dev/null || return 1
return 0
}
@@ -52,7 +57,7 @@
# return once we have it, or the timeout has expired
spin_lock()
{
- # $1 = directory to use as the lock directory
+ # $1 = lockfile
# $2 = optional timeout
elapsed=$(($elapsed + 1))
local elapsed=0
@@ -65,28 +70,28 @@
# release the lock
release_lock()
{
- # $1 = directory used as the lock directory
+ # $1 = lockfile
# make sure it is ours first.
rm -rf "$1"
return $?
}
+take_suspend_lock()
{
VT=$(fgconsole)
chvt 63
- try_lock "$LOCKDIR" || return 1
- [ -d /var/run/pm-suspend ] && rm -rf /var/run/pm-suspend
- mkdir /var/run/pm-suspend
+ try_lock "$LOCK" || return 1
+ mkdir -p "${SERVICEDIR}" "${STATEDIR}" "${MODULEDIR}"
return 0
}
remove_suspend_lock()
{
- rm -rf /var/run/pm-suspend
+ rm -rf "${SERVICEDIR}" "${STATEDIR}" "${MODULEDIR}"
chvt 1
chvt $VT
- release_lock "${LOCKDIR}"
+ release_lock "${LOCK}"
}
find_hooks() {
@@ -188,7 +193,7 @@
_rmmod() {
if modprobe -r $1; then
- touch "/var/run/pm-suspend/module:$1"
+ touch "${MODULEDIR}/module:$1"
return 0
else
echo "# could not unload '$1', usage count was $2"
@@ -234,7 +239,7 @@
# reload all the modules in no particular order.
modreload()
{
- for x in /var/run/pm-suspend/module:* ; do
+ for x in ${MODULEDIR}/module:* ; do
[ -f "${x}" ] && modprobe "${x##*:}" >/dev/null 2>&1
done
}
@@ -253,22 +258,22 @@
stopservice()
{
if service "$1" status 2>/dev/null | grep -c -q running; then
- touch "/var/run/pm-suspend/service:$1"
+ touch "${SERVICEDIR}/service:$1"
service "$1" stop
fi
}
restartservice()
{
- [ -f "/var/run/pm-suspend/service:$1" ] && service "$1" start
+ [ -f "${SERVICEDIR}/service:$1" ] && service "$1" start
}
savestate()
{
- echo "$2" > "/var/run/pm-suspend/state:$1"
+ echo "$2" > "${STATEDIR}/state:$1"
}
restorestate()
{
- cat "/var/run/pm-suspend/state:${1}"
+ cat "${STATEDIR}/state:${1}"
}
diff -ru pm-utils-git-new/pm/sleep.d/90clock pm-utils-git/pm/sleep.d/90clock
--- pm-utils-git-new/pm/sleep.d/90clock 2008-01-29 00:08:00.000000000 +0100
+++ pm-utils-git/pm/sleep.d/90clock 2008-01-28 22:51:04.000000000 +0100
@@ -1,13 +1,11 @@
#!/bin/sh
. /usr/lib/pm-utils/functions
-NTPD_LOCK=/tmp/.pm-ntpd.lock
-release_ntpd_lock() {
- rmdir "${NTPD_LOCK}"
-}
+NTPD_LOCK="/var/run/pm-utils/pm-ntpd.lock"
+
suspend_clock() {
if try_lock "${NTPD_LOCK}"; then
- trap release_ntpd_lock 0
+ trap 'release_lock ${NTPD_LOCK}"' 0
stopservice ntpd
fi
/sbin/hwclock --systohc >/dev/null 2>&1 0<&1
@@ -19,7 +17,7 @@
rc=$?
# Bring back ntpd _after_ NetworkManager and such come back...
( spin_lock "${NTPD_LOCK}";
- trap release_ntpd_lock 0
+ trap 'release_lock "${NTPD_LOCK}"' 0
sleep 20;
restartservice ntpd; ) &
return $rc
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ Pm-utils mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/pm-utils
