[PATCH 2/7] common/btrfs: Add a helper function to get the nodesize

Nirjhar Roy (IBM)
2025-07-29T06:23:41Z

Introduce a helper function to get the nodesize of the btrfs
filesystem.

Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
---
common/btrfs | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/common/btrfs b/common/btrfs
index 6a1095ff..2922eb8e 100644
--- a/common/btrfs
+++ b/common/btrfs
@@ -18,6 +18,15 @@ _btrfs_get_subvolid()
$BTRFS_UTIL_PROG subvolume list $mnt | grep -E "\s$name$" | $AWK_PROG '{ print $2 }'
}

+# returns the node size of the filesystem.
+# usage _get_btrfs_node_size <device_name>
+_get_btrfs_node_size()
+{
+ local dev=$1
+ $BTRFS_UTIL_PROG inspect-internal dump-super -f "$dev"\
+ | awk '/nodesize/ { print $2 }'
+}
+
# _require_btrfs_command <command> [<subcommand>| ]
# We check for btrfs and (optionally) features of the btrfs command
# This function support both subfunction like "inspect-internal dump-tree" and
--
2.34.1