Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125794
b: refs/heads/master
c: 6c3faba
h: refs/heads/master
v: v3
  • Loading branch information
Tiger Yang authored and Mark Fasheh committed Jan 5, 2009
1 parent 58d50c1 commit a472957
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f5d362022a947e84b0a3dd656d09c6b2322e234f
refs/heads/master: 6c3faba4421e230d77a181c260972229c542dec9
68 changes: 68 additions & 0 deletions trunk/fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -2325,6 +2325,74 @@ static int __ocfs2_xattr_set_handle(struct inode *inode,
return ret;
}

/*
* This function only called duing creating inode
* for init security/acl xattrs of the new inode.
* The xattrs could be put into ibody or extent block,
* xattr bucket would not be use in this case.
* transanction credits also be reserved in here.
*/
int ocfs2_xattr_set_handle(handle_t *handle,
struct inode *inode,
struct buffer_head *di_bh,
int name_index,
const char *name,
const void *value,
size_t value_len,
int flags,
struct ocfs2_alloc_context *meta_ac,
struct ocfs2_alloc_context *data_ac)
{
struct ocfs2_dinode *di;
int ret;

struct ocfs2_xattr_info xi = {
.name_index = name_index,
.name = name,
.value = value,
.value_len = value_len,
};

struct ocfs2_xattr_search xis = {
.not_found = -ENODATA,
};

struct ocfs2_xattr_search xbs = {
.not_found = -ENODATA,
};

struct ocfs2_xattr_set_ctxt ctxt = {
.handle = handle,
.meta_ac = meta_ac,
.data_ac = data_ac,
};

if (!ocfs2_supports_xattr(OCFS2_SB(inode->i_sb)))
return -EOPNOTSUPP;

xis.inode_bh = xbs.inode_bh = di_bh;
di = (struct ocfs2_dinode *)di_bh->b_data;

down_write(&OCFS2_I(inode)->ip_xattr_sem);

ret = ocfs2_xattr_ibody_find(inode, name_index, name, &xis);
if (ret)
goto cleanup;
if (xis.not_found) {
ret = ocfs2_xattr_block_find(inode, name_index, name, &xbs);
if (ret)
goto cleanup;
}

ret = __ocfs2_xattr_set_handle(inode, di, &xi, &xis, &xbs, &ctxt);

cleanup:
up_write(&OCFS2_I(inode)->ip_xattr_sem);
brelse(xbs.xattr_bh);

return ret;
}

/*
* ocfs2_xattr_set()
*
Expand Down
4 changes: 4 additions & 0 deletions trunk/fs/ocfs2/xattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ extern struct xattr_handler *ocfs2_xattr_handlers[];
ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
int ocfs2_xattr_set(struct inode *, int, const char *, const void *,
size_t, int);
int ocfs2_xattr_set_handle(handle_t *, struct inode *, struct buffer_head *,
int, const char *, const void *, size_t, int,
struct ocfs2_alloc_context *,
struct ocfs2_alloc_context *);
int ocfs2_xattr_remove(struct inode *, struct buffer_head *);

#endif /* OCFS2_XATTR_H */

0 comments on commit a472957

Please sign in to comment.