Linux Audio

Check our new training course

Loading...
v6.8
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2017-2018 HUAWEI, Inc.
 4 *             https://www.huawei.com/
 5 */
 6#ifndef __EROFS_XATTR_H
 7#define __EROFS_XATTR_H
 8
 9#include "internal.h"
10#include <linux/posix_acl_xattr.h>
11#include <linux/xattr.h>
12
13/* Attribute not found */
14#define ENOATTR         ENODATA
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16#ifdef CONFIG_EROFS_FS_XATTR
17extern const struct xattr_handler erofs_xattr_user_handler;
18extern const struct xattr_handler erofs_xattr_trusted_handler;
19extern const struct xattr_handler erofs_xattr_security_handler;
20
21static inline const char *erofs_xattr_prefix(unsigned int idx,
22					     struct dentry *dentry)
23{
24	const struct xattr_handler *handler = NULL;
25
26	static const struct xattr_handler * const xattr_handler_map[] = {
27		[EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
28#ifdef CONFIG_EROFS_FS_POSIX_ACL
29		[EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
30		[EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
 
 
31#endif
32		[EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler,
33#ifdef CONFIG_EROFS_FS_SECURITY
34		[EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler,
35#endif
36	};
37
38	if (idx && idx < ARRAY_SIZE(xattr_handler_map))
39		handler = xattr_handler_map[idx];
40
41	if (!xattr_handler_can_list(handler, dentry))
42		return NULL;
43
44	return xattr_prefix(handler);
45}
46
47extern const struct xattr_handler * const erofs_xattr_handlers[];
48
49int erofs_xattr_prefixes_init(struct super_block *sb);
50void erofs_xattr_prefixes_cleanup(struct super_block *sb);
51int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
52ssize_t erofs_listxattr(struct dentry *, char *, size_t);
53#else
54static inline int erofs_xattr_prefixes_init(struct super_block *sb) { return 0; }
55static inline void erofs_xattr_prefixes_cleanup(struct super_block *sb) {}
56static inline int erofs_getxattr(struct inode *inode, int index,
57				 const char *name, void *buffer,
58				 size_t buffer_size)
59{
60	return -EOPNOTSUPP;
61}
62
63#define erofs_listxattr (NULL)
64#define erofs_xattr_handlers (NULL)
65#endif	/* !CONFIG_EROFS_FS_XATTR */
66
67#ifdef CONFIG_EROFS_FS_POSIX_ACL
68struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu);
69#else
70#define erofs_get_acl	(NULL)
71#endif
72
73#endif
v6.2
 1/* SPDX-License-Identifier: GPL-2.0-only */
 2/*
 3 * Copyright (C) 2017-2018 HUAWEI, Inc.
 4 *             https://www.huawei.com/
 5 */
 6#ifndef __EROFS_XATTR_H
 7#define __EROFS_XATTR_H
 8
 9#include "internal.h"
10#include <linux/posix_acl_xattr.h>
11#include <linux/xattr.h>
12
13/* Attribute not found */
14#define ENOATTR         ENODATA
15
16static inline unsigned int inlinexattr_header_size(struct inode *inode)
17{
18	return sizeof(struct erofs_xattr_ibody_header) +
19		sizeof(u32) * EROFS_I(inode)->xattr_shared_count;
20}
21
22static inline erofs_blk_t xattrblock_addr(struct erofs_sb_info *sbi,
23					  unsigned int xattr_id)
24{
25#ifdef CONFIG_EROFS_FS_XATTR
26	return sbi->xattr_blkaddr +
27		xattr_id * sizeof(__u32) / EROFS_BLKSIZ;
28#else
29	return 0;
30#endif
31}
32
33static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi,
34					     unsigned int xattr_id)
35{
36	return (xattr_id * sizeof(__u32)) % EROFS_BLKSIZ;
37}
38
39#ifdef CONFIG_EROFS_FS_XATTR
40extern const struct xattr_handler erofs_xattr_user_handler;
41extern const struct xattr_handler erofs_xattr_trusted_handler;
42extern const struct xattr_handler erofs_xattr_security_handler;
43
44static inline const struct xattr_handler *erofs_xattr_handler(unsigned int idx)
 
45{
46	static const struct xattr_handler *xattr_handler_map[] = {
 
 
47		[EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
48#ifdef CONFIG_EROFS_FS_POSIX_ACL
49		[EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] =
50			&posix_acl_access_xattr_handler,
51		[EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] =
52			&posix_acl_default_xattr_handler,
53#endif
54		[EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler,
55#ifdef CONFIG_EROFS_FS_SECURITY
56		[EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler,
57#endif
58	};
59
60	return idx && idx < ARRAY_SIZE(xattr_handler_map) ?
61		xattr_handler_map[idx] : NULL;
 
 
 
 
 
62}
63
64extern const struct xattr_handler *erofs_xattr_handlers[];
65
 
 
66int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
67ssize_t erofs_listxattr(struct dentry *, char *, size_t);
68#else
 
 
69static inline int erofs_getxattr(struct inode *inode, int index,
70				 const char *name, void *buffer,
71				 size_t buffer_size)
72{
73	return -EOPNOTSUPP;
74}
75
76#define erofs_listxattr (NULL)
77#define erofs_xattr_handlers (NULL)
78#endif	/* !CONFIG_EROFS_FS_XATTR */
79
80#ifdef CONFIG_EROFS_FS_POSIX_ACL
81struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu);
82#else
83#define erofs_get_acl	(NULL)
84#endif
85
86#endif