diff options
author | Tiger Yang <tiger.yang@oracle.com> | 2008-11-13 22:17:41 -0500 |
---|---|---|
committer | Mark Fasheh <mfasheh@suse.com> | 2009-01-05 11:34:20 -0500 |
commit | 89c38bd0ade3c567707ed8fce088b253b0369c50 (patch) | |
tree | ffc5bf6a8871efa8e7793c552d16ac9fb92f1334 /fs/ocfs2/acl.c | |
parent | 060bc66dd5017460076d9e808e2198cd532c943d (diff) |
ocfs2: add ocfs2_init_acl in mknod
We need to get the parent directories acls and let the new child inherit it.
To this, we add additional calculations for data/metadata allocation.
Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
Signed-off-by: Mark Fasheh <mfasheh@suse.com>
Diffstat (limited to 'fs/ocfs2/acl.c')
-rw-r--r-- | fs/ocfs2/acl.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/fs/ocfs2/acl.c b/fs/ocfs2/acl.c index df72256c4422..12dfb44c22e5 100644 --- a/fs/ocfs2/acl.c +++ b/fs/ocfs2/acl.c | |||
@@ -272,6 +272,65 @@ int ocfs2_acl_chmod(struct inode *inode) | |||
272 | return ret; | 272 | return ret; |
273 | } | 273 | } |
274 | 274 | ||
275 | /* | ||
276 | * Initialize the ACLs of a new inode. If parent directory has default ACL, | ||
277 | * then clone to new inode. Called from ocfs2_mknod. | ||
278 | */ | ||
279 | int ocfs2_init_acl(handle_t *handle, | ||
280 | struct inode *inode, | ||
281 | struct inode *dir, | ||
282 | struct buffer_head *di_bh, | ||
283 | struct buffer_head *dir_bh, | ||
284 | struct ocfs2_alloc_context *meta_ac, | ||
285 | struct ocfs2_alloc_context *data_ac) | ||
286 | { | ||
287 | struct ocfs2_super *osb = OCFS2_SB(inode->i_sb); | ||
288 | struct posix_acl *acl = NULL; | ||
289 | int ret = 0; | ||
290 | |||
291 | if (!S_ISLNK(inode->i_mode)) { | ||
292 | if (osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) { | ||
293 | acl = ocfs2_get_acl_nolock(dir, ACL_TYPE_DEFAULT, | ||
294 | dir_bh); | ||
295 | if (IS_ERR(acl)) | ||
296 | return PTR_ERR(acl); | ||
297 | } | ||
298 | if (!acl) | ||
299 | inode->i_mode &= ~current->fs->umask; | ||
300 | } | ||
301 | if ((osb->s_mount_opt & OCFS2_MOUNT_POSIX_ACL) && acl) { | ||
302 | struct posix_acl *clone; | ||
303 | mode_t mode; | ||
304 | |||
305 | if (S_ISDIR(inode->i_mode)) { | ||
306 | ret = ocfs2_set_acl(handle, inode, di_bh, | ||
307 | ACL_TYPE_DEFAULT, acl, | ||
308 | meta_ac, data_ac); | ||
309 | if (ret) | ||
310 | goto cleanup; | ||
311 | } | ||
312 | clone = posix_acl_clone(acl, GFP_NOFS); | ||
313 | ret = -ENOMEM; | ||
314 | if (!clone) | ||
315 | goto cleanup; | ||
316 | |||
317 | mode = inode->i_mode; | ||
318 | ret = posix_acl_create_masq(clone, &mode); | ||
319 | if (ret >= 0) { | ||
320 | inode->i_mode = mode; | ||
321 | if (ret > 0) { | ||
322 | ret = ocfs2_set_acl(handle, inode, | ||
323 | di_bh, ACL_TYPE_ACCESS, | ||
324 | clone, meta_ac, data_ac); | ||
325 | } | ||
326 | } | ||
327 | posix_acl_release(clone); | ||
328 | } | ||
329 | cleanup: | ||
330 | posix_acl_release(acl); | ||
331 | return ret; | ||
332 | } | ||
333 | |||
275 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, | 334 | static size_t ocfs2_xattr_list_acl_access(struct inode *inode, |
276 | char *list, | 335 | char *list, |
277 | size_t list_len, | 336 | size_t list_len, |