Commit a9273ca5c6814f393e18ed66645f817b2b71e9ad

Authored by Dave Chinner
1 parent b9c4864957

xfs: convert attr to use unsigned names

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>

Showing 12 changed files with 90 additions and 70 deletions Side-by-side Diff

fs/xfs/linux-2.6/xfs_acl.c
... ... @@ -106,7 +106,7 @@
106 106 struct posix_acl *acl;
107 107 struct xfs_acl *xfs_acl;
108 108 int len = sizeof(struct xfs_acl);
109   - char *ea_name;
  109 + unsigned char *ea_name;
110 110 int error;
111 111  
112 112 acl = get_cached_acl(inode, type);
... ... @@ -133,7 +133,8 @@
133 133 if (!xfs_acl)
134 134 return ERR_PTR(-ENOMEM);
135 135  
136   - error = -xfs_attr_get(ip, ea_name, (char *)xfs_acl, &len, ATTR_ROOT);
  136 + error = -xfs_attr_get(ip, ea_name, (unsigned char *)xfs_acl,
  137 + &len, ATTR_ROOT);
137 138 if (error) {
138 139 /*
139 140 * If the attribute doesn't exist make sure we have a negative
... ... @@ -162,7 +163,7 @@
162 163 xfs_set_acl(struct inode *inode, int type, struct posix_acl *acl)
163 164 {
164 165 struct xfs_inode *ip = XFS_I(inode);
165   - char *ea_name;
  166 + unsigned char *ea_name;
166 167 int error;
167 168  
168 169 if (S_ISLNK(inode->i_mode))
... ... @@ -194,7 +195,7 @@
194 195 (sizeof(struct xfs_acl_entry) *
195 196 (XFS_ACL_MAX_ENTRIES - acl->a_count));
196 197  
197   - error = -xfs_attr_set(ip, ea_name, (char *)xfs_acl,
  198 + error = -xfs_attr_set(ip, ea_name, (unsigned char *)xfs_acl,
198 199 len, ATTR_ROOT);
199 200  
200 201 kfree(xfs_acl);
... ... @@ -262,7 +263,7 @@
262 263 }
263 264  
264 265 static int
265   -xfs_acl_exists(struct inode *inode, char *name)
  266 +xfs_acl_exists(struct inode *inode, unsigned char *name)
266 267 {
267 268 int len = sizeof(struct xfs_acl);
268 269  
fs/xfs/linux-2.6/xfs_ioctl.c
... ... @@ -447,12 +447,12 @@
447 447 int
448 448 xfs_attrmulti_attr_get(
449 449 struct inode *inode,
450   - char *name,
451   - char __user *ubuf,
  450 + unsigned char *name,
  451 + unsigned char __user *ubuf,
452 452 __uint32_t *len,
453 453 __uint32_t flags)
454 454 {
455   - char *kbuf;
  455 + unsigned char *kbuf;
456 456 int error = EFAULT;
457 457  
458 458 if (*len > XATTR_SIZE_MAX)
459 459  
... ... @@ -476,12 +476,12 @@
476 476 int
477 477 xfs_attrmulti_attr_set(
478 478 struct inode *inode,
479   - char *name,
480   - const char __user *ubuf,
  479 + unsigned char *name,
  480 + const unsigned char __user *ubuf,
481 481 __uint32_t len,
482 482 __uint32_t flags)
483 483 {
484   - char *kbuf;
  484 + unsigned char *kbuf;
485 485 int error = EFAULT;
486 486  
487 487 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
... ... @@ -501,7 +501,7 @@
501 501 int
502 502 xfs_attrmulti_attr_remove(
503 503 struct inode *inode,
504   - char *name,
  504 + unsigned char *name,
505 505 __uint32_t flags)
506 506 {
507 507 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
... ... @@ -519,7 +519,7 @@
519 519 xfs_fsop_attrmulti_handlereq_t am_hreq;
520 520 struct dentry *dentry;
521 521 unsigned int i, size;
522   - char *attr_name;
  522 + unsigned char *attr_name;
523 523  
524 524 if (!capable(CAP_SYS_ADMIN))
525 525 return -XFS_ERROR(EPERM);
... ... @@ -547,7 +547,7 @@
547 547  
548 548 error = 0;
549 549 for (i = 0; i < am_hreq.opcount; i++) {
550   - ops[i].am_error = strncpy_from_user(attr_name,
  550 + ops[i].am_error = strncpy_from_user((char *)attr_name,
551 551 ops[i].am_attrname, MAXNAMELEN);
552 552 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
553 553 error = -ERANGE;
fs/xfs/linux-2.6/xfs_ioctl.h
... ... @@ -45,23 +45,23 @@
45 45 extern int
46 46 xfs_attrmulti_attr_get(
47 47 struct inode *inode,
48   - char *name,
49   - char __user *ubuf,
  48 + unsigned char *name,
  49 + unsigned char __user *ubuf,
50 50 __uint32_t *len,
51 51 __uint32_t flags);
52 52  
53 53 extern int
54   - xfs_attrmulti_attr_set(
  54 +xfs_attrmulti_attr_set(
55 55 struct inode *inode,
56   - char *name,
57   - const char __user *ubuf,
  56 + unsigned char *name,
  57 + const unsigned char __user *ubuf,
58 58 __uint32_t len,
59 59 __uint32_t flags);
60 60  
61 61 extern int
62 62 xfs_attrmulti_attr_remove(
63 63 struct inode *inode,
64   - char *name,
  64 + unsigned char *name,
65 65 __uint32_t flags);
66 66  
67 67 extern struct dentry *
fs/xfs/linux-2.6/xfs_ioctl32.c
... ... @@ -411,7 +411,7 @@
411 411 compat_xfs_fsop_attrmulti_handlereq_t am_hreq;
412 412 struct dentry *dentry;
413 413 unsigned int i, size;
414   - char *attr_name;
  414 + unsigned char *attr_name;
415 415  
416 416 if (!capable(CAP_SYS_ADMIN))
417 417 return -XFS_ERROR(EPERM);
... ... @@ -440,7 +440,7 @@
440 440  
441 441 error = 0;
442 442 for (i = 0; i < am_hreq.opcount; i++) {
443   - ops[i].am_error = strncpy_from_user(attr_name,
  443 + ops[i].am_error = strncpy_from_user((char *)attr_name,
444 444 compat_ptr(ops[i].am_attrname),
445 445 MAXNAMELEN);
446 446 if (ops[i].am_error == 0 || ops[i].am_error == MAXNAMELEN)
fs/xfs/linux-2.6/xfs_iops.c
... ... @@ -140,10 +140,10 @@
140 140 struct xfs_inode *ip = XFS_I(inode);
141 141 size_t length;
142 142 void *value;
143   - char *name;
  143 + unsigned char *name;
144 144 int error;
145 145  
146   - error = security_inode_init_security(inode, dir, &name,
  146 + error = security_inode_init_security(inode, dir, (char **)&name,
147 147 &value, &length);
148 148 if (error) {
149 149 if (error == -EOPNOTSUPP)
fs/xfs/linux-2.6/xfs_xattr.c
... ... @@ -45,7 +45,7 @@
45 45 value = NULL;
46 46 }
47 47  
48   - error = -xfs_attr_get(ip, name, value, &asize, xflags);
  48 + error = -xfs_attr_get(ip, (unsigned char *)name, value, &asize, xflags);
49 49 if (error)
50 50 return error;
51 51 return asize;
... ... @@ -67,8 +67,9 @@
67 67 xflags |= ATTR_REPLACE;
68 68  
69 69 if (!value)
70   - return -xfs_attr_remove(ip, name, xflags);
71   - return -xfs_attr_set(ip, name, (void *)value, size, xflags);
  70 + return -xfs_attr_remove(ip, (unsigned char *)name, xflags);
  71 + return -xfs_attr_set(ip, (unsigned char *)name,
  72 + (void *)value, size, xflags);
72 73 }
73 74  
74 75 static struct xattr_handler xfs_xattr_user_handler = {
... ... @@ -124,8 +125,13 @@
124 125 }
125 126  
126 127 static int
127   -xfs_xattr_put_listent(struct xfs_attr_list_context *context, int flags,
128   - char *name, int namelen, int valuelen, char *value)
  128 +xfs_xattr_put_listent(
  129 + struct xfs_attr_list_context *context,
  130 + int flags,
  131 + unsigned char *name,
  132 + int namelen,
  133 + int valuelen,
  134 + unsigned char *value)
129 135 {
130 136 unsigned int prefix_len = xfs_xattr_prefix_len(flags);
131 137 char *offset;
... ... @@ -148,7 +154,7 @@
148 154 offset = (char *)context->alist + context->count;
149 155 strncpy(offset, xfs_xattr_prefix(flags), prefix_len);
150 156 offset += prefix_len;
151   - strncpy(offset, name, namelen); /* real name */
  157 + strncpy(offset, (char *)name, namelen); /* real name */
152 158 offset += namelen;
153 159 *offset = '\0';
154 160 context->count += prefix_len + namelen + 1;
... ... @@ -156,8 +162,13 @@
156 162 }
157 163  
158 164 static int
159   -xfs_xattr_put_listent_sizes(struct xfs_attr_list_context *context, int flags,
160   - char *name, int namelen, int valuelen, char *value)
  165 +xfs_xattr_put_listent_sizes(
  166 + struct xfs_attr_list_context *context,
  167 + int flags,
  168 + unsigned char *name,
  169 + int namelen,
  170 + int valuelen,
  171 + unsigned char *value)
