Blame SOURCES/0432-lsinitrd-Suppress-cat-write-error-Broken-pipe.patch

a0a3b4
From 84d845fc7d58946eadc4bf284c941ec52e26632d Mon Sep 17 00:00:00 2001
a0a3b4
From: HATAYAMA Daisuke <d.hatayama@jp.fujitsu.com>
a0a3b4
Date: Wed, 4 Nov 2015 11:31:10 +0900
a0a3b4
Subject: [PATCH] lsinitrd: Suppress "cat: write error: Broken pipe"
a0a3b4
a0a3b4
On systemd, SIGPIPE is ignored by default; see man 5 systemd.exec for
a0a3b4
IgnoreSIGPIPE=. As a result, lsinitrd.sh under a systemd service
a0a3b4
outputs "cat: write error: Broken pipe" in the processing of
a0a3b4
determining a compression format of a given initramfs file using cat
a0a3b4
command in the write part of a pipeline processing.
a0a3b4
a0a3b4
For example, this is a log message of kdump.service in RHEL7.1,
a0a3b4
a0a3b4
    -- Logs begin at Wed 2015-11-04 09:57:33 JST, end at Wed 2015-11-04 09:58:28 JST. --
a0a3b4
    Nov 04 09:57:33 localhost systemd[1]: Stopping Crash recovery kernel arming...
a0a3b4
    Nov 04 09:57:33 localhost kdumpctl[22545]: kexec: unloaded kdump kernel
a0a3b4
    Nov 04 09:57:33 localhost kdumpctl[22545]: Stopping kdump: [OK]
a0a3b4
    Nov 04 09:57:33 localhost systemd[1]: Starting Crash recovery kernel arming...
a0a3b4
    Nov 04 09:57:36 localhost kdumpctl[22553]: Detected change(s) in the following file(s):
a0a3b4
    Nov 04 09:57:36 localhost kdumpctl[22553]: /etc/kdump.conf
a0a3b4
    Nov 04 09:57:36 localhost kdumpctl[22553]: Rebuilding /boot/initramfs-3.10.0-229.el7.x86_64kdump.img
a0a3b4
    Nov 04 09:57:40 localhost dracut[24914]: Executing: /usr/sbin/dracut --hostonly --hostonly-cmdline -o "plymouth dash resume" -f /boot/initramfs-3.10.0-229.el7.x86_64kdump.img 3.10.0-229.el7.x86_64
a0a3b4
    ...<cut>...
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]: *** Creating image file done ***
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]: Image: /boot/initramfs-3.10.0-229.el7.x86_64kdump.img: 18M
a0a3b4
    Nov 04 09:58:12 localhost kdumpctl[22553]: cat: write error: Broken pipe
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]: ========================================================================
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]: Version: dracut-033-240.el7
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]:
a0a3b4
    Nov 04 09:58:12 localhost dracut[24914]: Arguments: --hostonly --hostonly-cmdline -o 'plymouth dash resume' -f
a0a3b4
    Nov 04 09:58:13 localhost dracut[24914]:
a0a3b4
    Nov 04 09:58:13 localhost dracut[24914]: dracut modules:
a0a3b4
    Nov 04 09:58:13 localhost dracut[24914]: bash
a0a3b4
a0a3b4
kdump.service builds and loads an initramfs for kdump kernel using
a0a3b4
kdumpctl command which uses dracut command and so lsinitrd command,
a0a3b4
too.
a0a3b4
a0a3b4
Although there's no actual harm except for the error message, there
a0a3b4
has been several inquiries from customers about this message so
a0a3b4
far. We should suppress this message to reduce needless
a0a3b4
communications.
a0a3b4
a0a3b4
To suppress the message, this commit cleans up the processing of
a0a3b4
reading the first 6 bytes of a given initramfs file without cat
a0a3b4
command.
a0a3b4
a0a3b4
(cherry picked from commit 3ce142861d88c357864d3a3bef7ec453826d737d)
a0a3b4
a0a3b4
Conflicts:
a0a3b4
	lsinitrd.sh
a0a3b4
---
a0a3b4
 lsinitrd.sh | 60 ++++++++++++++++++++++++++++--------------------------------
a0a3b4
 1 file changed, 28 insertions(+), 32 deletions(-)
a0a3b4
a0a3b4
diff --git a/lsinitrd.sh b/lsinitrd.sh
a0a3b4
index 88fe983..4103ee2 100755
a0a3b4
--- a/lsinitrd.sh
a0a3b4
+++ b/lsinitrd.sh
a0a3b4
@@ -171,39 +171,35 @@ case $bin in
a0a3b4
         ;;
a0a3b4
 esac
a0a3b4
 
a0a3b4
-
a0a3b4
-CAT=$({
a0a3b4
-        if [[ $SKIP ]]; then
a0a3b4
-            $SKIP "$image"
a0a3b4
+if [[ $SKIP ]] ; then
a0a3b4
+    bin="$($SKIP "$image" | { read -N 6 bin && echo "$bin" ; })"
a0a3b4
+else
a0a3b4
+    read -N 6 bin < "$image"
a0a3b4
+fi
a0a3b4
+case $bin in
a0a3b4
+    $'\x1f\x8b'*)
a0a3b4
+        CAT="zcat --"
a0a3b4
+        ;;
a0a3b4
+    BZh*)
a0a3b4
+        CAT="bzcat --"
a0a3b4
+        ;;
a0a3b4
+    $'\x71\xc7'*|070701)
a0a3b4
+        CAT="cat --"
a0a3b4
+        ;;
a0a3b4
+    $'\x02\x21'*)
a0a3b4
+        CAT="lz4 -d -c"
a0a3b4
+        ;;
a0a3b4
+    $'\x89'LZO$'\0'*)
a0a3b4
+        CAT="lzop -d -c"
a0a3b4
+        ;;
a0a3b4
+    *)
a0a3b4
+        if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
a0a3b4
+            CAT="xzcat --single-stream --"
a0a3b4
         else
a0a3b4
-            cat "$image"
a0a3b4
-        fi } | {
a0a3b4
-        read -N 6 bin
a0a3b4
-        case $bin in
a0a3b4
-            $'\x1f\x8b'*)
a0a3b4
-                echo "zcat --"
a0a3b4
-                ;;
a0a3b4
-            BZh*)
a0a3b4
-                echo "bzcat --"
a0a3b4
-                ;;
a0a3b4
-            $'\x71\xc7'*|070701)
a0a3b4
-                echo "cat --"
a0a3b4
-                ;;
a0a3b4
-            $'\x02\x21'*)
a0a3b4
-                echo "lz4 -d -c"
a0a3b4
-                ;;
a0a3b4
-            $'\x89'LZO$'\0'*)
a0a3b4
-                echo "lzop -d -c"
a0a3b4
-                ;;
a0a3b4
-            *)
a0a3b4
-                if echo "test"|xz|xzcat --single-stream >/dev/null 2>&1; then
a0a3b4
-                    echo "xzcat --single-stream --"
a0a3b4
-                else
a0a3b4
-                    echo "xzcat --"
a0a3b4
-                fi
a0a3b4
-                ;;
a0a3b4
-        esac
a0a3b4
-    })
a0a3b4
+            CAT="xzcat --"
a0a3b4
+        fi
a0a3b4
+        ;;
a0a3b4
+esac
a0a3b4
 
a0a3b4
 skipcpio()
a0a3b4
 {