diff mbox series

[V6.1] common/xfs: Add helper to obtain fsxattr field value

Message ID 20210311085205.14881-1-chandanrlinux@gmail.com (mailing list archive)
State Accepted, archived
Headers show
Series [V6.1] common/xfs: Add helper to obtain fsxattr field value | expand

Commit Message

Chandan Babu R March 11, 2021, 8:52 a.m. UTC
This commit adds a helper function to obtain the value of a particular field
of an inode's fsxattr fields.

Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
V6 -> V6.1
1. Pass '-w' flag to grep to limit searches that match whole words.

 common/xfs | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Allison Henderson March 11, 2021, 6:36 p.m. UTC | #1
On 3/11/21 1:52 AM, Chandan Babu R wrote:
> This commit adds a helper function to obtain the value of a particular field
> of an inode's fsxattr fields.
> 
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
Ok, looks good!
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

> ---
> V6 -> V6.1
> 1. Pass '-w' flag to grep to limit searches that match whole words.
> 
>   common/xfs | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/common/xfs b/common/xfs
> index 26ae21b9..aec2cea6 100644
> --- a/common/xfs
> +++ b/common/xfs
> @@ -194,6 +194,15 @@ _xfs_get_file_block_size()
>   	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
>   }
>   
> +_xfs_get_fsxattr()
> +{
> +	local field="$1"
> +	local path="$2"
> +
> +	local value=$($XFS_IO_PROG -c "stat" "$path" | grep -w "$field")
> +	echo ${value##fsxattr.${field} = }
> +}
> +
>   # xfs_check script is planned to be deprecated. But, we want to
>   # be able to invoke "xfs_check" behavior in xfstests in order to
>   # maintain the current verification levels.
>
diff mbox series

Patch

diff --git a/common/xfs b/common/xfs
index 26ae21b9..aec2cea6 100644
--- a/common/xfs
+++ b/common/xfs
@@ -194,6 +194,15 @@  _xfs_get_file_block_size()
 	$XFS_INFO_PROG "$path" | grep realtime | sed -e 's/^.*extsz=\([0-9]*\).*$/\1/g'
 }
 
+_xfs_get_fsxattr()
+{
+	local field="$1"
+	local path="$2"
+
+	local value=$($XFS_IO_PROG -c "stat" "$path" | grep -w "$field")
+	echo ${value##fsxattr.${field} = }
+}
+
 # xfs_check script is planned to be deprecated. But, we want to
 # be able to invoke "xfs_check" behavior in xfstests in order to
 # maintain the current verification levels.