#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2022 Red Hat, Inc. All Rights Reserved.
#
# FS QA Test No. 545
#
# Create a filesystem which contains an inode with a lower number
# than the root inode. Ensure that xfsdump/xfsrestore handles this.
#
. ./common/preamble
_begin_fstest auto quick dump prealloc

# Import common functions.
. ./common/dump

_require_xfs_io_command "falloc"
_require_scratch

# Create a filesystem which contains a fake root inode
inums=($(_scratch_xfs_create_fake_root))
root_inum=${inums[0]}
fake_inum=${inums[1]}

# Now try a dump and restore. Cribbed from xfs/068
_create_dumpdir_stress

echo -n "Before: " >> $seqres.full
_count_dumpdir_files | tee $tmp.before >> $seqres.full

# filter out the file count, it changes as fsstress adds new operations
_do_dump_restore | sed -e "/entries processed$/s/[0-9][0-9]*/NUM/g"

echo -n "After: " >> $seqres.full
_count_restoredir_files | tee $tmp.after >> $seqres.full
diff -u $tmp.before $tmp.after

# success, all done
status=0
exit
