Blame view
fs/f2fs/xattr.h
5.15 KB
d29fbcdb0 f2fs: Use the cor... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
0a8165d7c f2fs: adjust kern... |
2 |
/* |
af48b85b8 f2fs: add xattr a... |
3 4 5 6 7 8 9 10 11 12 |
* fs/f2fs/xattr.h * * Copyright (c) 2012 Samsung Electronics Co., Ltd. * http://www.samsung.com/ * * Portions of this code from linux/fs/ext2/xattr.h * * On-disk format of extended attributes for the ext2 filesystem. * * (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org> |
af48b85b8 f2fs: add xattr a... |
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
*/ #ifndef __F2FS_XATTR_H__ #define __F2FS_XATTR_H__ #include <linux/init.h> #include <linux/xattr.h> /* Magic value in attribute blocks */ #define F2FS_XATTR_MAGIC 0xF2F52011 /* Maximum number of references to one attribute block */ #define F2FS_XATTR_REFCOUNT_MAX 1024 /* Name indexes */ |
98e9cb571 vfs: Distinguish ... |
27 |
#define F2FS_SYSTEM_ADVISE_NAME "system.advise" |
af48b85b8 f2fs: add xattr a... |
28 29 30 31 32 33 34 |
#define F2FS_XATTR_INDEX_USER 1 #define F2FS_XATTR_INDEX_POSIX_ACL_ACCESS 2 #define F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT 3 #define F2FS_XATTR_INDEX_TRUSTED 4 #define F2FS_XATTR_INDEX_LUSTRE 5 #define F2FS_XATTR_INDEX_SECURITY 6 #define F2FS_XATTR_INDEX_ADVISE 7 |
b93531dd7 f2fs crypto: add ... |
35 36 |
/* Should be same as EXT4_XATTR_INDEX_ENCRYPTION */ #define F2FS_XATTR_INDEX_ENCRYPTION 9 |
95ae251fe f2fs: add fs-veri... |
37 |
#define F2FS_XATTR_INDEX_VERITY 11 |
b93531dd7 f2fs crypto: add ... |
38 39 |
#define F2FS_XATTR_NAME_ENCRYPTION_CONTEXT "c" |
95ae251fe f2fs: add fs-veri... |
40 |
#define F2FS_XATTR_NAME_VERITY "v" |
af48b85b8 f2fs: add xattr a... |
41 42 43 44 45 46 47 48 49 50 51 |
struct f2fs_xattr_header { __le32 h_magic; /* magic number for identification */ __le32 h_refcount; /* reference count */ __u32 h_reserved[4]; /* zero right now */ }; struct f2fs_xattr_entry { __u8 e_name_index; __u8 e_name_len; __le16 e_value_size; /* size of attribute value */ |
50b1203d8 f2fs: xattr.h: Re... |
52 |
char e_name[]; /* attribute name */ |
af48b85b8 f2fs: add xattr a... |
53 54 55 56 |
}; #define XATTR_HDR(ptr) ((struct f2fs_xattr_header *)(ptr)) #define XATTR_ENTRY(ptr) ((struct f2fs_xattr_entry *)(ptr)) |
dd9cfe236 f2fs: introduce _... |
57 |
#define XATTR_FIRST_ENTRY(ptr) (XATTR_ENTRY(XATTR_HDR(ptr) + 1)) |
af48b85b8 f2fs: add xattr a... |
58 |
#define XATTR_ROUND (3) |
68afcf2d3 f2fs: guard macro... |
59 |
#define XATTR_ALIGN(size) (((size) + XATTR_ROUND) & ~XATTR_ROUND) |
af48b85b8 f2fs: add xattr a... |
60 61 |
#define ENTRY_SIZE(entry) (XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + \ |
68afcf2d3 f2fs: guard macro... |
62 |
(entry)->e_name_len + le16_to_cpu((entry)->e_value_size))) |
af48b85b8 f2fs: add xattr a... |
63 64 65 66 67 68 69 70 71 72 |
#define XATTR_NEXT_ENTRY(entry) ((struct f2fs_xattr_entry *)((char *)(entry) +\ ENTRY_SIZE(entry))) #define IS_XATTR_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0) #define list_for_each_xattr(entry, addr) \ for (entry = XATTR_FIRST_ENTRY(addr);\ !IS_XATTR_LAST_ENTRY(entry);\ entry = XATTR_NEXT_ENTRY(entry)) |
22588f877 f2fs: don't reser... |
73 74 |
#define VALID_XATTR_BLOCK_SIZE (PAGE_SIZE - sizeof(struct node_footer)) #define XATTR_PADDING_SIZE (sizeof(__u32)) |
ba3b583cf f2fs: clean up pa... |
75 76 |
#define XATTR_SIZE(i) ((F2FS_I(i)->i_xattr_nid ? \ VALID_XATTR_BLOCK_SIZE : 0) + \ |
2777e6543 f2fs: fix to avoi... |
77 |
(inline_xattr_size(i))) |
ba38c27eb f2fs: enhance loo... |
78 79 |
#define MIN_OFFSET(i) XATTR_ALIGN(inline_xattr_size(i) + \ VALID_XATTR_BLOCK_SIZE) |
af48b85b8 f2fs: add xattr a... |
80 |
|
65985d935 f2fs: support the... |
81 82 83 |
#define MAX_VALUE_LEN(i) (MIN_OFFSET(i) - \ sizeof(struct f2fs_xattr_header) - \ sizeof(struct f2fs_xattr_entry)) |
af48b85b8 f2fs: add xattr a... |
84 |
|
dd6c89b5f f2fs: fix to do s... |
85 86 87 88 89 |
#define MAX_INLINE_XATTR_SIZE \ (DEF_ADDRS_PER_INODE - \ F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) - \ DEF_INLINE_RESERVED_SIZE - \ MIN_INLINE_DENTRY_SIZE / sizeof(__le32)) |
0a8165d7c f2fs: adjust kern... |
90 |
/* |
af48b85b8 f2fs: add xattr a... |
91 |
* On-disk structure of f2fs_xattr |
65985d935 f2fs: support the... |
92 |
* We use inline xattrs space + 1 block for xattr. |
af48b85b8 f2fs: add xattr a... |
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
* * +--------------------+ * | f2fs_xattr_header | * | | * +--------------------+ * | f2fs_xattr_entry | * | .e_name_index = 1 | * | .e_name_len = 3 | * | .e_value_size = 14 | * | .e_name = "foo" | * | "value_of_xattr" |<- value_offs = e_name + e_name_len * +--------------------+ * | f2fs_xattr_entry | * | .e_name_index = 4 | * | .e_name = "bar" | * +--------------------+ * | | * | Free | * | | * +--------------------+<- MIN_OFFSET * | node_footer | * | (nid, ino, offset) | * +--------------------+ * **/ #ifdef CONFIG_F2FS_FS_XATTR extern const struct xattr_handler f2fs_xattr_user_handler; extern const struct xattr_handler f2fs_xattr_trusted_handler; |
af48b85b8 f2fs: add xattr a... |
122 |
extern const struct xattr_handler f2fs_xattr_advise_handler; |
8ae8f1627 f2fs: support xat... |
123 |
extern const struct xattr_handler f2fs_xattr_security_handler; |
af48b85b8 f2fs: add xattr a... |
124 125 |
extern const struct xattr_handler *f2fs_xattr_handlers[]; |
8ae8f1627 f2fs: support xat... |
126 |
extern int f2fs_setxattr(struct inode *, int, const char *, |
c02745ef6 f2fs: pass flags ... |
127 |
const void *, size_t, struct page *, int); |
bce8d1120 f2fs: avoid deadl... |
128 129 |
extern int f2fs_getxattr(struct inode *, int, const char *, void *, size_t, struct page *); |
8ae8f1627 f2fs: support xat... |
130 |
extern ssize_t f2fs_listxattr(struct dentry *, char *, size_t); |
a999150f4 f2fs: use kmem_ca... |
131 132 |
extern int f2fs_init_xattr_caches(struct f2fs_sb_info *); extern void f2fs_destroy_xattr_caches(struct f2fs_sb_info *); |
af48b85b8 f2fs: add xattr a... |
133 134 135 |
#else #define f2fs_xattr_handlers NULL |
195f40654 f2fs: code cleanu... |
136 |
#define f2fs_listxattr NULL |
e11232680 f2fs: clean up lo... |
137 |
static inline int f2fs_setxattr(struct inode *inode, int index, |
fff4c55d3 f2fs: add missing... |
138 139 |
const char *name, const void *value, size_t size, struct page *page, int flags) |
af48b85b8 f2fs: add xattr a... |
140 141 142 |
{ return -EOPNOTSUPP; } |
e11232680 f2fs: clean up lo... |
143 |
static inline int f2fs_getxattr(struct inode *inode, int index, |
bce8d1120 f2fs: avoid deadl... |
144 145 |
const char *name, void *buffer, size_t buffer_size, struct page *dpage) |
af48b85b8 f2fs: add xattr a... |
146 147 148 |
{ return -EOPNOTSUPP; } |
db251553c f2fs: xattr.h: Ma... |
149 150 |
static inline int f2fs_init_xattr_caches(struct f2fs_sb_info *sbi) { return 0; } static inline void f2fs_destroy_xattr_caches(struct f2fs_sb_info *sbi) { } |
af48b85b8 f2fs: add xattr a... |
151 |
#endif |
8ae8f1627 f2fs: support xat... |
152 153 154 155 156 157 158 159 160 161 |
#ifdef CONFIG_F2FS_FS_SECURITY extern int f2fs_init_security(struct inode *, struct inode *, const struct qstr *, struct page *); #else static inline int f2fs_init_security(struct inode *inode, struct inode *dir, const struct qstr *qstr, struct page *ipage) { return 0; } #endif |
af48b85b8 f2fs: add xattr a... |
162 |
#endif /* __F2FS_XATTR_H__ */ |