[Pm-utils] [patch commit] POSIXification of pm-utils

Victor Lowther victor.lowther at gmail.com
Sat Jan 26 12:47:53 PST 2008


Attached patch against mainline GIT to posixify pm-utils.
Changes made:

        * Overall:
	Rewrote scripts to make them POSIX compliant.

	* pm/functions:
	Changed locking to use directories as locking primitives, because
	atomicity of directory creation is enforced by the kernel and mkdir
	will fail if a directory already exists.  I investigated using
	noclobber, but POSIX says to die on redirection failure instead of
	returning an error.

	Changed location of the main lock to reside in /tmp, so that it will
	be automatically cleaned on boot if suspend/resume fails.

	Genericised the hook-running infrastructure, modified pm-powersave
	to use it instead of implementing its own.

	Changed run_hooks to handle going forwards and backwards in one call
	When running hooks backwards, run_hooks automatically skips ones that
	failed running forwards. This allows hooks to signal that they do
	not need to run on resume by returning a non-zero exit status.

	Modified module load/unload, service stop/start, and save/restore
	state functions to avoid environment variable hackery and (more
	important) use of eval where not required.

	Simplified get_power_status -- on_ac_power never returns 255, so do
	not bother testing for it.
	
	In pm_main, moved unlocking into a trap 0 function so that it will be
	called no matter how the script exits.  Also modified pm_main to use
	the new auto-reversing run_hooks infrastructure.

	In modunload, got rid of gratuitous use of seq as well as numerous
	bashisms.

	Added LC_COLLATE=c so that our sort order will always be stable.

	* src/pm-action:
	Moved LC_COLLATE=c to pm/functions
	Replaced calls to basename with parameter expansion.

	* src/pm-powersave:
	Got rid of duplicate hook-running infrastructure

	* pm/sleep.d/zzz:
	New file that actually does the suspend/hibernate.

	* pm/sleep.d/49bluetooth:
	Don't save any state if we are not in a system where this applies.

	* pm/sleep.d/50modules:
	Don't use nonexistent RESUME_MODULES environment variable, just call
	the modreload function.

	* pm/sleep.d/90clock:
	Use new locking infrastructure.

	* pm/sleep.d/94cpufreq:
	Replace parsing of output of ls with globbing.
	Change fallback governor from "userspace" to "performance"

	* pm/sleep.d/99video:
	Get rid of redundant tests
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pm-utils-posix.diff
Type: text/x-patch
Size: 28894 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/pm-utils/attachments/20080126/aaa1ca05/attachment-0001.bin 


More information about the Pm-utils mailing list