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

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