File kdump-use-last-entry-get-mountpoints.patch of Package kdump

From: Roberto Sassu <rsassu@suse.com>
Subject: Use the last mount entry in kdump_get_mountpoints()
References: bsc#951844
Patch-mainline: v0.8.16
Git-commit: 07e26e637e6c98bf977fa3d5f1ee0902ded8e100

When a mount point appears multiple times in /proc/mounts and/or
/etc/fstab, then the last occurence should be taken. This is
especially important to avoid including the rootfs entry (if
"/" is missing in /etc/fstab).

Signed-off-by: Roberto Sassu <rsassu@suse.com>
Acked-by: Petr Tesarik <ptesarik@suse.com>

---
 init/setup-kdump.functions |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

--- a/init/setup-kdump.functions
+++ b/init/setup-kdump.functions
@@ -378,7 +378,7 @@ function kdump_read_mounts()						   # {
     local proc_mounts=/proc/mounts
     test -e "$proc_mounts" || proc_mounts=
     sed -e 's/[ \t][ \t]*/\t/g;s/^\t//;/^$/d;/^#/d' \
-        /etc/fstab "$proc_mounts"
+        "$proc_mounts" /etc/fstab
 }									   # }}}
 
 #
@@ -454,14 +454,12 @@ function kdump_get_mountpoints()
     kdump_opts=( )
 
     while read device mountpoint filesystem opts dummy ; do
-	if [ "$mountpoint" = "/" -a \
-	     -z "$rootmnt" ] ; then
+	if [ "$mountpoint" = "/" ] ; then
 	    rootdev="$device"
 	    rootmnt="$mountpoint"
 	    rootfstype="$filesystem"
 	    rootopts="$opts"
-	elif [ "$mountpoint" = "/boot" -a \
-	       -z "$bootmnt" ] ; then
+	elif [ "$mountpoint" = "/boot" ] ; then
 	    bootdev="$device"
 	    bootmnt="$mountpoint"
 	    bootfstype="$filesystem"
@@ -474,7 +472,7 @@ function kdump_get_mountpoints()
             realpath="${kdump_Realpath[i]}"
             if [ "$protocol" = "file" -a \
 		"${realpath#$mountpoint}" != "$realpath" -a \
-		"${#mountpoint}" -gt "${#curmp[i]}" ] ; then
+		"${#mountpoint}" -ge "${#curmp[i]}" ] ; then
 		curmp[i]="$mountpoint"
 		mntdev[i]="$device"
 		mntfstype[i]="$filesystem"
openSUSE Build Service is sponsored by