[PATCH 6/6] xfs: pad xfs_attr_leaf_name_remote to avoid tripping on m68k

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>

Pad the xfs_attr_leaf_name_remote so that we don't trip the structure
size checker on m68k.

[dchinner: add comment, XFS_ATTR_LEAF_NAME_BYTES constant and make sure
	   xfs_attr_leaf_entsize_remote() does the right thing. ]

Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
Signed-off-by: Dave Chinner <david@xxxxxxxxxxxxx>
---
 fs/xfs/libxfs/xfs_da_format.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/fs/xfs/libxfs/xfs_da_format.h b/fs/xfs/libxfs/xfs_da_format.h
index 8d4d8bc..b6d58f6 100644
--- a/fs/xfs/libxfs/xfs_da_format.h
+++ b/fs/xfs/libxfs/xfs_da_format.h
@@ -686,11 +686,19 @@ typedef struct xfs_attr_leaf_name_local {
 	__u8	nameval[1];		/* name/value bytes */
 } xfs_attr_leaf_name_local_t;
 
+/*
+ * some platforms (like m68k) don't like non-word sized structures and pad them
+ * out inappropriately. To work around this, we set the name array to the size
+ * that pads out to a 4 byte word size. We need to take this away from the size
+ * of the structure when calculating the length of the entry in
+ * xfs_attr_leaf_entsize_remote(), hence we define a constant for this value.
+ */
+#define XFS_ATTR_LEAF_NAME_BYTES	3
 typedef struct xfs_attr_leaf_name_remote {
 	__be32	valueblk;		/* block number of value bytes */
 	__be32	valuelen;		/* number of bytes in value */
 	__u8	namelen;		/* length of name bytes */
-	__u8	name[1];		/* name bytes */
+	__u8	name[XFS_ATTR_LEAF_NAME_BYTES];	/* name bytes */
 } xfs_attr_leaf_name_remote_t;
 
 typedef struct xfs_attr_leafblock {
@@ -847,8 +855,10 @@ xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
  */
 static inline int xfs_attr_leaf_entsize_remote(int nlen)
 {
-	return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
-		XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
+	return ((uint)sizeof(xfs_attr_leaf_name_remote_t) -
+		      XFS_ATTR_LEAF_NAME_BYTES + nlen +
+		      XFS_ATTR_LEAF_NAME_ALIGN - 1) &
+	       ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
 }
 
 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
-- 
2.7.0

_______________________________________________
xfs mailing list
xfs@xxxxxxxxxxx
http://oss.sgi.com/mailman/listinfo/xfs



[Index of Archives]     [Linux XFS Devel]     [Linux Filesystem Development]     [Filesystem Testing]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux