diff options
author | Christian Brauner <brauner@kernel.org> | 2023-02-01 14:14:52 +0100 |
---|---|---|
committer | Christian Brauner (Microsoft) <brauner@kernel.org> | 2023-03-06 09:57:07 +0100 |
commit | f2620f166e2a4db08f016b7b30b904ab28c265e4 (patch) | |
tree | 11a350c4f48ac673b05b1f3c4f5c14677575cf97 /fs/posix_acl.c | |
parent | fe15c26ee26efa11741a7b632e9f23b01aca4cc6 (diff) |
xattr: simplify listxattr helpers
The generic_listxattr() and simple_xattr_list() helpers list xattrs and
contain duplicated code. Add two helpers that both generic_listxattr()
and simple_xattr_list() can use.
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
Diffstat (limited to 'fs/posix_acl.c')
-rw-r--r-- | fs/posix_acl.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/fs/posix_acl.c b/fs/posix_acl.c index 5a76fb35923a..b350e8396adb 100644 --- a/fs/posix_acl.c +++ b/fs/posix_acl.c @@ -957,6 +957,31 @@ set_posix_acl(struct mnt_idmap *idmap, struct dentry *dentry, } EXPORT_SYMBOL(set_posix_acl); +int posix_acl_listxattr(struct inode *inode, char **buffer, + ssize_t *remaining_size) +{ + int err; + + if (!IS_POSIXACL(inode)) + return 0; + + if (inode->i_acl) { + err = xattr_list_one(buffer, remaining_size, + XATTR_NAME_POSIX_ACL_ACCESS); + if (err) + return err; + } + + if (inode->i_default_acl) { + err = xattr_list_one(buffer, remaining_size, + XATTR_NAME_POSIX_ACL_DEFAULT); + if (err) + return err; + } + + return 0; +} + static bool posix_acl_xattr_list(struct dentry *dentry) { |