1 #include <linux/reiserfs_xattr.h>
2 #include <linux/init.h>
3 #include <linux/list.h>
4 #include <linux/rwsem.h>
5 #include <linux/xattr.h>
12 int reiserfs_xattr_register_handlers(void) __init;
13 void reiserfs_xattr_unregister_handlers(void);
14 int reiserfs_xattr_init(struct super_block *sb, int mount_flags);
15 int reiserfs_lookup_privroot(struct super_block *sb);
16 int reiserfs_delete_xattrs(struct inode *inode);
17 int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs);
18 int reiserfs_permission(struct inode *inode, int mask);
20 #ifdef CONFIG_REISERFS_FS_XATTR
21 #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir)
22 ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
24 int reiserfs_xattr_get(struct inode *, const char *, void *, size_t);
25 int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int);
26 int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *,
27 struct inode *, const char *, const void *,
30 extern const struct xattr_handler reiserfs_xattr_user_handler;
31 extern const struct xattr_handler reiserfs_xattr_trusted_handler;
32 extern const struct xattr_handler reiserfs_xattr_security_handler;
33 #ifdef CONFIG_REISERFS_FS_SECURITY
34 int reiserfs_security_init(struct inode *dir, struct inode *inode,
35 const struct qstr *qstr,
36 struct reiserfs_security_handle *sec);
37 int reiserfs_security_write(struct reiserfs_transaction_handle *th,
39 struct reiserfs_security_handle *sec);
40 void reiserfs_security_free(struct reiserfs_security_handle *sec);
43 static inline int reiserfs_xattrs_initialized(struct super_block *sb)
45 return REISERFS_SB(sb)->priv_root != NULL;
48 #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header))
49 static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size)
52 if (reiserfs_file_data_log(inode)) {
53 ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize);
54 ret >>= inode->i_sb->s_blocksize_bits;
60 * We may have to create up to 3 objects: xattr root, xattr dir, xattr file.
61 * Let's try to be smart about it.
62 * xattr root: We cache it. If it's not cached, we may need to create it.
63 * xattr dir: If anything has been loaded for this inode, we can set a flag
65 * xattr file: Since we don't cache xattrs, we can't tell. We always include
68 * However, since root and dir can be created between calls - YOU MUST SAVE
71 static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode)
73 size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
75 if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) {
76 nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
77 if (d_really_is_negative(REISERFS_SB(inode->i_sb)->xattr_root))
78 nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb);
84 static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
86 init_rwsem(&REISERFS_I(inode)->i_xattr_sem);
91 #define reiserfs_listxattr NULL
93 static inline void reiserfs_init_xattr_rwsem(struct inode *inode)
96 #endif /* CONFIG_REISERFS_FS_XATTR */
98 #ifndef CONFIG_REISERFS_FS_SECURITY
99 static inline int reiserfs_security_init(struct inode *dir,
101 const struct qstr *qstr,
102 struct reiserfs_security_handle *sec)
107 reiserfs_security_write(struct reiserfs_transaction_handle *th,
109 struct reiserfs_security_handle *sec)
113 static inline void reiserfs_security_free(struct reiserfs_security_handle *sec)