#! /bin/bash
# SPDX-License-Identifier: GPL-2.0-or-later
# Copyright (c) 2022-2025 Oracle.  All Rights Reserved.
#
# FS QA Test No. 807
#
# Populate a XFS filesystem and fuzz every metadir root field.
# Use xfs_scrub to fix the corruption.

. ./common/preamble
_begin_fstest dangerous_fuzzers scrub fuzzers_online_repair realtime

_register_cleanup "_cleanup" BUS

. ./common/filter
. ./common/populate
. ./common/fuzzy

_require_xfs_scratch_metadir
_require_scratch_xfs_fuzz_fields
_disable_dmesg_check

echo "Format and populate"
_scratch_populate_cached nofill > $seqres.full 2>&1

inode_ver=$(_scratch_xfs_get_metadata_field "core.version" 'path -m /')

echo "Fuzz metadir root"
_scratch_xfs_fuzz_metadata '' 'online' 'path -m /' >> $seqres.full
echo "Done fuzzing metadir root"

# success, all done
status=0
exit
