File xfsprogs-repair-Fix-root-inode-s-parent-when-it-s-bogus-f.patch of Package xfsprogs.13989

From 77b3425e3bee68e92eabdd1d01bc26853acc22b9 Mon Sep 17 00:00:00 2001
From: Marco Benatto <mbenatto@redhat.com>
Date: Thu, 21 Jun 2018 19:46:24 -0500
Subject: [PATCH] xfs_repair: Fix root inode's parent when it's bogus for sf
 directory
Git-commit: 77b3425e3bee68e92eabdd1d01bc26853acc22b9
Patch-mainline: v4.17.0-rc1
References: bsc#1119063

Currently when root inode is in short-form and its parent ino
has an invalid value, process_sf_dir2() ends up not fixing it,
because if verify_inum() fails we never get to the next case which
would fix the root inode's parent pointer.

This behavior triggers the following assert on process_dir2():

   ASSERT((ino != mp->m_sb.sb_rootino && ino != *parent) ||
        (ino == mp->m_sb.sb_rootino &&
        (ino == *parent || need_root_dotdot == 1)));

This patch fixes this behavior by making sure we always properly
handle rootino parent pointer in process_sf_dir2()

Signed-off-by: Marco Benatto <mbenatto@redhat.com>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
Acked-by: Anthony Iliopoulos <ailiopoulos@suse.com>

---
 repair/dir2.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/repair/dir2.c b/repair/dir2.c
index e162d2b8..225f9266 100644
--- a/repair/dir2.c
+++ b/repair/dir2.c
@@ -495,8 +495,10 @@ _("corrected entry offsets in directory %" PRIu64 "\n"),
 
 	/*
 	 * if parent entry is bogus, null it out.  we'll fix it later .
+	 * If the validation fails for the root inode we fix it in
+	 * the next else case.
 	 */
-	if (verify_inum(mp, *parent))  {
+	if (verify_inum(mp, *parent) && ino != mp->m_sb.sb_rootino)  {
 
 		do_warn(
 _("bogus .. inode number (%" PRIu64 ") in directory inode %" PRIu64 ", "),
-- 
2.16.4

openSUSE Build Service is sponsored by