From b0b379e77db79c372161a6aee5cc46f426f99df7 Mon Sep 17 00:00:00 2001 From: Chandan Babu R Date: Tue, 9 Mar 2021 10:31:13 +0530 Subject: [PATCH] common/xfs: Add a helper to get an inode fork's extent count This commit adds the helper _scratch_get_iext_count() which returns an inode fork's extent count. Reviewed-by: Allison Henderson Reviewed-by: Darrick J. Wong Signed-off-by: Chandan Babu R --- common/xfs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/common/xfs b/common/xfs index 4469f045..fff65667 100644 --- a/common/xfs +++ b/common/xfs @@ -975,6 +975,26 @@ _scratch_get_bmx_prefix() { return 1 } +_scratch_get_iext_count() +{ + local ino=$1 + local whichfork=$2 + local field="" + + case $whichfork in + "attr") + field=core.naextents + ;; + "data") + field=core.nextents + ;; + *) + return 1 + esac + + _scratch_xfs_get_metadata_field $field "inode $ino" +} + # # Ensures that we don't pass any mount options incompatible with XFS v4 # -- 2.39.5