1 /* SPDX-License-Identifier: GPL-2.0
3 * linux/drivers/staging/erofs/xattr.h
5 * Copyright (C) 2017-2018 HUAWEI, Inc.
6 * http://www.huawei.com/
7 * Created by Gao Xiang <gaoxiang25@huawei.com>
9 * This file is subject to the terms and conditions of the GNU General Public
10 * License. See the file COPYING in the main directory of the Linux
11 * distribution for more details.
13 #ifndef __EROFS_XATTR_H
14 #define __EROFS_XATTR_H
17 #include <linux/posix_acl_xattr.h>
18 #include <linux/xattr.h>
20 /* Attribute not found */
21 #define ENOATTR ENODATA
23 static inline unsigned inlinexattr_header_size(struct inode
*inode
)
25 return sizeof(struct erofs_xattr_ibody_header
)
26 + sizeof(u32
) * EROFS_V(inode
)->xattr_shared_count
;
29 static inline erofs_blk_t
30 xattrblock_addr(struct erofs_sb_info
*sbi
, unsigned xattr_id
)
32 #ifdef CONFIG_EROFS_FS_XATTR
33 return sbi
->xattr_blkaddr
+
34 xattr_id
* sizeof(__u32
) / EROFS_BLKSIZ
;
40 static inline unsigned
41 xattrblock_offset(struct erofs_sb_info
*sbi
, unsigned xattr_id
)
43 return (xattr_id
* sizeof(__u32
)) % EROFS_BLKSIZ
;
46 extern const struct xattr_handler erofs_xattr_user_handler
;
47 extern const struct xattr_handler erofs_xattr_trusted_handler
;
48 #ifdef CONFIG_EROFS_FS_SECURITY
49 extern const struct xattr_handler erofs_xattr_security_handler
;
52 static inline const struct xattr_handler
*erofs_xattr_handler(unsigned index
)
54 static const struct xattr_handler
*xattr_handler_map
[] = {
55 [EROFS_XATTR_INDEX_USER
] = &erofs_xattr_user_handler
,
56 #ifdef CONFIG_EROFS_FS_POSIX_ACL
57 [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS
] = &posix_acl_access_xattr_handler
,
58 [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT
] =
59 &posix_acl_default_xattr_handler
,
61 [EROFS_XATTR_INDEX_TRUSTED
] = &erofs_xattr_trusted_handler
,
62 #ifdef CONFIG_EROFS_FS_SECURITY
63 [EROFS_XATTR_INDEX_SECURITY
] = &erofs_xattr_security_handler
,
66 return index
&& index
< ARRAY_SIZE(xattr_handler_map
) ?
67 xattr_handler_map
[index
] : NULL
;
70 #ifdef CONFIG_EROFS_FS_XATTR
72 extern const struct inode_operations erofs_generic_xattr_iops
;
73 extern const struct inode_operations erofs_dir_xattr_iops
;
75 int erofs_getxattr(struct inode
*, int, const char *, void *, size_t);
76 ssize_t
erofs_listxattr(struct dentry
*, char *, size_t);
78 static int __maybe_unused
erofs_getxattr(struct inode
*inode
, int index
,
80 void *buffer
, size_t buffer_size
)
85 static ssize_t __maybe_unused
erofs_listxattr(struct dentry
*dentry
,
86 char *buffer
, size_t buffer_size
)