take private bits of reiserfs_xattr.h to fs/reiserfs/xattr.h
[deliverable/linux.git] / fs / reiserfs / xattr.h
CommitLineData
c45ac888
AV
1#include <linux/reiserfs_xattr.h>
2#include <linux/init.h>
3#include <linux/list.h>
4#include <linux/rwsem.h>
5#include <linux/reiserfs_fs_i.h>
6#include <linux/reiserfs_fs.h>
7
8struct inode;
9struct dentry;
10struct iattr;
11struct super_block;
12struct nameidata;
13
14int reiserfs_xattr_register_handlers(void) __init;
15void reiserfs_xattr_unregister_handlers(void);
16int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
17int reiserfs_lookup_privroot(struct super_block *sb);
18int reiserfs_delete_xattrs(struct inode *inode);
19int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
20int reiserfs_permission(struct inode *inode, int mask);
21
22#ifdef CONFIG_REISERFS_FS_XATTR
23#define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
24ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name,
25 void *buffer, size_t size);
26int reiserfs_setxattr(struct dentry *dentry, const char *name,
27 const void *value, size_t size, int flags);
28ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
29int reiserfs_removexattr(struct dentry *dentry, const char *name);
30
31int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
32int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
33int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
34 struct inode *, const char *, const void *,
35 size_t, int);
36
37extern const struct xattr_handler reiserfs_xattr_user_handler;
38extern const struct xattr_handler reiserfs_xattr_trusted_handler;
39extern const struct xattr_handler reiserfs_xattr_security_handler;
40#ifdef CONFIG_REISERFS_FS_SECURITY
41int reiserfs_security_init(struct inode *dir, struct inode *inode,
42 const struct qstr *qstr,
43 struct reiserfs_security_handle *sec);
44int reiserfs_security_write(struct reiserfs_transaction_handle *th,
45 struct inode *inode,
46 struct reiserfs_security_handle *sec);
47void reiserfs_security_free(struct reiserfs_security_handle *sec);
48#endif
49
50static inline int reiserfs_xattrs_initialized(struct super_block *sb)
51{
52 return REISERFS_SB(sb)->priv_root != NULL;
53}
54
55#define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
56static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
57{
58 loff_t ret = 0;
59 if (reiserfs_file_data_log(inode)) {
60 ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
61 ret >>= inode->i_sb->s_blocksize_bits;
62 }
63 return ret;
64}
65
66/* We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
67 * Let's try to be smart about it.
68 * xattr root: We cache it. If it's not cached, we may need to create it.
69 * xattr dir: If anything has been loaded for this inode, we can set a flag
70 * saying so.
71 * xattr file: Since we don't cache xattrs, we can't tell. We always include
72 * blocks for it.
73 *
74 * However, since root and dir can be created between calls - YOU MUST SAVE
75 * THIS VALUE.
76 */
77static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
78{
79 size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
80
81 if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
82 nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
83 if (!REISERFS_SB(inode->i_sb)->xattr_root->d_inode)
84 nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
85 }
86
87 return nblocks;
88}
89
90static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
91{
92 init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
93}
94
95#else
96
97#define reiserfs_getxattr NULL
98#define reiserfs_setxattr NULL
99#define reiserfs_listxattr NULL
100#define reiserfs_removexattr NULL
101
102static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
103{
104}
105#endif /* CONFIG_REISERFS_FS_XATTR */
106
107#ifndef CONFIG_REISERFS_FS_SECURITY
108static inline int reiserfs_security_init(struct inode *dir,
109 struct inode *inode,
110 const struct qstr *qstr,
111 struct reiserfs_security_handle *sec)
112{
113 return 0;
114}
115static inline int
116reiserfs_security_write(struct reiserfs_transaction_handle *th,
117 struct inode *inode,
118 struct reiserfs_security_handle *sec)
119{
120 return 0;
121}
122static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)
123{}
124#endif
This page took 0.030268 seconds and 5 git commands to generate.