aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-17 01:29:25 -0500
committerNathan Scott <nathans@sgi.com>2006-03-17 01:29:25 -0500
commit3b244aa81ecb06859e0c16abf4c26404c1d86591 (patch)
tree35a78ae82d8a183c72da8f579479bc2caa6d3bc0
parentc0f054e7a44b4bbed8e16dd459f33df63dad98ef (diff)
[XFS] endianess annotations for xfs_attr_shortform_t
SGI-PV: 943272 SGI-Modid: xfs-linux-melb:xfs-kern:25501a Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nathan Scott <nathans@sgi.com>
-rw-r--r--fs/xfs/xfs_attr_leaf.c55
-rw-r--r--fs/xfs/xfs_attr_sf.h8
-rw-r--r--fs/xfs/xfs_inode.c2
3 files changed, 30 insertions, 35 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 531417b2c74c..37d2e10f874c 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -194,7 +194,7 @@ xfs_attr_shortform_create(xfs_da_args_t *args)
194 xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK); 194 xfs_idata_realloc(dp, sizeof(*hdr), XFS_ATTR_FORK);
195 hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data; 195 hdr = (xfs_attr_sf_hdr_t *)ifp->if_u1.if_data;
196 hdr->count = 0; 196 hdr->count = 0;
197 INT_SET(hdr->totsize, ARCH_CONVERT, sizeof(*hdr)); 197 hdr->totsize = cpu_to_be16(sizeof(*hdr));
198 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 198 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
199} 199}
200 200
@@ -224,8 +224,7 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
224 ASSERT(ifp->if_flags & XFS_IFINLINE); 224 ASSERT(ifp->if_flags & XFS_IFINLINE);
225 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 225 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
226 sfe = &sf->list[0]; 226 sfe = &sf->list[0];
227 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); 227 for (i = 0; i < sf->hdr.count; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
228 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
229#ifdef DEBUG 228#ifdef DEBUG
230 if (sfe->namelen != args->namelen) 229 if (sfe->namelen != args->namelen)
231 continue; 230 continue;
@@ -248,13 +247,13 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff)
248 sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset); 247 sfe = (xfs_attr_sf_entry_t *)((char *)sf + offset);
249 248
250 sfe->namelen = args->namelen; 249 sfe->namelen = args->namelen;
251 INT_SET(sfe->valuelen, ARCH_CONVERT, args->valuelen); 250 sfe->valuelen = args->valuelen;
252 sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : 251 sfe->flags = (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
253 ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); 252 ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
254 memcpy(sfe->nameval, args->name, args->namelen); 253 memcpy(sfe->nameval, args->name, args->namelen);
255 memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen); 254 memcpy(&sfe->nameval[args->namelen], args->value, args->valuelen);
256 INT_MOD(sf->hdr.count, ARCH_CONVERT, 1); 255 sf->hdr.count++;
257 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, size); 256 be16_add(&sf->hdr.totsize, size);
258 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA); 257 xfs_trans_log_inode(args->trans, dp, XFS_ILOG_CORE | XFS_ILOG_ADATA);
259 258
260 xfs_sbversion_add_attr2(mp, args->trans); 259 xfs_sbversion_add_attr2(mp, args->trans);
@@ -277,7 +276,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
277 base = sizeof(xfs_attr_sf_hdr_t); 276 base = sizeof(xfs_attr_sf_hdr_t);
278 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data; 277 sf = (xfs_attr_shortform_t *)dp->i_afp->if_u1.if_data;
279 sfe = &sf->list[0]; 278 sfe = &sf->list[0];
280 end = INT_GET(sf->hdr.count, ARCH_CONVERT); 279 end = sf->hdr.count;
281 for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe), 280 for (i = 0; i < end; sfe = XFS_ATTR_SF_NEXTENTRY(sfe),
282 base += size, i++) { 281 base += size, i++) {
283 size = XFS_ATTR_SF_ENTSIZE(sfe); 282 size = XFS_ATTR_SF_ENTSIZE(sfe);
@@ -300,11 +299,11 @@ xfs_attr_shortform_remove(xfs_da_args_t *args)
300 * Fix up the attribute fork data, covering the hole 299 * Fix up the attribute fork data, covering the hole
301 */ 300 */
302 end = base + size; 301 end = base + size;
303 totsize = INT_GET(sf->hdr.totsize, ARCH_CONVERT); 302 totsize = be16_to_cpu(sf->hdr.totsize);
304 if (end != totsize) 303 if (end != totsize)
305 memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end); 304 memmove(&((char *)sf)[base], &((char *)sf)[end], totsize - end);
306 INT_MOD(sf->hdr.count, ARCH_CONVERT, -1); 305 sf->hdr.count--;
307 INT_MOD(sf->hdr.totsize, ARCH_CONVERT, -size); 306 be16_add(&sf->hdr.totsize, -size);
308 307
309 /* 308 /*
310 * Fix up the start offset of the attribute fork 309 * Fix up the start offset of the attribute fork
@@ -360,7 +359,7 @@ xfs_attr_shortform_lookup(xfs_da_args_t *args)
360 ASSERT(ifp->if_flags & XFS_IFINLINE); 359 ASSERT(ifp->if_flags & XFS_IFINLINE);
361 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 360 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
362 sfe = &sf->list[0]; 361 sfe = &sf->list[0];
363 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); 362 for (i = 0; i < sf->hdr.count;
364 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { 363 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
365 if (sfe->namelen != args->namelen) 364 if (sfe->namelen != args->namelen)
366 continue; 365 continue;
@@ -391,7 +390,7 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
391 ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE); 390 ASSERT(args->dp->i_d.di_aformat == XFS_IFINLINE);
392 sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data; 391 sf = (xfs_attr_shortform_t *)args->dp->i_afp->if_u1.if_data;
393 sfe = &sf->list[0]; 392 sfe = &sf->list[0];
394 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); 393 for (i = 0; i < sf->hdr.count;
395 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) { 394 sfe = XFS_ATTR_SF_NEXTENTRY(sfe), i++) {
396 if (sfe->namelen != args->namelen) 395 if (sfe->namelen != args->namelen)
397 continue; 396 continue;
@@ -404,14 +403,14 @@ xfs_attr_shortform_getvalue(xfs_da_args_t *args)
404 ((sfe->flags & XFS_ATTR_ROOT) != 0)) 403 ((sfe->flags & XFS_ATTR_ROOT) != 0))
405 continue; 404 continue;
406 if (args->flags & ATTR_KERNOVAL) { 405 if (args->flags & ATTR_KERNOVAL) {
407 args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); 406 args->valuelen = sfe->valuelen;
408 return(XFS_ERROR(EEXIST)); 407 return(XFS_ERROR(EEXIST));
409 } 408 }
410 if (args->valuelen < INT_GET(sfe->valuelen, ARCH_CONVERT)) { 409 if (args->valuelen < sfe->valuelen) {
411 args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); 410 args->valuelen = sfe->valuelen;
412 return(XFS_ERROR(ERANGE)); 411 return(XFS_ERROR(ERANGE));
413 } 412 }
414 args->valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); 413 args->valuelen = sfe->valuelen;
415 memcpy(args->value, &sfe->nameval[args->namelen], 414 memcpy(args->value, &sfe->nameval[args->namelen],
416 args->valuelen); 415 args->valuelen);
417 return(XFS_ERROR(EEXIST)); 416 return(XFS_ERROR(EEXIST));
@@ -438,7 +437,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
438 dp = args->dp; 437 dp = args->dp;
439 ifp = dp->i_afp; 438 ifp = dp->i_afp;
440 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data; 439 sf = (xfs_attr_shortform_t *)ifp->if_u1.if_data;
441 size = INT_GET(sf->hdr.totsize, ARCH_CONVERT); 440 size = be16_to_cpu(sf->hdr.totsize);
442 tmpbuffer = kmem_alloc(size, KM_SLEEP); 441 tmpbuffer = kmem_alloc(size, KM_SLEEP);
443 ASSERT(tmpbuffer != NULL); 442 ASSERT(tmpbuffer != NULL);
444 memcpy(tmpbuffer, ifp->if_u1.if_data, size); 443 memcpy(tmpbuffer, ifp->if_u1.if_data, size);
@@ -481,11 +480,11 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
481 nargs.oknoent = 1; 480 nargs.oknoent = 1;
482 481
483 sfe = &sf->list[0]; 482 sfe = &sf->list[0];
484 for (i = 0; i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) { 483 for (i = 0; i < sf->hdr.count; i++) {
485 nargs.name = (char *)sfe->nameval; 484 nargs.name = (char *)sfe->nameval;
486 nargs.namelen = sfe->namelen; 485 nargs.namelen = sfe->namelen;
487 nargs.value = (char *)&sfe->nameval[nargs.namelen]; 486 nargs.value = (char *)&sfe->nameval[nargs.namelen];
488 nargs.valuelen = INT_GET(sfe->valuelen, ARCH_CONVERT); 487 nargs.valuelen = sfe->valuelen;
489 nargs.hashval = xfs_da_hashname((char *)sfe->nameval, 488 nargs.hashval = xfs_da_hashname((char *)sfe->nameval,
490 sfe->namelen); 489 sfe->namelen);
491 nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : 490 nargs.flags = (sfe->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
@@ -560,10 +559,8 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
560 * If the buffer is large enough, do not bother with sorting. 559 * If the buffer is large enough, do not bother with sorting.
561 * Note the generous fudge factor of 16 overhead bytes per entry. 560 * Note the generous fudge factor of 16 overhead bytes per entry.
562 */ 561 */
563 if ((dp->i_afp->if_bytes + INT_GET(sf->hdr.count, ARCH_CONVERT) * 16) 562 if ((dp->i_afp->if_bytes + sf->hdr.count * 16) < context->bufsize) {
564 < context->bufsize) { 563 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
565 for (i = 0, sfe = &sf->list[0];
566 i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
567 attrnames_t *namesp; 564 attrnames_t *namesp;
568 565
569 if (((context->flags & ATTR_SECURE) != 0) != 566 if (((context->flags & ATTR_SECURE) != 0) !=
@@ -584,14 +581,13 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
584 if (context->flags & ATTR_KERNOVAL) { 581 if (context->flags & ATTR_KERNOVAL) {
585 ASSERT(context->flags & ATTR_KERNAMELS); 582 ASSERT(context->flags & ATTR_KERNAMELS);
586 context->count += namesp->attr_namelen + 583 context->count += namesp->attr_namelen +
587 INT_GET(sfe->namelen, ARCH_CONVERT) + 1; 584 sfe->namelen + 1;
588 } 585 }
589 else { 586 else {
590 if (xfs_attr_put_listent(context, namesp, 587 if (xfs_attr_put_listent(context, namesp,
591 (char *)sfe->nameval, 588 (char *)sfe->nameval,
592 (int)sfe->namelen, 589 (int)sfe->namelen,
593 (int)INT_GET(sfe->valuelen, 590 (int)sfe->valuelen))
594 ARCH_CONVERT)))
595 break; 591 break;
596 } 592 }
597 sfe = XFS_ATTR_SF_NEXTENTRY(sfe); 593 sfe = XFS_ATTR_SF_NEXTENTRY(sfe);
@@ -603,7 +599,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
603 /* 599 /*
604 * It didn't all fit, so we have to sort everything on hashval. 600 * It didn't all fit, so we have to sort everything on hashval.
605 */ 601 */
606 sbsize = INT_GET(sf->hdr.count, ARCH_CONVERT) * sizeof(*sbuf); 602 sbsize = sf->hdr.count * sizeof(*sbuf);
607 sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP); 603 sbp = sbuf = kmem_alloc(sbsize, KM_SLEEP);
608 604
609 /* 605 /*
@@ -611,8 +607,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
611 * the relevant info from only those that match into a buffer. 607 * the relevant info from only those that match into a buffer.
612 */ 608 */
613 nsbuf = 0; 609 nsbuf = 0;
614 for (i = 0, sfe = &sf->list[0]; 610 for (i = 0, sfe = &sf->list[0]; i < sf->hdr.count; i++) {
615 i < INT_GET(sf->hdr.count, ARCH_CONVERT); i++) {
616 if (unlikely( 611 if (unlikely(
617 ((char *)sfe < (char *)sf) || 612 ((char *)sfe < (char *)sf) ||
618 ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) { 613 ((char *)sfe >= ((char *)sf + dp->i_afp->if_bytes)))) {
@@ -696,7 +691,7 @@ xfs_attr_shortform_list(xfs_attr_list_context_t *context)
696 } else { 691 } else {
697 if (xfs_attr_put_listent(context, namesp, 692 if (xfs_attr_put_listent(context, namesp,
698 sbp->name, sbp->namelen, 693 sbp->name, sbp->namelen,
699 INT_GET(sbp->valuelen, ARCH_CONVERT))) 694 sbp->valuelen))
700 break; 695 break;
701 } 696 }
702 cursor->offset++; 697 cursor->offset++;
diff --git a/fs/xfs/xfs_attr_sf.h b/fs/xfs/xfs_attr_sf.h
index ffed6ca81a52..f67f917803b1 100644
--- a/fs/xfs/xfs_attr_sf.h
+++ b/fs/xfs/xfs_attr_sf.h
@@ -32,8 +32,8 @@ struct xfs_inode;
32 */ 32 */
33typedef struct xfs_attr_shortform { 33typedef struct xfs_attr_shortform {
34 struct xfs_attr_sf_hdr { /* constant-structure header block */ 34 struct xfs_attr_sf_hdr { /* constant-structure header block */
35 __uint16_t totsize; /* total bytes in shortform list */ 35 __be16 totsize; /* total bytes in shortform list */
36 __uint8_t count; /* count of active entries */ 36 __u8 count; /* count of active entries */
37 } hdr; 37 } hdr;
38 struct xfs_attr_sf_entry { 38 struct xfs_attr_sf_entry {
39 __uint8_t namelen; /* actual length of name (no NULL) */ 39 __uint8_t namelen; /* actual length of name (no NULL) */
@@ -66,8 +66,8 @@ typedef struct xfs_attr_sf_sort {
66#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \ 66#define XFS_ATTR_SF_NEXTENTRY(sfep) /* next entry in struct */ \
67 ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep))) 67 ((xfs_attr_sf_entry_t *)((char *)(sfep) + XFS_ATTR_SF_ENTSIZE(sfep)))
68#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \ 68#define XFS_ATTR_SF_TOTSIZE(dp) /* total space in use */ \
69 (INT_GET(((xfs_attr_shortform_t *) \ 69 (be16_to_cpu(((xfs_attr_shortform_t *) \
70 ((dp)->i_afp->if_u1.if_data))->hdr.totsize, ARCH_CONVERT)) 70 ((dp)->i_afp->if_u1.if_data))->hdr.totsize))
71 71
72#if defined(XFS_ATTR_TRACE) 72#if defined(XFS_ATTR_TRACE)
73/* 73/*
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index b1e95707e7cf..7d0ded05a467 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -506,7 +506,7 @@ xfs_iformat(
506 switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) { 506 switch (INT_GET(dip->di_core.di_aformat, ARCH_CONVERT)) {
507 case XFS_DINODE_FMT_LOCAL: 507 case XFS_DINODE_FMT_LOCAL:
508 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip); 508 atp = (xfs_attr_shortform_t *)XFS_DFORK_APTR(dip);
509 size = (int)INT_GET(atp->hdr.totsize, ARCH_CONVERT); 509 size = be16_to_cpu(atp->hdr.totsize);
510 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size); 510 error = xfs_iformat_local(ip, dip, XFS_ATTR_FORK, size);
511 break; 511 break;
512 case XFS_DINODE_FMT_EXTENTS: 512 case XFS_DINODE_FMT_EXTENTS: