Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | File: linux/reiserfs_xattr.h |
| 3 | */ |
| 4 | |
| 5 | #include <linux/config.h> |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/xattr.h> |
| 8 | |
| 9 | /* Magic value in header */ |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 10 | #define REISERFS_XATTR_MAGIC 0x52465841 /* "RFXA" */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | |
| 12 | struct reiserfs_xattr_header { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 13 | __le32 h_magic; /* magic number for identification */ |
| 14 | __le32 h_hash; /* hash of the value */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | }; |
| 16 | |
| 17 | #ifdef __KERNEL__ |
| 18 | |
| 19 | struct reiserfs_xattr_handler { |
| 20 | char *prefix; |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 21 | int (*init) (void); |
| 22 | void (*exit) (void); |
| 23 | int (*get) (struct inode * inode, const char *name, void *buffer, |
| 24 | size_t size); |
| 25 | int (*set) (struct inode * inode, const char *name, const void *buffer, |
| 26 | size_t size, int flags); |
| 27 | int (*del) (struct inode * inode, const char *name); |
| 28 | int (*list) (struct inode * inode, const char *name, int namelen, |
| 29 | char *out); |
| 30 | struct list_head handlers; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | }; |
| 32 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | #ifdef CONFIG_REISERFS_FS_XATTR |
| 34 | #define is_reiserfs_priv_object(inode) IS_PRIVATE(inode) |
| 35 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 36 | ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name, |
| 37 | void *buffer, size_t size); |
| 38 | int reiserfs_setxattr(struct dentry *dentry, const char *name, |
| 39 | const void *value, size_t size, int flags); |
| 40 | ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
| 41 | int reiserfs_removexattr(struct dentry *dentry, const char *name); |
| 42 | int reiserfs_delete_xattrs(struct inode *inode); |
| 43 | int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); |
| 44 | int reiserfs_xattr_init(struct super_block *sb, int mount_flags); |
| 45 | int reiserfs_permission(struct inode *inode, int mask, struct nameidata *nd); |
| 46 | int reiserfs_permission_locked(struct inode *inode, int mask, |
| 47 | struct nameidata *nd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 49 | int reiserfs_xattr_del(struct inode *, const char *); |
| 50 | int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t); |
| 51 | int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | extern struct reiserfs_xattr_handler user_handler; |
| 54 | extern struct reiserfs_xattr_handler trusted_handler; |
| 55 | #ifdef CONFIG_REISERFS_FS_SECURITY |
| 56 | extern struct reiserfs_xattr_handler security_handler; |
| 57 | #endif |
| 58 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 59 | int reiserfs_xattr_register_handlers(void) __init; |
| 60 | void reiserfs_xattr_unregister_handlers(void); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 62 | static inline void reiserfs_write_lock_xattrs(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 64 | down_write(&REISERFS_XATTR_DIR_SEM(sb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 66 | static inline void reiserfs_write_unlock_xattrs(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 68 | up_write(&REISERFS_XATTR_DIR_SEM(sb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 70 | static inline void reiserfs_read_lock_xattrs(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 72 | down_read(&REISERFS_XATTR_DIR_SEM(sb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | } |
| 74 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 75 | static inline void reiserfs_read_unlock_xattrs(struct super_block *sb) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 77 | up_read(&REISERFS_XATTR_DIR_SEM(sb)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | } |
| 79 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 80 | static inline void reiserfs_write_lock_xattr_i(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 81 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 82 | down_write(&REISERFS_I(inode)->xattr_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 84 | static inline void reiserfs_write_unlock_xattr_i(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 86 | up_write(&REISERFS_I(inode)->xattr_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 87 | } |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 88 | static inline void reiserfs_read_lock_xattr_i(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 90 | down_read(&REISERFS_I(inode)->xattr_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | } |
| 92 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 93 | static inline void reiserfs_read_unlock_xattr_i(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 94 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 95 | up_read(&REISERFS_I(inode)->xattr_sem); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 96 | } |
| 97 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 98 | static inline void reiserfs_mark_inode_private(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 100 | inode->i_flags |= S_PRIVATE; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | #else |
| 104 | |
| 105 | #define is_reiserfs_priv_object(inode) 0 |
| 106 | #define reiserfs_mark_inode_private(inode) |
| 107 | #define reiserfs_getxattr NULL |
| 108 | #define reiserfs_setxattr NULL |
| 109 | #define reiserfs_listxattr NULL |
| 110 | #define reiserfs_removexattr NULL |
| 111 | #define reiserfs_write_lock_xattrs(sb) |
| 112 | #define reiserfs_write_unlock_xattrs(sb) |
| 113 | #define reiserfs_read_lock_xattrs(sb) |
| 114 | #define reiserfs_read_unlock_xattrs(sb) |
| 115 | |
| 116 | #define reiserfs_permission NULL |
| 117 | |
| 118 | #define reiserfs_xattr_register_handlers() 0 |
| 119 | #define reiserfs_xattr_unregister_handlers() |
| 120 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 121 | static inline int reiserfs_delete_xattrs(struct inode *inode) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 122 | { |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 123 | return 0; |
| 124 | }; |
| 125 | static inline int reiserfs_chown_xattrs(struct inode *inode, |
| 126 | struct iattr *attrs) |
| 127 | { |
| 128 | return 0; |
| 129 | }; |
| 130 | static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags) |
| 131 | { |
| 132 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */ |
| 133 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | }; |
| 135 | #endif |
| 136 | |
Linus Torvalds | bd4c625 | 2005-07-12 20:21:28 -0700 | [diff] [blame] | 137 | #endif /* __KERNEL__ */ |