Package: yaird Version: 0.0.12-3.2 Followup-For: Bug #329319 Appended is a slightly updated patch: it deals better with 'resume=' options on the kernel command-line. Also, in answer to the question immediately previous: my patch does allow specifying a 'resume' option in /etc/fstab, in addition to or instead of specifying a kernel command-line option. The idea here is that (eventually) the 'resume' tag will be added by debian-installer at partition-creation time to the largest swap partition created, saving the end-user from having to muck around with kernel command-line arguments (which are an unintuitive place to specify partition properties). --scott
-- System Information: Debian Release: testing/unstable APT prefers unstable APT policy: (500, 'unstable'), (500, 'stable') Architecture: i386 (i686) Shell: /bin/sh linked to /bin/bash Kernel: Linux 2.6.15-1-686 Locale: LANG=en_US, LC_CTYPE=en_US (charmap=ISO-8859-1) Versions of packages yaird depends on: ii cpio 2.6-10 GNU cpio -- a program to manage ar ii dash 0.5.3-2 The Debian Almquist Shell ii libc6 2.3.5-12 GNU C Library: Shared libraries an ii libhtml-template-perl 2.8-1 HTML::Template : A module for usin ii libparse-recdescent-perl 1.94.free-1 Generates recursive-descent parser ii perl 5.8.7-10 Larry Wall's Practical Extraction yaird recommends no packages. -- no debconf information
diff -ruHp yaird-0.0.11-debpat/perl/Parser.pm yaird-0.0.11-mod2/perl/Parser.pm --- yaird-0.0.11-debpat/perl/Parser.pm 2005-12-09 13:58:20.000000000 -0500 +++ yaird-0.0.11-mod2/perl/Parser.pm 2005-12-09 17:20:51.000000000 -0500 @@ -311,6 +311,7 @@ goal_directive : | network_directive[fileName => $arg{fileName}] | module_directive[fileName => $arg{fileName}] | optional_module_directive[fileName => $arg{fileName}] + | resume_directive[fileName => $arg{fileName}] | mountdir_directive[fileName => $arg{fileName}] | mountdev_directive[fileName => $arg{fileName}] | <error> @@ -377,6 +378,19 @@ optional_module_directive: 'OPTIONAL' 'M } # + # Load modules for swap device, and attempt to resume from it + # +resume_directive : 'RESUME' <commit> pathname(?) + { + $return = { + type => 'resume', + value => @{$item{'pathname(?)'}}[0], + origin => "$arg{fileName}:$prevline", + }; + } + | <error: Invalid argument to resume directive> + + # # Mount the fs that fstab lists for pathname # mountdir_directive: 'MOUNTDIR' <commit> pathname mount_point diff -ruHp yaird-0.0.11-debpat/perl/Plan.pm yaird-0.0.11-mod2/perl/Plan.pm --- yaird-0.0.11-debpat/perl/Plan.pm 2005-12-09 13:58:20.000000000 -0500 +++ yaird-0.0.11-mod2/perl/Plan.pm 2005-12-09 17:35:31.000000000 -0500 @@ -623,6 +623,42 @@ sub addFsTabMount ($$$) { addBlockDevMount ($actions, $blockDevName, $mountPoint); } +# +# addResumePlan -- add list of actions to load modules necessary to +# access swap device (either given, or found from /etc/fstab), then +# (if a resume device was found or given) add a short script which +# will effect the resume-from-swap from the given device. +# +sub addResumePlan ($$) { + my ($actions, $swapDevName) = @_; + # treat optional parameter uniformly: '' is equivalent to undef. + $swapDevName=undef if $swapDevName eq '' || $swapDevName eq '--'; + if (! defined ($swapDevName)) { + # find resume-from-swap device in fstab; it will be the + # entry with <type>='swap' and <options> including 'resume' + for my $entry (@{FsTab::all()}) { + if ($entry->type eq 'swap' && + $entry->opts->exists('resume')) { + if (defined ($swapDevName)) { + Base::fatal("duplicate resume-swap entries in fstab."); + } + $swapDevName = $entry->dev; + } + } + } + if (defined ($swapDevName)) { + # device must be in /dev, to determine whether + # it's raid, lvm, scsi or whatever. + my $abd = ActiveBlockDevTab::findByPath($swapDevName); + if (! defined ($abd)) { + Base::fatal ("swap block device '$swapDevName' unavailable"); + } + addDevicePlan ($actions, $abd, []); + # now add script which will do the resume from this device. + $actions->add ("resume", $swapDevName, + devno => $abd->devno); + } +} # # makePlan -- given list of goals read from config file, @@ -652,6 +688,9 @@ sub makePlan ($) { elsif ($type eq 'network') { addNetworkPlan ($actions); } + elsif ($type eq 'resume') { + addResumePlan ($actions, $value); + } elsif ($type eq 'mountdir') { my $mountPoint = $goal->{mountPoint}; Base::assert (defined ($mountPoint)); diff -ruHp yaird-0.0.11-debpat/templates/Default.cfg.in yaird-0.0.11-mod2/templates/Default.cfg.in --- yaird-0.0.11-debpat/templates/Default.cfg.in 2005-12-09 13:58:20.000000000 -0500 +++ yaird-0.0.11-mod2/templates/Default.cfg.in 2005-12-09 14:13:27.000000000 -0500 @@ -129,6 +129,20 @@ CONFIG # TEMPLATE nfsstart # + # RESUME -- handle resume-from-swap (swsusp or suspend2). + # + # This will ensure that all modules required to access the + # resume device (a swap device with the 'resume' option + # specified in /etc/fstab) are loaded, and then will attempt + # to perform a resume. This does nothing if we didn't + # just perform a suspend-to-disk. + # + # You can override the swap partition to resume from by + # providing an optional parameter, ie: + # RESUME "/dev/hda5" + RESUME + + # # MOUNTDIR -- Given a directory name that occurs in # fstab, eg "/", insert all modules needed to access # the underlying block device and file system type, diff -ruHp yaird-0.0.12/templates.old/Debian.cfg yaird-0.0.12/templates/Debian.cfg --- yaird-0.0.12/templates.old/Debian.cfg 2006-01-19 21:41:03.000000000 -0500 +++ yaird-0.0.12/templates/Debian.cfg 2006-01-19 21:46:42.000000000 -0500 @@ -167,7 +167,11 @@ TEMPLATE SET !# ro,rw - mount root read-only or read-write. !# This is like a mount -r; it overrules !# a -o rw. - !# noresume, resume - to be done + !# noresume, resume= - should we resume from a + !# suspend-to-disk? The resume parameter + !# is optional, but overrides automatic + !# detection of the resume partition if present. + !# noresume prevents us from attempting to resume. !# ide - options for module ide_core. !# need a way to append these to proper !# module. do a check on module name @@ -177,6 +181,9 @@ TEMPLATE SET !ro=-r !ip= !nfsroot= + !noresume= + !resume= + !resume2= !init=/sbin/init !for i in $(cat /proc/cmdline) !do @@ -196,6 +203,15 @@ TEMPLATE SET ! nfsroot=*) ! nfsroot="$i" ! ;; + ! noresume) + ! noresume=1 + ! ;; + ! resume=*) + ! resume=${i#resume=} + ! ;; + ! resume2=*) + ! resume2=${i#resume2=} + ! ;; ! ydebug) ! INIT_DEBUG=yes ! esac @@ -368,6 +384,40 @@ TEMPLATE SET # + # Do a resume from swap, unless 'noresume' is on the command-line. + # + TEMPLATE resume + BEGIN + SCRIPT "/init" + BEGIN + !if [ -z "$noresume" ] + !then + ! # for suspend2 + ! # XXX: untested! + ! if [ -w /proc/software_suspend/do_resume ]; then + ! echo > /proc/software_suspend/do_resume + ! fi + ! # for swsusp + ! if [ -n "$resume" ] + ! then + ! case "$resume" in + ! [0-9]*:[0-9]*) + ! echo "$resume" > /sys/power/resume + ! ;; + ! *[a-z]*[0-9]) + ! cat /sys/block/*/${resume#/dev/}/dev > \ + ! /sys/power/resume + ! ;; + ! esac + ! else + ! echo <TMPL_VAR NAME=devno> > /sys/power/resume + ! fi + !fi + END SCRIPT + END TEMPLATE + + + # # NOTE: honouring the kernel cmdline option ro,rw # is very nice, but... If you have an ext3 in a # file loopback-mounted from vfat, it's unlikely diff -ruHp yaird-0.0.12/templates.old/Fedora.cfg yaird-0.0.12/templates/Fedora.cfg --- yaird-0.0.12/templates.old/Fedora.cfg 2006-01-19 21:41:03.000000000 -0500 +++ yaird-0.0.12/templates/Fedora.cfg 2006-01-19 21:46:23.000000000 -0500 @@ -182,7 +182,11 @@ TEMPLATE SET !# ro,rw - mount root read-only or read-write. !# This is like a mount -r; it overrules !# a -o rw. - !# noresume, resume - to be done + !# noresume, resume= - should we resume from a + !# suspend-to-disk? The resume parameter + !# is optional, but overrides automatic + !# detection of the resume partition if present. + !# noresume prevents us from attempting to resume. !# ide - options for module ide_core. !# need a way to append these to proper !# module. do a check on module name @@ -192,6 +196,9 @@ TEMPLATE SET !ro=-r !ip= !nfsroot= + !noresume= + !resume= + !resume2= !init=/sbin/init !for i in $(cat /proc/cmdline) !do @@ -211,6 +218,15 @@ TEMPLATE SET ! nfsroot=*) ! nfsroot="$i" ! ;; + ! noresume) + ! noresume=1 + ! ;; + ! resume=*) + ! resume=${i#resume=} + ! ;; + ! resume2=*) + ! resume2=${i#resume2=} + ! ;; ! ydebug) ! INIT_DEBUG=yes ! esac @@ -379,6 +395,40 @@ TEMPLATE SET # + # Do a resume from swap, unless 'noresume' is on the command-line. + # + TEMPLATE resume + BEGIN + SCRIPT "/init" + BEGIN + !if [ -z "$noresume" ] + !then + ! # for suspend2 + ! # XXX: untested! + ! if [ -w /proc/software_suspend/do_resume ]; then + ! echo > /proc/software_suspend/do_resume + ! fi + ! # for swsusp + ! if [ -n "$resume" ] + ! then + ! case "$resume" in + ! [0-9]*:[0-9]*) + ! echo "$resume" > /sys/power/resume + ! ;; + ! *[a-z]*[0-9]) + ! cat /sys/block/*/${resume#/dev/}/dev > \ + ! /sys/power/resume + ! ;; + ! esac + ! else + ! echo <TMPL_VAR NAME=devno> > /sys/power/resume + ! fi + !fi + END SCRIPT + END TEMPLATE + + + # # NOTE: honouring the kernel cmdline option ro,rw # is very nice, but... If you have an ext3 in a # file loopback-mounted from vfat, it's unlikely