File Index
Files and directories
Sign in
FILE

xattr.h

File preview with syntax highlighting.

linux-6.19.14/fs/erofs/xattr.h C
 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#ifdef CONFIG_EROFS_FS_XATTR
14extern const struct xattr_handler erofs_xattr_user_handler;
15extern const struct xattr_handler erofs_xattr_trusted_handler;
16extern const struct xattr_handler erofs_xattr_security_handler;
17
18static inline const char *erofs_xattr_prefix(unsigned int idx,
19					     struct dentry *dentry)
20{
21	const struct xattr_handler *handler = NULL;
22
23	static const struct xattr_handler * const xattr_handler_map[] = {
24		[EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
25#ifdef CONFIG_EROFS_FS_POSIX_ACL
26		[EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] = &nop_posix_acl_access,
27		[EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] = &nop_posix_acl_default,
28#endif
29		[EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler,
30#ifdef CONFIG_EROFS_FS_SECURITY
31		[EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler,
32#endif
33	};
34
35	if (idx && idx < ARRAY_SIZE(xattr_handler_map))
36		handler = xattr_handler_map[idx];
37
38	if (!xattr_handler_can_list(handler, dentry))
39		return NULL;
40
41	return xattr_prefix(handler);
42}
43
44extern const struct xattr_handler * const erofs_xattr_handlers[];
45
46int erofs_xattr_prefixes_init(struct super_block *sb);
47void erofs_xattr_prefixes_cleanup(struct super_block *sb);
48int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
49ssize_t erofs_listxattr(struct dentry *, char *, size_t);
50#else
51static inline int erofs_xattr_prefixes_init(struct super_block *sb) { return 0; }
52static inline void erofs_xattr_prefixes_cleanup(struct super_block *sb) {}
53static inline int erofs_getxattr(struct inode *inode, int index,
54				 const char *name, void *buffer,
55				 size_t buffer_size)
56{
57	return -EOPNOTSUPP;
58}
59
60#define erofs_listxattr (NULL)
61#define erofs_xattr_handlers (NULL)
62#endif	/* !CONFIG_EROFS_FS_XATTR */
63
64#ifdef CONFIG_EROFS_FS_POSIX_ACL
65struct posix_acl *erofs_get_acl(struct inode *inode, int type, bool rcu);
66#else
67#define erofs_get_acl	(NULL)
68#endif
69
70#endif
~/ Read-only file preview.