aboutsummaryrefslogtreecommitdiffstats
path: root/fs/ext2/acl.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/ext2/acl.c')
-rw-r--r--fs/ext2/acl.c43
1 files changed, 29 insertions, 14 deletions
diff --git a/fs/ext2/acl.c b/fs/ext2/acl.c
index 79dafa71effd..51f0aea70cb4 100644
--- a/fs/ext2/acl.c
+++ b/fs/ext2/acl.c
@@ -175,11 +175,8 @@ ext2_get_acl(struct inode *inode, int type)
175 return acl; 175 return acl;
176} 176}
177 177
178/* 178static int
179 * inode->i_mutex: down 179__ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
180 */
181int
182ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
183{ 180{
184 int name_index; 181 int name_index;
185 void *value = NULL; 182 void *value = NULL;
@@ -189,13 +186,6 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
189 switch(type) { 186 switch(type) {
190 case ACL_TYPE_ACCESS: 187 case ACL_TYPE_ACCESS:
191 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS; 188 name_index = EXT2_XATTR_INDEX_POSIX_ACL_ACCESS;
192 if (acl) {
193 error = posix_acl_update_mode(inode, &inode->i_mode, &acl);
194 if (error)
195 return error;
196 inode->i_ctime = current_time(inode);
197 mark_inode_dirty(inode);
198 }
199 break; 189 break;
200 190
201 case ACL_TYPE_DEFAULT: 191 case ACL_TYPE_DEFAULT:
@@ -222,6 +212,31 @@ ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
222} 212}
223 213
224/* 214/*
215 * inode->i_mutex: down
216 */
217int
218ext2_set_acl(struct inode *inode, struct posix_acl *acl, int type)
219{
220 int error;
221 int update_mode = 0;
222 umode_t mode = inode->i_mode;
223
224 if (type == ACL_TYPE_ACCESS && acl) {
225 error = posix_acl_update_mode(inode, &mode, &acl);
226 if (error)
227 return error;
228 update_mode = 1;
229 }
230 error = __ext2_set_acl(inode, acl, type);
231 if (!error && update_mode) {
232 inode->i_mode = mode;
233 inode->i_ctime = current_time(inode);
234 mark_inode_dirty(inode);
235 }
236 return error;
237}
238
239/*
225 * Initialize the ACLs of a new inode. Called from ext2_new_inode. 240 * Initialize the ACLs of a new inode. Called from ext2_new_inode.
226 * 241 *
227 * dir->i_mutex: down 242 * dir->i_mutex: down
@@ -238,12 +253,12 @@ ext2_init_acl(struct inode *inode, struct inode *dir)
238 return error; 253 return error;
239 254
240 if (default_acl) { 255 if (default_acl) {
241 error = ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT); 256 error = __ext2_set_acl(inode, default_acl, ACL_TYPE_DEFAULT);
242 posix_acl_release(default_acl); 257 posix_acl_release(default_acl);
243 } 258 }
244 if (acl) { 259 if (acl) {
245 if (!error) 260 if (!error)
246 error = ext2_set_acl(inode, acl, ACL_TYPE_ACCESS); 261 error = __ext2_set_acl(inode, acl, ACL_TYPE_ACCESS);
247 posix_acl_release(acl); 262 posix_acl_release(acl);
248 } 263 }
249 return error; 264 return error;