diff options
author | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-05-08 21:29:27 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2009-05-08 21:29:27 -0400 |
commit | d585a021c0b10b0477d6b608c53e1feb8cde0507 (patch) | |
tree | 5ca059da1db7f15d4b29427644ad9c08270c885c /include/linux/reiserfs_xattr.h | |
parent | 84e5b0d00f8f84c4ae226be131d4bebbcee88bd3 (diff) | |
parent | 091bf7624d1c90cec9e578a18529f615213ff847 (diff) |
Merge commit 'v2.6.30-rc5' into next
Diffstat (limited to 'include/linux/reiserfs_xattr.h')
-rw-r--r-- | include/linux/reiserfs_xattr.h | 154 |
1 files changed, 72 insertions, 82 deletions
diff --git a/include/linux/reiserfs_xattr.h b/include/linux/reiserfs_xattr.h index af135ae895db..dcae01e63e40 100644 --- a/include/linux/reiserfs_xattr.h +++ b/include/linux/reiserfs_xattr.h | |||
@@ -15,6 +15,12 @@ struct reiserfs_xattr_header { | |||
15 | __le32 h_hash; /* hash of the value */ | 15 | __le32 h_hash; /* hash of the value */ |
16 | }; | 16 | }; |
17 | 17 | ||
18 | struct reiserfs_security_handle { | ||
19 | char *name; | ||
20 | void *value; | ||
21 | size_t length; | ||
22 | }; | ||
23 | |||
18 | #ifdef __KERNEL__ | 24 | #ifdef __KERNEL__ |
19 | 25 | ||
20 | #include <linux/init.h> | 26 | #include <linux/init.h> |
@@ -29,22 +35,13 @@ struct iattr; | |||
29 | struct super_block; | 35 | struct super_block; |
30 | struct nameidata; | 36 | struct nameidata; |
31 | 37 | ||
32 | struct reiserfs_xattr_handler { | 38 | int reiserfs_xattr_register_handlers(void) __init; |
33 | char *prefix; | 39 | void reiserfs_xattr_unregister_handlers(void); |
34 | int (*init) (void); | 40 | int reiserfs_xattr_init(struct super_block *sb, int mount_flags); |
35 | void (*exit) (void); | 41 | int reiserfs_delete_xattrs(struct inode *inode); |
36 | int (*get) (struct inode * inode, const char *name, void *buffer, | 42 | int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); |
37 | size_t size); | ||
38 | int (*set) (struct inode * inode, const char *name, const void *buffer, | ||
39 | size_t size, int flags); | ||
40 | int (*del) (struct inode * inode, const char *name); | ||
41 | int (*list) (struct inode * inode, const char *name, int namelen, | ||
42 | char *out); | ||
43 | struct list_head handlers; | ||
44 | }; | ||
45 | 43 | ||
46 | #ifdef CONFIG_REISERFS_FS_XATTR | 44 | #ifdef CONFIG_REISERFS_FS_XATTR |
47 | #define is_reiserfs_priv_object(inode) IS_PRIVATE(inode) | ||
48 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) | 45 | #define has_xattr_dir(inode) (REISERFS_I(inode)->i_flags & i_has_xattr_dir) |
49 | ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name, | 46 | ssize_t reiserfs_getxattr(struct dentry *dentry, const char *name, |
50 | void *buffer, size_t size); | 47 | void *buffer, size_t size); |
@@ -52,104 +49,97 @@ int reiserfs_setxattr(struct dentry *dentry, const char *name, | |||
52 | const void *value, size_t size, int flags); | 49 | const void *value, size_t size, int flags); |
53 | ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); | 50 | ssize_t reiserfs_listxattr(struct dentry *dentry, char *buffer, size_t size); |
54 | int reiserfs_removexattr(struct dentry *dentry, const char *name); | 51 | int reiserfs_removexattr(struct dentry *dentry, const char *name); |
55 | int reiserfs_delete_xattrs(struct inode *inode); | ||
56 | int reiserfs_chown_xattrs(struct inode *inode, struct iattr *attrs); | ||
57 | int reiserfs_xattr_init(struct super_block *sb, int mount_flags); | ||
58 | int reiserfs_permission(struct inode *inode, int mask); | 52 | int reiserfs_permission(struct inode *inode, int mask); |
59 | 53 | ||
60 | int reiserfs_xattr_del(struct inode *, const char *); | 54 | int reiserfs_xattr_get(struct inode *, const char *, void *, size_t); |
61 | int reiserfs_xattr_get(const struct inode *, const char *, void *, size_t); | ||
62 | int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); | 55 | int reiserfs_xattr_set(struct inode *, const char *, const void *, size_t, int); |
63 | 56 | int reiserfs_xattr_set_handle(struct reiserfs_transaction_handle *, | |
64 | extern struct reiserfs_xattr_handler user_handler; | 57 | struct inode *, const char *, const void *, |
65 | extern struct reiserfs_xattr_handler trusted_handler; | 58 | size_t, int); |
66 | extern struct reiserfs_xattr_handler security_handler; | 59 | |
67 | 60 | extern struct xattr_handler reiserfs_xattr_user_handler; | |
68 | int reiserfs_xattr_register_handlers(void) __init; | 61 | extern struct xattr_handler reiserfs_xattr_trusted_handler; |
69 | void reiserfs_xattr_unregister_handlers(void); | 62 | extern struct xattr_handler reiserfs_xattr_security_handler; |
70 | 63 | #ifdef CONFIG_REISERFS_FS_SECURITY | |
71 | static inline void reiserfs_write_lock_xattrs(struct super_block *sb) | 64 | int reiserfs_security_init(struct inode *dir, struct inode *inode, |
72 | { | 65 | struct reiserfs_security_handle *sec); |
73 | down_write(&REISERFS_XATTR_DIR_SEM(sb)); | 66 | int reiserfs_security_write(struct reiserfs_transaction_handle *th, |
74 | } | 67 | struct inode *inode, |
75 | static inline void reiserfs_write_unlock_xattrs(struct super_block *sb) | 68 | struct reiserfs_security_handle *sec); |
76 | { | 69 | void reiserfs_security_free(struct reiserfs_security_handle *sec); |
77 | up_write(&REISERFS_XATTR_DIR_SEM(sb)); | 70 | #endif |
78 | } | 71 | |
79 | static inline void reiserfs_read_lock_xattrs(struct super_block *sb) | 72 | #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header)) |
80 | { | 73 | static inline loff_t reiserfs_xattr_nblocks(struct inode *inode, loff_t size) |
81 | down_read(&REISERFS_XATTR_DIR_SEM(sb)); | ||
82 | } | ||
83 | |||
84 | static inline void reiserfs_read_unlock_xattrs(struct super_block *sb) | ||
85 | { | 74 | { |
86 | up_read(&REISERFS_XATTR_DIR_SEM(sb)); | 75 | loff_t ret = 0; |
76 | if (reiserfs_file_data_log(inode)) { | ||
77 | ret = _ROUND_UP(xattr_size(size), inode->i_sb->s_blocksize); | ||
78 | ret >>= inode->i_sb->s_blocksize_bits; | ||
79 | } | ||
80 | return ret; | ||
87 | } | 81 | } |
88 | 82 | ||
89 | static inline void reiserfs_write_lock_xattr_i(struct inode *inode) | 83 | /* We may have to create up to 3 objects: xattr root, xattr dir, xattr file. |
90 | { | 84 | * Let's try to be smart about it. |
91 | down_write(&REISERFS_I(inode)->xattr_sem); | 85 | * xattr root: We cache it. If it's not cached, we may need to create it. |
92 | } | 86 | * xattr dir: If anything has been loaded for this inode, we can set a flag |
93 | static inline void reiserfs_write_unlock_xattr_i(struct inode *inode) | 87 | * saying so. |
88 | * xattr file: Since we don't cache xattrs, we can't tell. We always include | ||
89 | * blocks for it. | ||
90 | * | ||
91 | * However, since root and dir can be created between calls - YOU MUST SAVE | ||
92 | * THIS VALUE. | ||
93 | */ | ||
94 | static inline size_t reiserfs_xattr_jcreate_nblocks(struct inode *inode) | ||
94 | { | 95 | { |
95 | up_write(&REISERFS_I(inode)->xattr_sem); | 96 | size_t nblocks = JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb); |
96 | } | ||
97 | static inline void reiserfs_read_lock_xattr_i(struct inode *inode) | ||
98 | { | ||
99 | down_read(&REISERFS_I(inode)->xattr_sem); | ||
100 | } | ||
101 | 97 | ||
102 | static inline void reiserfs_read_unlock_xattr_i(struct inode *inode) | 98 | if ((REISERFS_I(inode)->i_flags & i_has_xattr_dir) == 0) { |
103 | { | 99 | nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb); |
104 | up_read(&REISERFS_I(inode)->xattr_sem); | 100 | if (REISERFS_SB(inode->i_sb)->xattr_root == NULL) |
105 | } | 101 | nblocks += JOURNAL_BLOCKS_PER_OBJECT(inode->i_sb); |
102 | } | ||
106 | 103 | ||
107 | static inline void reiserfs_mark_inode_private(struct inode *inode) | 104 | return nblocks; |
108 | { | ||
109 | inode->i_flags |= S_PRIVATE; | ||
110 | } | 105 | } |
111 | 106 | ||
112 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) | 107 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) |
113 | { | 108 | { |
114 | init_rwsem(&REISERFS_I(inode)->xattr_sem); | 109 | init_rwsem(&REISERFS_I(inode)->i_xattr_sem); |
115 | } | 110 | } |
116 | 111 | ||
117 | #else | 112 | #else |
118 | 113 | ||
119 | #define is_reiserfs_priv_object(inode) 0 | ||
120 | #define reiserfs_mark_inode_private(inode) do {;} while(0) | ||
121 | #define reiserfs_getxattr NULL | 114 | #define reiserfs_getxattr NULL |
122 | #define reiserfs_setxattr NULL | 115 | #define reiserfs_setxattr NULL |
123 | #define reiserfs_listxattr NULL | 116 | #define reiserfs_listxattr NULL |
124 | #define reiserfs_removexattr NULL | 117 | #define reiserfs_removexattr NULL |
125 | #define reiserfs_write_lock_xattrs(sb) do {;} while(0) | ||
126 | #define reiserfs_write_unlock_xattrs(sb) do {;} while(0) | ||
127 | #define reiserfs_read_lock_xattrs(sb) | ||
128 | #define reiserfs_read_unlock_xattrs(sb) | ||
129 | 118 | ||
130 | #define reiserfs_permission NULL | 119 | #define reiserfs_permission NULL |
131 | 120 | ||
132 | #define reiserfs_xattr_register_handlers() 0 | 121 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) |
133 | #define reiserfs_xattr_unregister_handlers() | ||
134 | |||
135 | static inline int reiserfs_delete_xattrs(struct inode *inode) | ||
136 | { | 122 | { |
137 | return 0; | 123 | } |
138 | }; | 124 | #endif /* CONFIG_REISERFS_FS_XATTR */ |
139 | static inline int reiserfs_chown_xattrs(struct inode *inode, | 125 | |
140 | struct iattr *attrs) | 126 | #ifndef CONFIG_REISERFS_FS_SECURITY |
127 | static inline int reiserfs_security_init(struct inode *dir, | ||
128 | struct inode *inode, | ||
129 | struct reiserfs_security_handle *sec) | ||
141 | { | 130 | { |
142 | return 0; | 131 | return 0; |
143 | }; | 132 | } |
144 | static inline int reiserfs_xattr_init(struct super_block *sb, int mount_flags) | 133 | static inline int |
134 | reiserfs_security_write(struct reiserfs_transaction_handle *th, | ||
135 | struct inode *inode, | ||
136 | struct reiserfs_security_handle *sec) | ||
145 | { | 137 | { |
146 | sb->s_flags = (sb->s_flags & ~MS_POSIXACL); /* to be sure */ | ||
147 | return 0; | 138 | return 0; |
148 | }; | ||
149 | static inline void reiserfs_init_xattr_rwsem(struct inode *inode) | ||
150 | { | ||
151 | } | 139 | } |
152 | #endif /* CONFIG_REISERFS_FS_XATTR */ | 140 | static inline void reiserfs_security_free(struct reiserfs_security_handle *sec) |
141 | {} | ||
142 | #endif | ||
153 | 143 | ||
154 | #endif /* __KERNEL__ */ | 144 | #endif /* __KERNEL__ */ |
155 | 145 | ||