aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_attr.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/xfs_attr.c')
-rw-r--r--fs/xfs/xfs_attr.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index e5e91e9c7e89..093fac476bda 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
1127 return(error); 1127 return(error);
1128 ASSERT(bp != NULL); 1128 ASSERT(bp != NULL);
1129 leaf = bp->data; 1129 leaf = bp->data;
1130 if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) 1130 if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
1131 != XFS_ATTR_LEAF_MAGIC)) {
1132 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, 1131 XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
1133 context->dp->i_mount, leaf); 1132 context->dp->i_mount, leaf);
1134 xfs_da_brelse(NULL, bp); 1133 xfs_da_brelse(NULL, bp);
@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1541 XFS_ATTR_FORK); 1540 XFS_ATTR_FORK);
1542 if (error) 1541 if (error)
1543 goto out; 1542 goto out;
1544 ASSERT(INT_GET(((xfs_attr_leafblock_t *) 1543 ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
1545 bp->data)->hdr.info.magic, ARCH_CONVERT) 1544 bp->data)->hdr.info.magic)
1546 == XFS_ATTR_LEAF_MAGIC); 1545 == XFS_ATTR_LEAF_MAGIC);
1547 1546
1548 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { 1547 if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1763 return(error); 1762 return(error);
1764 if (bp) { 1763 if (bp) {
1765 node = bp->data; 1764 node = bp->data;
1766 switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) { 1765 switch (be16_to_cpu(node->hdr.info.magic)) {
1767 case XFS_DA_NODE_MAGIC: 1766 case XFS_DA_NODE_MAGIC:
1768 xfs_attr_trace_l_cn("wrong blk", context, node); 1767 xfs_attr_trace_l_cn("wrong blk", context, node);
1769 xfs_da_brelse(NULL, bp); 1768 xfs_da_brelse(NULL, bp);
@@ -1771,18 +1770,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1771 break; 1770 break;
1772 case XFS_ATTR_LEAF_MAGIC: 1771 case XFS_ATTR_LEAF_MAGIC:
1773 leaf = bp->data; 1772 leaf = bp->data;
1774 if (cursor->hashval > 1773 if (cursor->hashval > be32_to_cpu(leaf->entries[
1775 INT_GET(leaf->entries[ 1774 be16_to_cpu(leaf->hdr.count)-1].hashval)) {
1776 INT_GET(leaf->hdr.count,
1777 ARCH_CONVERT)-1].hashval,
1778 ARCH_CONVERT)) {
1779 xfs_attr_trace_l_cl("wrong blk", 1775 xfs_attr_trace_l_cl("wrong blk",
1780 context, leaf); 1776 context, leaf);
1781 xfs_da_brelse(NULL, bp); 1777 xfs_da_brelse(NULL, bp);
1782 bp = NULL; 1778 bp = NULL;
1783 } else if (cursor->hashval <= 1779 } else if (cursor->hashval <=
1784 INT_GET(leaf->entries[0].hashval, 1780 be32_to_cpu(leaf->entries[0].hashval)) {
1785 ARCH_CONVERT)) {
1786 xfs_attr_trace_l_cl("maybe wrong blk", 1781 xfs_attr_trace_l_cl("maybe wrong blk",
1787 context, leaf); 1782 context, leaf);
1788 xfs_da_brelse(NULL, bp); 1783 xfs_da_brelse(NULL, bp);
@@ -1817,10 +1812,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1817 return(XFS_ERROR(EFSCORRUPTED)); 1812 return(XFS_ERROR(EFSCORRUPTED));
1818 } 1813 }
1819 node = bp->data; 1814 node = bp->data;
1820 if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) 1815 if (be16_to_cpu(node->hdr.info.magic)
1821 == XFS_ATTR_LEAF_MAGIC) 1816 == XFS_ATTR_LEAF_MAGIC)
1822 break; 1817 break;
1823 if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT) 1818 if (unlikely(be16_to_cpu(node->hdr.info.magic)
1824 != XFS_DA_NODE_MAGIC)) { 1819 != XFS_DA_NODE_MAGIC)) {
1825 XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", 1820 XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
1826 XFS_ERRLEVEL_LOW, 1821 XFS_ERRLEVEL_LOW,
@@ -1830,19 +1825,17 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1830 return(XFS_ERROR(EFSCORRUPTED)); 1825 return(XFS_ERROR(EFSCORRUPTED));
1831 } 1826 }
1832 btree = node->btree; 1827 btree = node->btree;
1833 for (i = 0; 1828 for (i = 0; i < be16_to_cpu(node->hdr.count);
1834 i < INT_GET(node->hdr.count, ARCH_CONVERT);
1835 btree++, i++) { 1829 btree++, i++) {
1836 if (cursor->hashval 1830 if (cursor->hashval
1837 <= INT_GET(btree->hashval, 1831 <= be32_to_cpu(btree->hashval)) {
1838 ARCH_CONVERT)) { 1832 cursor->blkno = be32_to_cpu(btree->before);
1839 cursor->blkno = INT_GET(btree->before, ARCH_CONVERT);
1840 xfs_attr_trace_l_cb("descending", 1833 xfs_attr_trace_l_cb("descending",
1841 context, btree); 1834 context, btree);
1842 break; 1835 break;
1843 } 1836 }
1844 } 1837 }
1845 if (i == INT_GET(node->hdr.count, ARCH_CONVERT)) { 1838 if (i == be16_to_cpu(node->hdr.count)) {
1846 xfs_da_brelse(NULL, bp); 1839 xfs_da_brelse(NULL, bp);
1847 return(0); 1840 return(0);
1848 } 1841 }
@@ -1858,7 +1851,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1858 */ 1851 */
1859 for (;;) { 1852 for (;;) {
1860 leaf = bp->data; 1853 leaf = bp->data;
1861 if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) 1854 if (unlikely(be16_to_cpu(leaf->hdr.info.magic)
1862 != XFS_ATTR_LEAF_MAGIC)) { 1855 != XFS_ATTR_LEAF_MAGIC)) {
1863 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", 1856 XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
1864 XFS_ERRLEVEL_LOW, 1857 XFS_ERRLEVEL_LOW,
@@ -1869,7 +1862,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1869 error = xfs_attr_leaf_list_int(bp, context); 1862 error = xfs_attr_leaf_list_int(bp, context);
1870 if (error || !leaf->hdr.info.forw) 1863 if (error || !leaf->hdr.info.forw)
1871 break; /* not really an error, buffer full or EOF */ 1864 break; /* not really an error, buffer full or EOF */
1872 cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT); 1865 cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
1873 xfs_da_brelse(NULL, bp); 1866 xfs_da_brelse(NULL, bp);
1874 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, 1867 error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
1875 &bp, XFS_ATTR_FORK); 1868 &bp, XFS_ATTR_FORK);
@@ -2232,9 +2225,10 @@ xfs_attr_trace_l_cn(char *where, struct xfs_attr_list_context *context,
2232 : 0, 2225 : 0,
2233 (__psunsigned_t)context->dupcnt, 2226 (__psunsigned_t)context->dupcnt,
2234 (__psunsigned_t)context->flags, 2227 (__psunsigned_t)context->flags,
2235 (__psunsigned_t)INT_GET(node->hdr.count, ARCH_CONVERT), 2228 (__psunsigned_t)be16_to_cpu(node->hdr.count),
2236 (__psunsigned_t)INT_GET(node->btree[0].hashval, ARCH_CONVERT), 2229 (__psunsigned_t)be32_to_cpu(node->btree[0].hashval),
2237 (__psunsigned_t)INT_GET(node->btree[INT_GET(node->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); 2230 (__psunsigned_t)be32_to_cpu(node->btree[
2231 be16_to_cpu(node->hdr.count)-1].hashval));
2238} 2232}
2239 2233
2240/* 2234/*
@@ -2261,8 +2255,8 @@ xfs_attr_trace_l_cb(char *where, struct xfs_attr_list_context *context,
2261 : 0, 2255 : 0,
2262 (__psunsigned_t)context->dupcnt, 2256 (__psunsigned_t)context->dupcnt,
2263 (__psunsigned_t)context->flags, 2257 (__psunsigned_t)context->flags,
2264 (__psunsigned_t)INT_GET(btree->hashval, ARCH_CONVERT), 2258 (__psunsigned_t)be32_to_cpu(btree->hashval),
2265 (__psunsigned_t)INT_GET(btree->before, ARCH_CONVERT), 2259 (__psunsigned_t)be32_to_cpu(btree->before),
2266 (__psunsigned_t)NULL); 2260 (__psunsigned_t)NULL);
2267} 2261}
2268 2262
@@ -2290,9 +2284,10 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
2290 : 0, 2284 : 0,
2291 (__psunsigned_t)context->dupcnt, 2285 (__psunsigned_t)context->dupcnt,
2292 (__psunsigned_t)context->flags, 2286 (__psunsigned_t)context->flags,
2293 (__psunsigned_t)INT_GET(leaf->hdr.count, ARCH_CONVERT), 2287 (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
2294 (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT), 2288 (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
2295 (__psunsigned_t)INT_GET(leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1].hashval, ARCH_CONVERT)); 2289 (__psunsigned_t)be32_to_cpu(leaf->entries[
2290 be16_to_cpu(leaf->hdr.count)-1].hashval));
2296} 2291}
2297 2292
2298/* 2293/*
@@ -2522,7 +2517,7 @@ attr_user_capable(
2522 struct vnode *vp, 2517 struct vnode *vp,
2523 cred_t *cred) 2518 cred_t *cred)
2524{ 2519{
2525 struct inode *inode = LINVFS_GET_IP(vp); 2520 struct inode *inode = vn_to_inode(vp);
2526 2521
2527 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 2522 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2528 return -EPERM; 2523 return -EPERM;
@@ -2540,7 +2535,7 @@ attr_trusted_capable(
2540 struct vnode *vp, 2535 struct vnode *vp,
2541 cred_t *cred) 2536 cred_t *cred)
2542{ 2537{
2543 struct inode *inode = LINVFS_GET_IP(vp); 2538 struct inode *inode = vn_to_inode(vp);
2544 2539
2545 if (IS_IMMUTABLE(inode) || IS_APPEND(inode)) 2540 if (IS_IMMUTABLE(inode) || IS_APPEND(inode))
2546 return -EPERM; 2541 return -EPERM;