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

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