mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
common/rc: factor out _scratch_xfs_[get|set]_sb_field
It's common to get and set the values of fields in XFS super block, so factor them out as scratch_xfs_[get|set]_sb_field, reimplement them based on _scratch_xfs_[get|set]_metadata_field, and update the related test cases accordingly. Also move _scratch_xfs_[get|set]_metadata_field from common/fuzzy to common/xfs. Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Hou Tao <houtao1@huawei.com> Signed-off-by: Eryu Guan <eguan@redhat.com>
This commit is contained in:
@@ -126,39 +126,6 @@ _scratch_xfs_list_metadata_fields() {
|
||||
_scratch_xfs_db "${cmds[@]}" -c print | __filter_xfs_db_print_fields "${filter}"
|
||||
}
|
||||
|
||||
# Get a metadata field
|
||||
# The first arg is the field name
|
||||
# The rest of the arguments are xfs_db commands to find the metadata.
|
||||
_scratch_xfs_get_metadata_field() {
|
||||
key="$1"
|
||||
shift
|
||||
|
||||
grep_key="$(echo "${key}" | tr '[]()' '....')"
|
||||
local cmds=()
|
||||
for arg in "$@"; do
|
||||
cmds+=("-c" "${arg}")
|
||||
done
|
||||
_scratch_xfs_db "${cmds[@]}" -c "print ${key}" | grep "^${grep_key}" | \
|
||||
sed -e 's/^.* = //g'
|
||||
}
|
||||
|
||||
# Set a metadata field
|
||||
# The first arg is the field name
|
||||
# The second arg is the new value
|
||||
# The rest of the arguments are xfs_db commands to find the metadata.
|
||||
_scratch_xfs_set_metadata_field() {
|
||||
key="$1"
|
||||
value="$2"
|
||||
shift; shift
|
||||
|
||||
local cmds=()
|
||||
for arg in "$@"; do
|
||||
cmds+=("-c" "${arg}")
|
||||
done
|
||||
_scratch_xfs_db -x "${cmds[@]}" -c "write -d ${key} ${value}"
|
||||
echo
|
||||
}
|
||||
|
||||
# Fuzz a metadata field
|
||||
# The first arg is the field name
|
||||
# The second arg is the xfs_db fuzz verb
|
||||
|
||||
Reference in New Issue
Block a user