From f5d2a488b2c254176e6ba40fee47bd28368a4ab8 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Thu, 3 Apr 2003 21:58:27 +0000 Subject: [PATCH] kernel / libxfs sync-up Implement get_unaligned / put_unaligned in libxfs Change typecasts to a type available in kernel & userspace Bump version --- VERSION | 2 +- doc/CHANGES | 4 ++++ libxfs/xfs.h | 9 +++++++++ libxfs/xfs_inode.c | 12 ++++++++---- 4 files changed, 22 insertions(+), 5 deletions(-) diff --git a/VERSION b/VERSION index 3d294f97a..defdf9551 100644 --- a/VERSION +++ b/VERSION @@ -3,5 +3,5 @@ # PKG_MAJOR=2 PKG_MINOR=4 -PKG_REVISION=4 +PKG_REVISION=5 PKG_BUILD=0 diff --git a/doc/CHANGES b/doc/CHANGES index fc7d69979..c962ba0de 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +xfsprogs-2.4.5 (03 April 2003) + - Sync up xfs_inode.c in libxfs + - Implement get_unaligned/put_unaligned in libxfs + xfsprogs-2.4.4 (30 March 2003) - Correct display of imaxpct in mkfs.xfs output. - Portability changes; including some code to support use diff --git a/libxfs/xfs.h b/libxfs/xfs.h index 0059cf0bf..bb281f414 100644 --- a/libxfs/xfs.h +++ b/libxfs/xfs.h @@ -284,6 +284,15 @@ typedef struct { dev_t dev; } xfs_buftarg_t; #define XFS_TRANS_UNRESERVE_BLKQUOTA(mp,tp,ip,nblks) #define XFS_TRANS_RESERVE_QUOTA_NBLKS(mp,tp,ip,nblks,ninos,fl) +/* These are lifted from the kernel */ +#define get_unaligned(ptr) \ + ({ __typeof__(*(ptr)) __tmp; memmove(&__tmp, (ptr), sizeof(*(ptr))); __tmp; }) + +#define put_unaligned(val, ptr) \ + ({ __typeof__(*(ptr)) __tmp = (val); \ + memmove((ptr), &__tmp, sizeof(*(ptr))); \ + (void)0; }) + #if (__GNUC__ < 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ <= 95)) # define xfs_fs_cmn_err(a,b,msg,args...)( fprintf(stderr, msg, ## args) ) # define cmn_err(a,msg,args...) ( fprintf(stderr, msg, ## args) ) diff --git a/libxfs/xfs_inode.c b/libxfs/xfs_inode.c index 1549451dc..adc4b557e 100644 --- a/libxfs/xfs_inode.c +++ b/libxfs/xfs_inode.c @@ -477,8 +477,10 @@ xfs_iformat_extents( ep = ifp->if_u1.if_extents; #if ARCH_CONVERT != ARCH_NOCONVERT for (i = 0; i < nex; i++, ep++, dp++) { - ep->l0 = INT_GET(dp->l0, ARCH_CONVERT); - ep->l1 = INT_GET(dp->l1, ARCH_CONVERT); + ep->l0 = INT_GET(get_unaligned((__uint64_t*)&dp->l0), + ARCH_CONVERT); + ep->l1 = INT_GET(get_unaligned((__uint64_t*)&dp->l1), + ARCH_CONVERT); } #else memcpy(ep, dp, size); @@ -1312,8 +1314,10 @@ xfs_iextents_copy( #if ARCH_CONVERT != ARCH_NOCONVERT /* Translate to on disk format */ - dest_ep->l0 = INT_GET(ep->l0, ARCH_CONVERT); - dest_ep->l1 = INT_GET(ep->l1, ARCH_CONVERT); + put_unaligned(INT_GET(ep->l0, ARCH_CONVERT), + (__uint64_t*)&dest_ep->l0); + put_unaligned(INT_GET(ep->l1, ARCH_CONVERT), + (__uint64_t*)&dest_ep->l1); #else *dest_ep = *ep; #endif -- 2.47.2