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