Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177414
b: refs/heads/master
c: 431547b
h: refs/heads/master
v: v3
  • Loading branch information
Christoph Hellwig authored and Al Viro committed Dec 16, 2009
1 parent b00fe39 commit 9e65060
Show file tree
Hide file tree
Showing 40 changed files with 534 additions and 816 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ef26ca97e83052790940cbc444b01b0d17a813c1
refs/heads/master: 431547b3c4533b8c7fd150ab36980b9a3147797b
47 changes: 12 additions & 35 deletions trunk/fs/btrfs/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ static struct posix_acl *btrfs_get_acl(struct inode *inode, int type)
return acl;
}

static int btrfs_xattr_get_acl(struct inode *inode, int type,
void *value, size_t size)
static int btrfs_xattr_acl_get(struct dentry *dentry, const char *name,
void *value, size_t size, int type)
{
struct posix_acl *acl;
int ret = 0;

acl = btrfs_get_acl(inode, type);
acl = btrfs_get_acl(dentry->d_inode, type);

if (IS_ERR(acl))
return PTR_ERR(acl);
Expand Down Expand Up @@ -151,8 +151,8 @@ static int btrfs_set_acl(struct inode *inode, struct posix_acl *acl, int type)
return ret;
}

static int btrfs_xattr_set_acl(struct inode *inode, int type,
const void *value, size_t size)
static int btrfs_xattr_acl_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
{
int ret = 0;
struct posix_acl *acl = NULL;
Expand All @@ -167,38 +167,13 @@ static int btrfs_xattr_set_acl(struct inode *inode, int type,
}
}

ret = btrfs_set_acl(inode, acl, type);
ret = btrfs_set_acl(dentry->d_inode, acl, type);

posix_acl_release(acl);

return ret;
}


static int btrfs_xattr_acl_access_get(struct inode *inode, const char *name,
void *value, size_t size)
{
return btrfs_xattr_get_acl(inode, ACL_TYPE_ACCESS, value, size);
}

static int btrfs_xattr_acl_access_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
return btrfs_xattr_set_acl(inode, ACL_TYPE_ACCESS, value, size);
}

static int btrfs_xattr_acl_default_get(struct inode *inode, const char *name,
void *value, size_t size)
{
return btrfs_xattr_get_acl(inode, ACL_TYPE_DEFAULT, value, size);
}

static int btrfs_xattr_acl_default_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
{
return btrfs_xattr_set_acl(inode, ACL_TYPE_DEFAULT, value, size);
}

