Skip to content

Commit

Permalink
xfs: convert attr to use unsigned names
Browse files Browse the repository at this point in the history
To be consistent with the directory code, the attr code should use
unsigned names. Convert the names from the vfs at the highest level
to unsigned, and ænsure they are consistenly used as unsigned down
to disk.

Signed-off-by: Dave Chinner <david@fromorbit.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Dave Chinner committed Jan 19, 2010
1 parent b9c4864 commit a9273ca
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 70 deletions.
11 changes: 6 additions & 5 deletions fs/xfs/linux-2.6/xfs_acl.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ xfs_get_acl(struct inode *inode, int type)
struct posix_acl *acl;
struct xfs_acl *xfs_acl;
int len = sizeof(struct xfs_acl);
char *ea_name;
unsigned char *ea_name;
int error;

acl = get_cached_acl(inode, type);
Expand All @@ -133,7 +133,8 @@ xfs_get_acl(struct inode *inode, int type)
if (!xfs_acl)
return ERR_PTR(-ENOMEM);

error = -xfs_attr_get(ip, ea_name, (char *)xfs_acl, &len, ATTR_ROOT);
error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
&len, ATTR_ROOT);
if (error) {
/*
* If the attribute doesn't exist make sure we have a negative
Expand Down Expand Up @@ -162,7 +163,7 @@ STATIC int
xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
{
struct xfs_inode *ip = XFS_I(inode);
char *ea_name;
unsigned char *ea_name;
int error;

if (S_ISLNK(inode->i_mode))
Expand Down Expand Up @@ -194,7 +195,7 @@ xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
(sizeof(struct xfs_acl_entry) *
(XFS_ACL_MAX_ENTRIES - acl->a_count));

error = -xfs_attr_set(ip, ea_name, (char *)xfs_acl,
error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
len, ATTR_ROOT);

kfree(xfs_acl);
Expand Down Expand Up @@ -262,7 +263,7 @@ xfs_set_mode(struct inode *inode, mode_t mode)
}

static int
xfs_acl_exists(struct inode *inode, char *name)
xfs_acl_exists(struct inode *inode, unsigned char *name)
{
int len = sizeof(struct xfs_acl);

Expand Down
18 changes: 9 additions & 9 deletions fs/xfs/linux-2.6/xfs_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -447,12 +447,12 @@ xfs_attrlist_by_handle(
int
xfs_attrmulti_attr_get(
struct inode *inode,
char *name,
char __user *ubuf,
unsigned char *name,
unsigned char __user *ubuf,
__uint32_t *len,
__uint32_t flags)
{
char *kbuf;
unsigned char *kbuf;
int error = EFAULT;

if (*len > XATTR_SIZE_MAX)
Expand All @@ -476,12 +476,12 @@ xfs_attrmulti_attr_get(
int
xfs_attrmulti_attr_set(
struct inode *inode,
char *name,
const char __user *ubuf,
unsigned char *name,
const unsigned char __user *ubuf,
__uint32_t len,
__uint32_t flags)
{
char *kbuf;
unsigned char *kbuf;
int error = EFAULT;

if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
Expand All @@ -501,7 +501,7 @@ xfs_attrmulti_attr_set(
int
xfs_attrmulti_attr_remove(
struct inode *inode,
char *name,
unsigned char *name,
__uint32_t flags)
{
if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
Expand All @@ -519,7 +519,7 @@ xfs_attrmulti_by_handle(
xfs_fsop_attrmulti_handlereq_t am_hreq;
struct dentry *dentry;
unsigned int i, size;
char *attr_name;
unsigned char *attr_name;

if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM);
Expand Down Expand Up @@ -547,7 +547,7 @@ xfs_attrmulti_by_handle(

error = 0;
for (i = 0; i < am_hreq.opcount; i++) {
ops[i].am_error = strncpy_from_user(attr_name,
ops[i].am_error = strncpy_from_user((char *)attr_name,
ops[i].am_attrname, MAXNAMELEN);
if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
error = -ERANGE;
Expand Down
12 changes: 6 additions & 6 deletions fs/xfs/linux-2.6/xfs_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,23 @@ xfs_readlink_by_handle(
extern int
xfs_attrmulti_attr_get(
struct inode *inode,
char *name,
char __user *ubuf,
unsigned char *name,
unsigned char __user *ubuf,
__uint32_t *len,
__uint32_t flags);

extern int
xfs_attrmulti_attr_set(
xfs_attrmulti_attr_set(
struct inode *inode,
char *name,
const char __user *ubuf,
unsigned char *name,
const unsigned char __user *ubuf,
__uint32_t len,
__uint32_t flags);

extern int
xfs_attrmulti_attr_remove(
struct inode *inode,
char *name,
unsigned char *name,
__uint32_t flags);

extern struct dentry *
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_ioctl32.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ xfs_compat_attrmulti_by_handle(
compat_xfs_fsop_attrmulti_handlereq_t am_hreq;
struct dentry *dentry;
unsigned int i, size;
char *attr_name;
unsigned char *attr_name;

if (!capable(CAP_SYS_ADMIN))
return -XFS_ERROR(EPERM);
Expand Down Expand Up @@ -440,7 +440,7 @@ xfs_compat_attrmulti_by_handle(

error = 0;
for (i = 0; i < am_hreq.opcount; i++) {
ops[i].am_error = strncpy_from_user(attr_name,
ops[i].am_error = strncpy_from_user((char *)attr_name,
compat_ptr(ops[i].am_attrname),
MAXNAMELEN);
if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ xfs_init_security(
struct xfs_inode *ip = XFS_I(inode);
size_t length;
void *value;
char *name;
unsigned char *name;
int error;

error = security_inode_init_security(inode, dir, &name,
error = security_inode_init_security(inode, dir, (char **)&name,
&value, &length);
if (error) {
if (error == -EOPNOTSUPP)
Expand Down
27 changes: 19 additions & 8 deletions fs/xfs/linux-2.6/xfs_xattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ xfs_xattr_get(struct dentry *dentry, const char *name,
value = NULL;
}

error = -xfs_attr_get(ip, name, value, &asize, xflags);
error = -xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags);
if (error)
return error;
return asize;
Expand All @@ -67,8 +67,9 @@ xfs_xattr_set(struct dentry *dentry, const char *name, const void *value,
xflags |= ATTR_REPLACE;

if (!value)
return -xfs_attr_remove(ip, name, xflags);
return -xfs_attr_set(ip, name, (void *)value, size, xflags);
return -xfs_attr_remove(ip, (unsigned char *)name, xflags);
return -xfs_attr_set(ip, (unsigned char *)name,
(void *)value, size, xflags);
}

static struct xattr_handler xfs_xattr_user_handler = {
Expand Down Expand Up @@ -124,8 +125,13 @@ static const char *xfs_xattr_prefix(int flags)
}

static int
xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags,
char *name, int namelen, int valuelen, char *value)
xfs_xattr_put_listent(
struct xfs_attr_list_context *context,
int flags,
unsigned char *name,
int namelen,
int valuelen,
unsigned char *value)
{
unsigned int prefix_len = xfs_xattr_prefix_len(flags);
char *offset;
Expand All @@ -148,16 +154,21 @@ xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags,
offset = (char *)context->alist + context->count;
strncpy(offset, xfs_xattr_prefix(flags), prefix_len);
offset += prefix_len;
strncpy(offset, name, namelen); /* real name */
strncpy(offset, (char *)name, namelen); /* real name */
offset += namelen;
*offset = '\0';
context->count += prefix_len + namelen + 1;
return 0;
}

