Blame 0020-resume-Fix-failure-when-invalid-device-passed-via-re.patch

Harald Hoyer 3957aa
From f65b874bda9f8b12d41c1f07826f584a8f5dcf6d Mon Sep 17 00:00:00 2001
Harald Hoyer 3957aa
From: Colin Guthrie <colin@mageia.org>
Harald Hoyer 3957aa
Date: Sat, 31 Dec 2011 13:30:58 +0000
Harald Hoyer 3957aa
Subject: [PATCH] resume: Fix failure when invalid device passed via 'resume='
Harald Hoyer 3957aa
Harald Hoyer 3957aa
This commit allows the waiting for a device to be cancelled.
Harald Hoyer 3957aa
When the resume partition does not exist, it becomes quite hard
Harald Hoyer 3957aa
to work out what to do (you have to either create the
Harald Hoyer 3957aa
/dev/resume symlink manually, or remove the 'finished' job
Harald Hoyer 3957aa
that is waiting for it). Additionally dracut incorrectly
Harald Hoyer 3957aa
displays a message about not being able to find the root
Harald Hoyer 3957aa
device, which is bogus and misleading.
Harald Hoyer 3957aa
Harald Hoyer 3957aa
This commit should just bail on the whole resume thing
Harald Hoyer 3957aa
if the device cannot be found and proceed with a normal boot.
Harald Hoyer 3957aa
---
Harald Hoyer 3957aa
 modules.d/95resume/resume-genrules.sh |    3 +++
Harald Hoyer 3957aa
 modules.d/99base/dracut-lib.sh        |    8 ++++++++
Harald Hoyer 3957aa
 2 files changed, 11 insertions(+), 0 deletions(-)
Harald Hoyer 3957aa
Harald Hoyer 3957aa
diff --git a/modules.d/95resume/resume-genrules.sh b/modules.d/95resume/resume-genrules.sh
Harald Hoyer 3957aa
index 16df877..ee4eacb 100755
Harald Hoyer 3957aa
--- a/modules.d/95resume/resume-genrules.sh
Harald Hoyer 3957aa
+++ b/modules.d/95resume/resume-genrules.sh
Harald Hoyer 3957aa
@@ -35,6 +35,9 @@ if [ -n "$resume" ]; then
Harald Hoyer 3957aa
     printf '[ -e "%s" ] && { ln -s "%s" /dev/resume; rm "$job"; }\n' \
Harald Hoyer 3957aa
         "$resume" "$resume" >> $hookdir/initqueue/settled/resume.sh
Harald Hoyer 3957aa
 
Harald Hoyer 3957aa
+    printf 'warn "Cancelling resume operation. Device not found."; cancel_wait_for_dev /dev/resume; rm "$job" "%s/initqueue/settled/resume.sh";' \
Harald Hoyer 3957aa
+        "$hookdir" >> $hookdir/initqueue/timeout/resume.sh
Harald Hoyer 3957aa
+
Harald Hoyer 3957aa
     wait_for_dev "/dev/resume"
Harald Hoyer 3957aa
 
Harald Hoyer 3957aa
 elif ! getarg noresume; then
Harald Hoyer 3957aa
diff --git a/modules.d/99base/dracut-lib.sh b/modules.d/99base/dracut-lib.sh
Harald Hoyer 3957aa
index 9eae4d9..b4fb435 100755
Harald Hoyer 3957aa
--- a/modules.d/99base/dracut-lib.sh
Harald Hoyer 3957aa
+++ b/modules.d/99base/dracut-lib.sh
Harald Hoyer 3957aa
@@ -717,6 +717,14 @@ wait_for_dev()
Harald Hoyer 3957aa
     } >> "$hookdir/emergency/80-${_name}.sh"
Harald Hoyer 3957aa
 }
Harald Hoyer 3957aa
 
Harald Hoyer 3957aa
+cancel_wait_for_dev()
Harald Hoyer 3957aa
+{
Harald Hoyer 3957aa
+    local _name
Harald Hoyer 3957aa
+    _name="$(str_replace "$1" '/' '\\x2f')"
Harald Hoyer 3957aa
+    rm -f "$hookdir/initqueue/finished/devexists-${_name}.sh"
Harald Hoyer 3957aa
+    rm -f "$hookdir/emergency/80-${_name}.sh"
Harald Hoyer 3957aa
+}
Harald Hoyer 3957aa
+
Harald Hoyer 3957aa
 killproc() {
Harald Hoyer 3957aa
     local _exe="$(command -v $1)"
Harald Hoyer 3957aa
     local _sig=$2