Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 125795
b: refs/heads/master
c: 923f7f3
h: refs/heads/master
i:
  125793: 58d50c1
  125791: 849cec6
v: v3
  • Loading branch information
Tiger Yang authored and Mark Fasheh committed Jan 5, 2009
1 parent a472957 commit 6ac8db1
Show file tree
Hide file tree
Showing 3 changed files with 49 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: 6c3faba4421e230d77a181c260972229c542dec9
refs/heads/master: 923f7f3102b80403152e05aee3d55ecfce240440
47 changes: 47 additions & 0 deletions trunk/fs/ocfs2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include <linux/init.h>
#include <linux/module.h>
#include <linux/string.h>
#include <linux/security.h>

#define MLOG_MASK_PREFIX ML_XATTR
#include <cluster/masklog.h>
Expand Down Expand Up @@ -88,12 +89,14 @@ static struct ocfs2_xattr_def_value_root def_xv = {
struct xattr_handler *ocfs2_xattr_handlers[] = {
&ocfs2_xattr_user_handler,
&ocfs2_xattr_trusted_handler,
&ocfs2_xattr_security_handler,
NULL
};

static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_XATTR_MAX] = {
[OCFS2_XATTR_INDEX_USER] = &ocfs2_xattr_user_handler,
[OCFS2_XATTR_INDEX_TRUSTED] = &ocfs2_xattr_trusted_handler,
[OCFS2_XATTR_INDEX_SECURITY] = &ocfs2_xattr_security_handler,
};

struct ocfs2_xattr_info {
Expand Down Expand Up @@ -4976,6 +4979,50 @@ static int ocfs2_delete_xattr_index_block(struct inode *inode,
return ret;
}

/*
* 'security' attributes support
*/
static size_t ocfs2_xattr_security_list(struct inode *inode, char *list,
size_t list_size, const char *name,
size_t name_len)
{
const size_t prefix_len = XATTR_SECURITY_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;

if (list && total_len <= list_size) {
memcpy(list, XATTR_SECURITY_PREFIX, prefix_len);
memcpy(list + prefix_len, name, name_len);
list[prefix_len + name_len] = '\0';
}
return total_len;
}

static int ocfs2_xattr_security_get(struct inode *inode, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") == 0)
return -EINVAL;
return ocfs2_xattr_get(inode, OCFS2_XATTR_INDEX_SECURITY, name,
buffer, size);
}

static int ocfs2_xattr_security_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
if (strcmp(name, "") == 0)
return -EINVAL;

return ocfs2_xattr_set(inode, OCFS2_XATTR_INDEX_SECURITY, name, value,
size, flags);
}

struct xattr_handler ocfs2_xattr_security_handler = {
.prefix = XATTR_SECURITY_PREFIX,
.list = ocfs2_xattr_security_list,
.get = ocfs2_xattr_security_get,
.set = ocfs2_xattr_security_set,
};

/*
* 'trusted' attributes support
*/
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/ocfs2/xattr.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ enum ocfs2_xattr_type {

extern struct xattr_handler ocfs2_xattr_user_handler;
extern struct xattr_handler ocfs2_xattr_trusted_handler;
extern struct xattr_handler ocfs2_xattr_security_handler;
extern struct xattr_handler *ocfs2_xattr_handlers[];

ssize_t ocfs2_listxattr(struct dentry *, char *, size_t);
Expand Down

0 comments on commit 6ac8db1

Please sign in to comment.