ipvs: info leak in __ip_vs_get_dest_entries()
[linux/fpc-iii.git] / fs / f2fs / xattr.h
blob49c9558305e3b4dae06e16733f150af76dbfe954
1 /*
2 * fs/f2fs/xattr.h
4 * Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
7 * Portions of this code from linux/fs/ext2/xattr.h
9 * On-disk format of extended attributes for the ext2 filesystem.
11 * (C) 2001 Andreas Gruenbacher, <a.gruenbacher@computer.org>
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License version 2 as
15 * published by the Free Software Foundation.
17 #ifndef __F2FS_XATTR_H__
18 #define __F2FS_XATTR_H__
20 #include <linux/init.h>
21 #include <linux/xattr.h>
23 /* Magic value in attribute blocks */
24 #define F2FS_XATTR_MAGIC 0xF2F52011
26 /* Maximum number of references to one attribute block */
27 #define F2FS_XATTR_REFCOUNT_MAX 1024
29 /* Name indexes */
30 #define F2FS_SYSTEM_ADVISE_PREFIX "system.advise"
31 #define F2FS_XATTR_INDEX_USER 1
32 #define F2FS_XATTR_INDEX_POSIX_ACL_ACCESS 2
33 #define F2FS_XATTR_INDEX_POSIX_ACL_DEFAULT 3
34 #define F2FS_XATTR_INDEX_TRUSTED 4
35 #define F2FS_XATTR_INDEX_LUSTRE 5
36 #define F2FS_XATTR_INDEX_SECURITY 6
37 #define F2FS_XATTR_INDEX_ADVISE 7
39 struct f2fs_xattr_header {
40 __le32 h_magic; /* magic number for identification */
41 __le32 h_refcount; /* reference count */
42 __u32 h_reserved[4]; /* zero right now */
45 struct f2fs_xattr_entry {
46 __u8 e_name_index;
47 __u8 e_name_len;
48 __le16 e_value_size; /* size of attribute value */
49 char e_name[0]; /* attribute name */
52 #define XATTR_HDR(ptr) ((struct f2fs_xattr_header *)(ptr))
53 #define XATTR_ENTRY(ptr) ((struct f2fs_xattr_entry *)(ptr))
54 #define XATTR_FIRST_ENTRY(ptr) (XATTR_ENTRY(XATTR_HDR(ptr)+1))
55 #define XATTR_ROUND (3)
57 #define XATTR_ALIGN(size) ((size + XATTR_ROUND) & ~XATTR_ROUND)
59 #define ENTRY_SIZE(entry) (XATTR_ALIGN(sizeof(struct f2fs_xattr_entry) + \
60 entry->e_name_len + le16_to_cpu(entry->e_value_size)))
62 #define XATTR_NEXT_ENTRY(entry) ((struct f2fs_xattr_entry *)((char *)(entry) +\
63 ENTRY_SIZE(entry)))
65 #define IS_XATTR_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
67 #define list_for_each_xattr(entry, addr) \
68 for (entry = XATTR_FIRST_ENTRY(addr);\
69 !IS_XATTR_LAST_ENTRY(entry);\
70 entry = XATTR_NEXT_ENTRY(entry))
73 #define MIN_OFFSET XATTR_ALIGN(PAGE_SIZE - \
74 sizeof(struct node_footer) - \
75 sizeof(__u32))
77 #define MAX_VALUE_LEN (MIN_OFFSET - sizeof(struct f2fs_xattr_header) - \
78 sizeof(struct f2fs_xattr_entry))
81 * On-disk structure of f2fs_xattr
82 * We use only 1 block for xattr.
84 * +--------------------+
85 * | f2fs_xattr_header |
86 * | |
87 * +--------------------+
88 * | f2fs_xattr_entry |
89 * | .e_name_index = 1 |
90 * | .e_name_len = 3 |
91 * | .e_value_size = 14 |
92 * | .e_name = "foo" |
93 * | "value_of_xattr" |<- value_offs = e_name + e_name_len
94 * +--------------------+
95 * | f2fs_xattr_entry |
96 * | .e_name_index = 4 |
97 * | .e_name = "bar" |
98 * +--------------------+
99 * | |
100 * | Free |
101 * | |
102 * +--------------------+<- MIN_OFFSET
103 * | node_footer |
104 * | (nid, ino, offset) |
105 * +--------------------+
109 #ifdef CONFIG_F2FS_FS_XATTR
110 extern const struct xattr_handler f2fs_xattr_user_handler;
111 extern const struct xattr_handler f2fs_xattr_trusted_handler;
112 extern const struct xattr_handler f2fs_xattr_acl_access_handler;
113 extern const struct xattr_handler f2fs_xattr_acl_default_handler;
114 extern const struct xattr_handler f2fs_xattr_advise_handler;
116 extern const struct xattr_handler *f2fs_xattr_handlers[];
118 extern int f2fs_setxattr(struct inode *inode, int name_index, const char *name,
119 const void *value, size_t value_len);
120 extern int f2fs_getxattr(struct inode *inode, int name_index, const char *name,
121 void *buffer, size_t buffer_size);
122 extern ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer,
123 size_t buffer_size);
125 #else
127 #define f2fs_xattr_handlers NULL
128 static inline int f2fs_setxattr(struct inode *inode, int name_index,
129 const char *name, const void *value, size_t value_len)
131 return -EOPNOTSUPP;
133 static inline int f2fs_getxattr(struct inode *inode, int name_index,
134 const char *name, void *buffer, size_t buffer_size)
136 return -EOPNOTSUPP;
138 static inline ssize_t f2fs_listxattr(struct dentry *dentry, char *buffer,
139 size_t buffer_size)
141 return -EOPNOTSUPP;
143 #endif
145 #endif /* __F2FS_XATTR_H__ */