29b24f6ca112d drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:31 +0800 1) /* SPDX-License-Identifier: GPL-2.0-only */
29b24f6ca112d drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:31 +0800 2) /*
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 3) * Copyright (C) 2017-2018 HUAWEI, Inc.
592e7cd00bb9d fs/erofs/xattr.h (Alexander A. Klimov 2020-07-13 15:09:44 +0200 4) * https://www.huawei.com/
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 5) * Created by Gao Xiang <gaoxiang25@huawei.com>
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 6) */
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 7) #ifndef __EROFS_XATTR_H
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 8) #define __EROFS_XATTR_H
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 9)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 10) #include "internal.h"
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 11) #include <linux/posix_acl_xattr.h>
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 12) #include <linux/xattr.h>
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 13)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 14) /* Attribute not found */
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 15) #define ENOATTR ENODATA
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 16)
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 17) static inline unsigned int inlinexattr_header_size(struct inode *inode)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 18) {
a5876e24f13f1 fs/erofs/xattr.h (Gao Xiang 2019-09-04 10:08:56 +0800 19) return sizeof(struct erofs_xattr_ibody_header) +
a5876e24f13f1 fs/erofs/xattr.h (Gao Xiang 2019-09-04 10:08:56 +0800 20) sizeof(u32) * EROFS_I(inode)->xattr_shared_count;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 21) }
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 22)
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 23) static inline erofs_blk_t xattrblock_addr(struct erofs_sb_info *sbi,
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 24) unsigned int xattr_id)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 25) {
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 26) #ifdef CONFIG_EROFS_FS_XATTR
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 27) return sbi->xattr_blkaddr +
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 28) xattr_id * sizeof(__u32) / EROFS_BLKSIZ;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 29) #else
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 30) return 0;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 31) #endif
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 32) }
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 33)
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 34) static inline unsigned int xattrblock_offset(struct erofs_sb_info *sbi,
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 35) unsigned int xattr_id)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 36) {
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 37) return (xattr_id * sizeof(__u32)) % EROFS_BLKSIZ;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 38) }
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 39)
5734fa217f27b drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:33 +0800 40) #ifdef CONFIG_EROFS_FS_XATTR
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 41) extern const struct xattr_handler erofs_xattr_user_handler;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 42) extern const struct xattr_handler erofs_xattr_trusted_handler;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 43) #ifdef CONFIG_EROFS_FS_SECURITY
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 44) extern const struct xattr_handler erofs_xattr_security_handler;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 45) #endif
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 46)
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 47) static inline const struct xattr_handler *erofs_xattr_handler(unsigned int idx)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 48) {
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 49) static const struct xattr_handler *xattr_handler_map[] = {
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 50) [EROFS_XATTR_INDEX_USER] = &erofs_xattr_user_handler,
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 51) #ifdef CONFIG_EROFS_FS_POSIX_ACL
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 52) [EROFS_XATTR_INDEX_POSIX_ACL_ACCESS] =
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 53) &posix_acl_access_xattr_handler,
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 54) [EROFS_XATTR_INDEX_POSIX_ACL_DEFAULT] =
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 55) &posix_acl_default_xattr_handler,
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 56) #endif
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 57) [EROFS_XATTR_INDEX_TRUSTED] = &erofs_xattr_trusted_handler,
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 58) #ifdef CONFIG_EROFS_FS_SECURITY
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 59) [EROFS_XATTR_INDEX_SECURITY] = &erofs_xattr_security_handler,
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 60) #endif
a55861c800ae0 fs/erofs/xattr.h (Vladimir Zapolskiy 2020-01-02 14:02:32 +0200 61) };
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 62)
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 63) return idx && idx < ARRAY_SIZE(xattr_handler_map) ?
e82a9a17d49c5 drivers/staging/erofs/xattr.h (Pratik Shinde 2019-07-15 17:51:27 +0530 64) xattr_handler_map[idx] : NULL;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 65) }
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 66)
6af7b4830569a drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-14 19:40:25 +0800 67) extern const struct xattr_handler *erofs_xattr_handlers[];
6af7b4830569a drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-14 19:40:25 +0800 68)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 69) int erofs_getxattr(struct inode *, int, const char *, void *, size_t);
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 70) ssize_t erofs_listxattr(struct dentry *, char *, size_t);
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 71) #else
5734fa217f27b drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:33 +0800 72) static inline int erofs_getxattr(struct inode *inode, int index,
5734fa217f27b drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:33 +0800 73) const char *name, void *buffer,
5734fa217f27b drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:33 +0800 74) size_t buffer_size)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 75) {
ff784a78af117 drivers/staging/erofs/xattr.h (Gao Xiang 2019-08-14 18:37:05 +0800 76) return -EOPNOTSUPP;
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 77) }
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 78)
e7cda1ee94f46 fs/erofs/xattr.h (Chengguang Xu 2020-05-26 17:03:43 +0800 79) #define erofs_listxattr (NULL)
e7cda1ee94f46 fs/erofs/xattr.h (Chengguang Xu 2020-05-26 17:03:43 +0800 80) #define erofs_xattr_handlers (NULL)
5734fa217f27b drivers/staging/erofs/xattr.h (Gao Xiang 2019-07-31 23:57:33 +0800 81) #endif /* !CONFIG_EROFS_FS_XATTR */
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 82)
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 83) #ifdef CONFIG_EROFS_FS_POSIX_ACL
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 84) struct posix_acl *erofs_get_acl(struct inode *inode, int type);
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 85) #else
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 86) #define erofs_get_acl (NULL)
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 87) #endif
516c115c9170f drivers/staging/erofs/xattr.h (Gao Xiang 2019-01-29 16:35:20 +0800 88)
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 89) #endif
b17500a0fdbae drivers/staging/erofs/xattr.h (Gao Xiang 2018-07-26 20:21:52 +0800 90)