File kdump-remount-sysroot-readwrite.patch of Package kdump.17334

From: Michal Suchanek <msuchanek@suse.de>
Date: Wed Jun 21 15:23:30 2017 +0200
Subject: Remount /sysroot readwrite when used for kdump
References: bsc#1034169
Upstream: v0.8.17
Git-commit: b3e40e6cb5794e441ddabf1de88f3729ebd0cc6f

When kdump is saved to / (ie /var is not separate filesystem) /kdump/mnt0 is
bind mount of readonly /sysroot. Due to mount bug "mount /kdump/mnt0 -o
remount,rw" does nothing.

Remount the device by hand with "mount none /kdump/mnt0 -o remount,rw" which
avoids the bug.

Based on patch by Neil Brown <nfbrown@suse.com>

Signed-off-by: Michal Suchanek <msuchanek@suse.de>

--- kdump-0.8.16/init/save_dump.sh~	2017-06-15 14:47:33.059006747 +0200
+++ kdump-0.8.16/init/save_dump.sh	2017-06-15 14:47:42.827155243 +0200
@@ -127,13 +127,38 @@
     check_for_device "$@"
 }
 
+function rw_fixup()
+{
+    # handle remounting existing readonly mounts readwrite
+    # mount -a works only for not yet mounted filesystems
+    # remounting bind mounts needs special incantation
+    while read dev mpt fs opt dummy ; do
+        case "$opt" in
+            *bind*)
+                if [ "$fs" = "none" ] && ! [ -w "$mpt" ]; then
+                    mount none "$mpt" -o remount,rw
+                fi
+                ;;
+            ro,* | *,ro,* | *,ro) ;;
+            *)
+                if ! [ -w "$mpt" ]; then
+                    mount "$mpt" -o remount,rw
+                fi
+                ;;
+        esac
+    done < /etc/fstab
+}
+
 #
 # Mounts all partitions listed in /etc/fstab.kdump
 function mount_all()
 {
     local ret=0
 
-    test -f /etc/fstab.kdump || return 0
+    if ! [ -f /etc/fstab.kdump ] ; then
+        rw_fixup
+        return 0
+    fi
 
     if [ -f /etc/fstab ] ; then
         mv /etc/fstab /etc/fstab.orig
@@ -143,6 +167,8 @@
     mount -a
     ret=$?
 
+    rw_fixup
+
     if [ -f /etc/fstab.orig ] ; then
         mv /etc/fstab.orig /etc/fstab
     else
openSUSE Build Service is sponsored by