static int
xfs_xattr_put_listent_sizes(struct xfs_attr_list_context *context, int flags,
char *name, int namelen, int valuelen, char *value)
xfs_xattr_put_listent_sizes(
struct xfs_attr_list_context *context,
int flags,
unsigned char *name,
int namelen,
int valuelen,
unsigned char *value)
{
context->count += xfs_xattr_prefix_len(flags) + namelen + 1;
return 0;
Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/xfs_acl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ struct xfs_acl {
};

/* On-disk XFS extended attribute names */
#define SGI_ACL_FILE "SGI_ACL_FILE"
#define SGI_ACL_DEFAULT "SGI_ACL_DEFAULT"
#define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE"
#define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT"
#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)

Expand Down
38 changes: 23 additions & 15 deletions fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,12 @@ STATIC int xfs_attr_rmtval_remove(xfs_da_args_t *args);
STATIC int
xfs_attr_name_to_xname(
struct xfs_name *xname,
const char *aname)
const unsigned char *aname)
{
if (!aname)
return EINVAL;
xname->name = aname;
xname->len = strlen(aname);
xname->len = strlen((char *)aname);
if (xname->len >= MAXNAMELEN)
return EFAULT; /* match IRIX behaviour */

Expand All @@ -124,7 +124,7 @@ STATIC int
xfs_attr_get_int(
struct xfs_inode *ip,
struct xfs_name *name,
char *value,
unsigned char *value,
int *valuelenp,
int flags)
{
Expand Down Expand Up @@ -171,8 +171,8 @@ xfs_attr_get_int(
int
xfs_attr_get(
xfs_inode_t *ip,
const char *name,
char *value,
const unsigned char *name,
unsigned char *value,
int *valuelenp,
int flags)
{
Expand Down Expand Up @@ -235,8 +235,12 @@ xfs_attr_calc_size(
}

STATIC int
xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
char *value, int valuelen, int flags)
xfs_attr_set_int(
struct xfs_inode *dp,
struct xfs_name *name,
unsigned char *value,
int valuelen,
int flags)
{
xfs_da_args_t args;
xfs_fsblock_t firstblock;
Expand Down Expand Up @@ -452,8 +456,8 @@ xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
int
xfs_attr_set(
xfs_inode_t *dp,
const char *name,
char *value,
const unsigned char *name,
unsigned char *value,
int valuelen,
int flags)
{
Expand Down Expand Up @@ -600,7 +604,7 @@ xfs_attr_remove_int(xfs_inode_t *dp, struct xfs_name *name, int flags)
int
xfs_attr_remove(
xfs_inode_t *dp,
const char *name,
const unsigned char *name,
int flags)
{
int error;
Expand Down Expand Up @@ -669,9 +673,13 @@ xfs_attr_list_int(xfs_attr_list_context_t *context)
*/
/*ARGSUSED*/
STATIC int
xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags,
char *name, int namelen,
int valuelen, char *value)
xfs_attr_put_listent(
xfs_attr_list_context_t *context,
int flags,
unsigned char *name,
int namelen,
int valuelen,
unsigned char *value)
{
struct attrlist *alist = (struct attrlist *)context->alist;
attrlist_ent_t *aep;
Expand Down Expand Up @@ -1980,7 +1988,7 @@ xfs_attr_rmtval_get(xfs_da_args_t *args)
xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE];
xfs_mount_t *mp;
xfs_daddr_t dblkno;
xfs_caddr_t dst;
void *dst;
xfs_buf_t *bp;
int nmap, error, tmp, valuelen, blkcnt, i;
xfs_dablk_t lblkno;
Expand Down Expand Up @@ -2039,7 +2047,7 @@ xfs_attr_rmtval_set(xfs_da_args_t *args)
xfs_inode_t *dp;
xfs_bmbt_irec_t map;
xfs_daddr_t dblkno;
xfs_caddr_t src;
void *src;
xfs_buf_t *bp;
xfs_dablk_t lblkno;
int blkcnt, valuelen, nmap, error, tmp, committed;
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/xfs_attr.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ typedef struct attrlist_cursor_kern {


typedef int (*put_listent_func_t)(struct xfs_attr_list_context *, int,
char *, int, int, char *);
unsigned char *, int, int, unsigned char *);

typedef struct xfs_attr_list_context {
struct xfs_inode *dp; /* inode */
Expand Down
Loading

0 comments on commit a9273ca

Please sign in to comment.