diff mbox series

[20/24] fuzzy: dump metadata state before fuzzing

Message ID 167243878162.730387.16597687752166658725.stgit@magnolia (mailing list archive)
State New, archived
Headers show
Series [01/24] fuzzy: disable per-field random fuzzing by default | expand

Commit Message

Darrick J. Wong Dec. 30, 2022, 10:19 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

When we start a fuzz test, dump the metadata to stdout so that anyone
analyzing a failure can see what was in the (supposedly) good image, and
what it turns into after fuzzing.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 common/fuzzy |   12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/common/fuzzy b/common/fuzzy
index 3de6f43dc6..939f5e5ef2 100644
--- a/common/fuzzy
+++ b/common/fuzzy
@@ -110,6 +110,16 @@  __filter_xfs_db_print_fields() {
 	done | grep -E "${filter}" | __filter_unvalidated_xfs_db_fields
 }
 
+# Dump the current contents of a metadata object.
+# All arguments are xfs_db commands to locate the metadata.
+_scratch_xfs_dump_metadata() {
+	local cmds=()
+	for arg in "$@"; do
+		cmds+=("-c" "${arg}")
+	done
+	_scratch_xfs_db "${cmds[@]}" -c print
+}
+
 # Navigate to some part of the filesystem and print the field info.
 # The first argument is an grep filter for the fields
 # The rest of the arguments are xfs_db commands to locate the metadata.
@@ -534,6 +544,8 @@  _scratch_xfs_fuzz_metadata() {
 	echo $(echo "${fields}")
 	echo "Verbs we propose to fuzz with:"
 	echo $(echo "${verbs}")
+	echo "Current metadata object state:"
+	_scratch_xfs_dump_metadata "$@"
 
 	# Always capture full core dumps from crashing tools
 	ulimit -c unlimited