int btrfs_check_acl(struct inode *inode, int mask)
{
struct posix_acl *acl;
Expand Down Expand Up @@ -303,14 +278,16 @@ int btrfs_acl_chmod(struct inode *inode)

struct xattr_handler btrfs_xattr_acl_default_handler = {
.prefix = POSIX_ACL_XATTR_DEFAULT,
.get = btrfs_xattr_acl_default_get,
.set = btrfs_xattr_acl_default_set,
.flags = ACL_TYPE_DEFAULT,
.get = btrfs_xattr_acl_get,
.set = btrfs_xattr_acl_set,
};

struct xattr_handler btrfs_xattr_acl_access_handler = {
.prefix = POSIX_ACL_XATTR_ACCESS,
.get = btrfs_xattr_acl_access_get,
.set = btrfs_xattr_acl_access_set,
.flags = ACL_TYPE_ACCESS,
.get = btrfs_xattr_acl_get,
.set = btrfs_xattr_acl_set,
};

#else /* CONFIG_BTRFS_FS_POSIX_ACL */
Expand Down
79 changes: 25 additions & 54 deletions trunk/fs/ext2/acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,41 +339,44 @@ ext2_acl_chmod(struct inode *inode)
* Extended attribut handlers
*/
static size_t
ext2_xattr_list_acl_access(struct inode *inode, char *list, size_t list_size,
const char *name, size_t name_len)
ext2_xattr_list_acl_access(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
{
const size_t size = sizeof(POSIX_ACL_XATTR_ACCESS);

if (!test_opt(inode->i_sb, POSIX_ACL))
if (!test_opt(dentry->d_sb, POSIX_ACL))
return 0;
if (list && size <= list_size)
memcpy(list, POSIX_ACL_XATTR_ACCESS, size);
return size;
}

static size_t
ext2_xattr_list_acl_default(struct inode *inode, char *list, size_t list_size,
const char *name, size_t name_len)
ext2_xattr_list_acl_default(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
{
const size_t size = sizeof(POSIX_ACL_XATTR_DEFAULT);

if (!test_opt(inode->i_sb, POSIX_ACL))
if (!test_opt(dentry->d_sb, POSIX_ACL))
return 0;
if (list && size <= list_size)
memcpy(list, POSIX_ACL_XATTR_DEFAULT, size);
return size;
}

static int
ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
ext2_xattr_get_acl(struct dentry *dentry, const char *name, void *buffer,
size_t size, int type)
{
struct posix_acl *acl;
int error;

if (!test_opt(inode->i_sb, POSIX_ACL))
if (strcmp(name, "") != 0)
return -EINVAL;
if (!test_opt(dentry->d_sb, POSIX_ACL))
return -EOPNOTSUPP;

acl = ext2_get_acl(inode, type);
acl = ext2_get_acl(dentry->d_inode, type);
if (IS_ERR(acl))
return PTR_ERR(acl);
if (acl == NULL)
Expand All @@ -385,33 +388,17 @@ ext2_xattr_get_acl(struct inode *inode, int type, void *buffer, size_t size)
}

static int
ext2_xattr_get_acl_access(struct inode *inode, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") != 0)
return -EINVAL;
return ext2_xattr_get_acl(inode, ACL_TYPE_ACCESS, buffer, size);
}

static int
ext2_xattr_get_acl_default(struct inode *inode, const char *name,
void *buffer, size_t size)
{
if (strcmp(name, "") != 0)
return -EINVAL;
return ext2_xattr_get_acl(inode, ACL_TYPE_DEFAULT, buffer, size);
}

static int
ext2_xattr_set_acl(struct inode *inode, int type, const void *value,
size_t size)
ext2_xattr_set_acl(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags, int type)
{
struct posix_acl *acl;
int error;

if (!test_opt(inode->i_sb, POSIX_ACL))
if (strcmp(name, "") != 0)
return -EINVAL;
if (!test_opt(dentry->d_sb, POSIX_ACL))
return -EOPNOTSUPP;
if (!is_owner_or_cap(inode))
if (!is_owner_or_cap(dentry->d_inode))
return -EPERM;

if (value) {
Expand All @@ -426,41 +413,25 @@ ext2_xattr_set_acl(struct inode *inode, int type, const void *value,
} else
acl = NULL;

error = ext2_set_acl(inode, type, acl);
error = ext2_set_acl(dentry->d_inode, type, acl);

release_and_out:
posix_acl_release(acl);
return error;
}

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

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

struct xattr_handler ext2_xattr_acl_access_handler = {
.prefix = POSIX_ACL_XATTR_ACCESS,
.flags = ACL_TYPE_ACCESS,
.list = ext2_xattr_list_acl_access,
.get = ext2_xattr_get_acl_access,
.set = ext2_xattr_set_acl_access,
.get = ext2_xattr_get_acl,
.set = ext2_xattr_set_acl,
};

struct xattr_handler ext2_xattr_acl_default_handler = {
.prefix = POSIX_ACL_XATTR_DEFAULT,
.flags = ACL_TYPE_DEFAULT,
.list = ext2_xattr_list_acl_default,
.get = ext2_xattr_get_acl_default,
.set = ext2_xattr_set_acl_default,
.get = ext2_xattr_get_acl,
.set = ext2_xattr_set_acl,
};
11 changes: 7 additions & 4 deletions trunk/fs/ext2/xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#include <linux/mbcache.h>
#include <linux/quotaops.h>
#include <linux/rwsem.h>
#include <linux/security.h>
#include "ext2.h"
#include "xattr.h"
#include "acl.h"
Expand Down Expand Up @@ -249,8 +250,9 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_get",
* used / required on success.
*/
static int
ext2_xattr_list(struct inode *inode, char *buffer, size_t buffer_size)
ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
{
struct inode *inode = dentry->d_inode;
struct buffer_head *bh = NULL;
struct ext2_xattr_entry *entry;
char *end;
Expand Down Expand Up @@ -300,9 +302,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
ext2_xattr_handler(entry->e_name_index);

if (handler) {
size_t size = handler->list(inode, buffer, rest,
size_t size = handler->list(dentry, buffer, rest,
entry->e_name,
entry->e_name_len);
entry->e_name_len,
handler->flags);
if (buffer) {
if (size > rest) {
error = -ERANGE;
Expand Down Expand Up @@ -330,7 +333,7 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
ssize_t
ext2_listxattr(struct dentry *dentry, char *buffer, size_t size)
{
return ext2_xattr_list(dentry->d_inode, buffer, size);
return ext2_xattr_list(dentry, buffer, size);
}

/*
Expand Down
16 changes: 8 additions & 8 deletions trunk/fs/ext2/xattr_security.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include "xattr.h"

static size_t
ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size,
const char *name, size_t name_len)
ext2_xattr_security_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
{
const int prefix_len = XATTR_SECURITY_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -26,22 +26,22 @@ ext2_xattr_security_list(struct inode *inode, char *list, size_t list_size,
}

static int
ext2_xattr_security_get(struct inode *inode, const char *name,
void *buffer, size_t size)
ext2_xattr_security_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
{
if (strcmp(name, "") == 0)
return -EINVAL;
return ext2_xattr_get(inode, EXT2_XATTR_INDEX_SECURITY, name,
return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name,
buffer, size);
}

static int
ext2_xattr_security_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
ext2_xattr_security_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
{
if (strcmp(name, "") == 0)
return -EINVAL;
return ext2_xattr_set(inode, EXT2_XATTR_INDEX_SECURITY, name,
return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_SECURITY, name,
value, size, flags);
}

Expand Down
16 changes: 8 additions & 8 deletions trunk/fs/ext2/xattr_trusted.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#include "xattr.h"

static size_t
ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
const char *name, size_t name_len)
ext2_xattr_trusted_list(struct dentry *dentry, char *list, size_t list_size,
const char *name, size_t name_len, int type)
{
const int prefix_len = XATTR_TRUSTED_PREFIX_LEN;
const size_t total_len = prefix_len + name_len + 1;
Expand All @@ -31,22 +31,22 @@ ext2_xattr_trusted_list(struct inode *inode, char *list, size_t list_size,
}

static int
ext2_xattr_trusted_get(struct inode *inode, const char *name,
void *buffer, size_t size)
ext2_xattr_trusted_get(struct dentry *dentry, const char *name,
void *buffer, size_t size, int type)
{
if (strcmp(name, "") == 0)
return -EINVAL;
return ext2_xattr_get(inode, EXT2_XATTR_INDEX_TRUSTED, name,
return ext2_xattr_get(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name,
buffer, size);
}

static int
ext2_xattr_trusted_set(struct inode *inode, const char *name,
const void *value, size_t size, int flags)
ext2_xattr_trusted_set(struct dentry *dentry, const char *name,
const void *value, size_t size, int flags, int type)
{
if (strcmp(name, "") == 0)
return -EINVAL;
return ext2_xattr_set(inode, EXT2_XATTR_INDEX_TRUSTED, name,
return ext2_xattr_set(dentry->d_inode, EXT2_XATTR_INDEX_TRUSTED, name,
value, size, flags);
}

Expand Down
Loading

0 comments on commit 9e65060

Please sign in to comment.