161 172 {
162 173 context->count += xfs_xattr_prefix_len(flags) + namelen + 1;
163 174 return 0;
... ... @@ -36,8 +36,8 @@
36 36 };
37 37  
38 38 /* On-disk XFS extended attribute names */
39   -#define SGI_ACL_FILE "SGI_ACL_FILE"
40   -#define SGI_ACL_DEFAULT "SGI_ACL_DEFAULT"
  39 +#define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE"
  40 +#define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT"
41 41 #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
42 42 #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
43 43  
... ... @@ -93,12 +93,12 @@
93 93 STATIC int
94 94 xfs_attr_name_to_xname(
95 95 struct xfs_name *xname,
96   - const char *aname)
  96 + const unsigned char *aname)
97 97 {
98 98 if (!aname)
99 99 return EINVAL;
100 100 xname->name = aname;
101   - xname->len = strlen(aname);
  101 + xname->len = strlen((char *)aname);
102 102 if (xname->len >= MAXNAMELEN)
103 103 return EFAULT; /* match IRIX behaviour */
104 104  
... ... @@ -124,7 +124,7 @@
124 124 xfs_attr_get_int(
125 125 struct xfs_inode *ip,
126 126 struct xfs_name *name,
127   - char *value,
  127 + unsigned char *value,
128 128 int *valuelenp,
129 129 int flags)
130 130 {
... ... @@ -171,8 +171,8 @@
171 171 int
172 172 xfs_attr_get(
173 173 xfs_inode_t *ip,
174   - const char *name,
175   - char *value,
  174 + const unsigned char *name,
  175 + unsigned char *value,
176 176 int *valuelenp,
177 177 int flags)
178 178 {
... ... @@ -235,8 +235,12 @@
235 235 }
236 236  
237 237 STATIC int
238   -xfs_attr_set_int(xfs_inode_t *dp, struct xfs_name *name,
239   - char *value, int valuelen, int flags)
  238 +xfs_attr_set_int(
  239 + struct xfs_inode *dp,
  240 + struct xfs_name *name,
  241 + unsigned char *value,
  242 + int valuelen,
  243 + int flags)
240 244 {
241 245 xfs_da_args_t args;
242 246 xfs_fsblock_t firstblock;
... ... @@ -452,8 +456,8 @@
452 456 int
453 457 xfs_attr_set(
454 458 xfs_inode_t *dp,
455   - const char *name,
456   - char *value,
  459 + const unsigned char *name,
  460 + unsigned char *value,
457 461 int valuelen,
458 462 int flags)
459 463 {
... ... @@ -600,7 +604,7 @@
600 604 int
601 605 xfs_attr_remove(
602 606 xfs_inode_t *dp,
603   - const char *name,
  607 + const unsigned char *name,
604 608 int flags)
605 609 {
606 610 int error;
... ... @@ -669,9 +673,13 @@
669 673 */
670 674 /*ARGSUSED*/
671 675 STATIC int
672   -xfs_attr_put_listent(xfs_attr_list_context_t *context, int flags,
673   - char *name, int namelen,
674   - int valuelen, char *value)
  676 +xfs_attr_put_listent(
  677 + xfs_attr_list_context_t *context,
  678 + int flags,
  679 + unsigned char *name,
  680 + int namelen,
  681 + int valuelen,
  682 + unsigned char *value)
675 683 {
676 684 struct attrlist *alist = (struct attrlist *)context->alist;
677 685 attrlist_ent_t *aep;
... ... @@ -1980,7 +1988,7 @@
1980 1988 xfs_bmbt_irec_t map[ATTR_RMTVALUE_MAPSIZE];
1981 1989 xfs_mount_t *mp;
1982 1990 xfs_daddr_t dblkno;
1983   - xfs_caddr_t dst;
  1991 + void *dst;
1984 1992 xfs_buf_t *bp;
1985 1993 int nmap, error, tmp, valuelen, blkcnt, i;
1986 1994 xfs_dablk_t lblkno;
... ... @@ -2039,7 +2047,7 @@
2039 2047 xfs_inode_t *dp;
2040 2048 xfs_bmbt_irec_t map;
2041 2049 xfs_daddr_t dblkno;
2042   - xfs_caddr_t src;
  2050 + void *src;
2043 2051 xfs_buf_t *bp;
2044 2052 xfs_dablk_t lblkno;
2045 2053 int blkcnt, valuelen, nmap, error, tmp, committed;
... ... @@ -113,7 +113,7 @@
113 113  
114 114  
115 115 typedef int (*put_listent_func_t)(struct xfs_attr_list_context *, int,
116   - char *, int, int, char *);
  116 + unsigned char *, int, int, unsigned char *);
117 117  
118 118 typedef struct xfs_attr_list_context {
119 119 struct xfs_inode *dp; /* inode */
fs/xfs/xfs_attr_leaf.c
... ... @@ -521,11 +521,11 @@
521 521  
522 522 sfe = &sf->list[0];
523 523 for (i = 0; i < sf->hdr.count; i++) {
524   - nargs.name = (char *)sfe->nameval;
  524 + nargs.name = sfe->nameval;
525 525 nargs.namelen = sfe->namelen;
526   - nargs.value = (char *)&sfe->nameval[nargs.namelen];
  526 + nargs.value = &sfe->nameval[nargs.namelen];
527 527 nargs.valuelen = sfe->valuelen;
528   - nargs.hashval = xfs_da_hashname((char *)sfe->nameval,
  528 + nargs.hashval = xfs_da_hashname(sfe->nameval,
529 529 sfe->namelen);
530 530 nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(sfe->flags);
531 531 error = xfs_attr_leaf_lookup_int(bp, &nargs); /* set a->index */
532 532  
... ... @@ -612,10 +612,10 @@
612 612 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
613 613 error = context->put_listent(context,
614 614 sfe->flags,
615   - (char *)sfe->nameval,
  615 + sfe->nameval,
616 616 (int)sfe->namelen,
617 617 (int)sfe->valuelen,
618   - (char*)&sfe->nameval[sfe->namelen]);
  618 + &sfe->nameval[sfe->namelen]);
619 619  
620 620 /*
621 621 * Either search callback finished early or
... ... @@ -659,8 +659,8 @@
659 659 }
660 660  
661 661 sbp->entno = i;
662   - sbp->hash = xfs_da_hashname((char *)sfe->nameval, sfe->namelen);
663   - sbp->name = (char *)sfe->nameval;
  662 + sbp->hash = xfs_da_hashname(sfe->nameval, sfe->namelen);
  663 + sbp->name = sfe->nameval;
664 664 sbp->namelen = sfe->namelen;
665 665 /* These are bytes, and both on-disk, don't endian-flip */
666 666 sbp->valuelen = sfe->valuelen;
667 667  
... ... @@ -818,9 +818,9 @@
818 818 continue;
819 819 ASSERT(entry->flags & XFS_ATTR_LOCAL);
820 820 name_loc = xfs_attr_leaf_name_local(leaf, i);
821   - nargs.name = (char *)name_loc->nameval;
  821 + nargs.name = name_loc->nameval;
822 822 nargs.namelen = name_loc->namelen;
823   - nargs.value = (char *)&name_loc->nameval[nargs.namelen];
  823 + nargs.value = &name_loc->nameval[nargs.namelen];
824 824 nargs.valuelen = be16_to_cpu(name_loc->valuelen);
825 825 nargs.hashval = be32_to_cpu(entry->hashval);
826 826 nargs.flags = XFS_ATTR_NSP_ONDISK_TO_ARGS(entry->flags);
827 827  
... ... @@ -2370,10 +2370,10 @@
2370 2370  
2371 2371 retval = context->put_listent(context,
2372 2372 entry->flags,
2373   - (char *)name_loc->nameval,
  2373 + name_loc->nameval,
2374 2374 (int)name_loc->namelen,
2375 2375 be16_to_cpu(name_loc->valuelen),
2376   - (char *)&name_loc->nameval[name_loc->namelen]);
  2376 + &name_loc->nameval[name_loc->namelen]);
2377 2377 if (retval)
2378 2378 return retval;
2379 2379 } else {
2380 2380  
2381 2381  
... ... @@ -2397,15 +2397,15 @@
2397 2397 return retval;
2398 2398 retval = context->put_listent(context,
2399 2399 entry->flags,
2400   - (char *)name_rmt->name,
  2400 + name_rmt->name,
2401 2401 (int)name_rmt->namelen,
2402 2402 valuelen,
2403   - (char*)args.value);
  2403 + args.value);
2404 2404 kmem_free(args.value);
2405 2405 } else {
2406 2406 retval = context->put_listent(context,
2407 2407 entry->flags,
2408   - (char *)name_rmt->name,
  2408 + name_rmt->name,
2409 2409 (int)name_rmt->namelen,
2410 2410 valuelen,
2411 2411 NULL);
fs/xfs/xfs_attr_sf.h
... ... @@ -52,7 +52,7 @@
52 52 __uint8_t valuelen; /* length of value */
53 53 __uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
54 54 xfs_dahash_t hash; /* this entry's hash value */
55   - char *name; /* name value, pointer into buffer */
  55 + unsigned char *name; /* name value, pointer into buffer */
56 56 } xfs_attr_sf_sort_t;
57 57  
58 58 #define XFS_ATTR_SF_ENTSIZE_BYNAME(nlen,vlen) /* space name/value uses */ \
fs/xfs/xfs_vnodeops.h
... ... @@ -43,11 +43,11 @@
43 43 int xfs_rename(struct xfs_inode *src_dp, struct xfs_name *src_name,
44 44 struct xfs_inode *src_ip, struct xfs_inode *target_dp,
45 45 struct xfs_name *target_name, struct xfs_inode *target_ip);
46   -int xfs_attr_get(struct xfs_inode *ip, const char *name, char *value,
47   - int *valuelenp, int flags);
48   -int xfs_attr_set(struct xfs_inode *dp, const char *name, char *value,
49   - int valuelen, int flags);
50   -int xfs_attr_remove(struct xfs_inode *dp, const char *name, int flags);
  46 +int xfs_attr_get(struct xfs_inode *ip, const unsigned char *name,
  47 + unsigned char *value, int *valuelenp, int flags);
  48 +int xfs_attr_set(struct xfs_inode *dp, const unsigned char *name,
  49 + unsigned char *value, int valuelen, int flags);
  50 +int xfs_attr_remove(struct xfs_inode *dp, const unsigned char *name, int flags);
51 51 int xfs_attr_list(struct xfs_inode *dp, char *buffer, int bufsize,
52 52 int flags, struct attrlist_cursor_kern *cursor);
53 53 ssize_t xfs_read(struct xfs_inode *ip, struct kiocb *iocb,