Commit c20f2b96 authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] ufs endianness annotations

Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent e195afac
......@@ -235,7 +235,7 @@ void ufs_free_blocks (struct inode * inode, unsigned fragment, unsigned count) {
brelse (bh); \
}
unsigned ufs_new_fragments (struct inode * inode, u32 * p, unsigned fragment,
unsigned ufs_new_fragments (struct inode * inode, __fs32 * p, unsigned fragment,
unsigned goal, unsigned count, int * err )
{
struct super_block * sb;
......@@ -771,11 +771,11 @@ static void ufs_clusteracct(struct super_block * sb,
i = back + forw + 1;
if (i > uspi->s_contigsumsize)
i = uspi->s_contigsumsize;
fs32_add(sb, (u32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (i << 2)), cnt);
fs32_add(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (i << 2)), cnt);
if (back > 0)
fs32_sub(sb, (u32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (back << 2)), cnt);
fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (back << 2)), cnt);
if (forw > 0)
fs32_sub(sb, (u32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (forw << 2)), cnt);
fs32_sub(sb, (__fs32*)ubh_get_addr(UCPI_UBH, ucpi->c_clustersumoff + (forw << 2)), cnt);
}
......
......@@ -99,8 +99,8 @@ u64 ufs_frag_map(struct inode *inode, sector_t frag)
sector_t offsets[4], *p;
int depth = ufs_block_to_path(inode, frag >> uspi->s_fpbshift, offsets);
u64 ret = 0L;
u32 block;
u64 u2_block = 0L;
__fs32 block;
__fs64 u2_block = 0L;
unsigned flags = UFS_SB(sb)->s_flags;
u64 temp = 0L;
......@@ -126,7 +126,7 @@ u64 ufs_frag_map(struct inode *inode, sector_t frag)
bh = sb_bread(sb, uspi->s_sbbase + fs32_to_cpu(sb, block)+(n>>shift));
if (!bh)
goto out;
block = ((u32*) bh->b_data)[n & mask];
block = ((__fs32 *) bh->b_data)[n & mask];
brelse (bh);
if (!block)
goto out;
......@@ -148,7 +148,7 @@ u64 ufs_frag_map(struct inode *inode, sector_t frag)
bh = sb_bread(sb, temp +(u64) (n>>shift));
if (!bh)
goto out;
u2_block = ((u64*)bh->b_data)[n & mask];
u2_block = ((__fs64 *)bh->b_data)[n & mask];
brelse(bh);
if (!u2_block)
goto out;
......@@ -171,7 +171,7 @@ static struct buffer_head * ufs_inode_getfrag (struct inode *inode,
struct buffer_head * result;
unsigned block, blockoff, lastfrag, lastblock, lastblockoff;
unsigned tmp, goal;
u32 * p, * p2;
__fs32 * p, * p2;
unsigned flags = 0;
UFSD(("ENTER, ino %lu, fragment %u, new_fragment %u, required %u\n",
......@@ -303,7 +303,7 @@ static struct buffer_head * ufs_block_getfrag (struct inode *inode,
struct ufs_sb_private_info * uspi;
struct buffer_head * result;
unsigned tmp, goal, block, blockoff;
u32 * p;
__fs32 * p;
sb = inode->i_sb;
uspi = UFS_SB(sb)->s_uspi;
......@@ -322,7 +322,7 @@ static struct buffer_head * ufs_block_getfrag (struct inode *inode,
goto out;
}
p = (u32 *) bh->b_data + block;
p = (__fs32 *) bh->b_data + block;
repeat:
tmp = fs32_to_cpu(sb, *p);
if (tmp) {
......@@ -338,7 +338,7 @@ static struct buffer_head * ufs_block_getfrag (struct inode *inode,
}
}
if (block && (tmp = fs32_to_cpu(sb, ((u32*)bh->b_data)[block-1]) + uspi->s_fpb))
if (block && (tmp = fs32_to_cpu(sb, ((__fs32*)bh->b_data)[block-1]) + uspi->s_fpb))
goal = tmp + uspi->s_fpb;
else
goal = bh->b_blocknr + uspi->s_fpb;
......
......@@ -743,22 +743,22 @@ static int ufs_fill_super(struct super_block *sb, void *data, int silent)
/*
* Check ufs magic number
*/
switch ((uspi->fs_magic = __constant_le32_to_cpu(usb3->fs_magic))) {
sbi->s_bytesex = BYTESEX_LE;
switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) {
case UFS_MAGIC:
case UFS2_MAGIC:
case UFS_MAGIC_LFN:
case UFS_MAGIC_FEA:
case UFS_MAGIC_4GB:
sbi->s_bytesex = BYTESEX_LE;
goto magic_found;
}
switch ((uspi->fs_magic = __constant_be32_to_cpu(usb3->fs_magic))) {
sbi->s_bytesex = BYTESEX_BE;
switch ((uspi->fs_magic = fs32_to_cpu(sb, usb3->fs_magic))) {
case UFS_MAGIC:
case UFS2_MAGIC:
case UFS_MAGIC_LFN:
case UFS_MAGIC_FEA:
case UFS_MAGIC_4GB:
sbi->s_bytesex = BYTESEX_BE;
goto magic_found;
}
......
......@@ -22,22 +22,22 @@ enum {
BYTESEX_BE
};
static __inline u64
fs64_to_cpu(struct super_block *sbp, u64 n)
static inline u64
fs64_to_cpu(struct super_block *sbp, __fs64 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return le64_to_cpu(n);
return le64_to_cpu((__force __le64)n);
else
return be64_to_cpu(n);
return be64_to_cpu((__force __be64)n);
}
static __inline u64
static inline __fs64
cpu_to_fs64(struct super_block *sbp, u64 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return cpu_to_le64(n);
return (__force __fs64)cpu_to_le64(n);
else
return cpu_to_be64(n);
return (__force __fs64)cpu_to_be64(n);
}
static __inline u32
......@@ -59,75 +59,75 @@ fs64_sub(struct super_block *sbp, u32 *n, int d)
}
static __inline u32
fs32_to_cpu(struct super_block *sbp, u32 n)
fs32_to_cpu(struct super_block *sbp, __fs32 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return le32_to_cpu(n);
return le32_to_cpu((__force __le32)n);
else
return be32_to_cpu(n);
return be32_to_cpu((__force __be32)n);
}
static __inline u32
static inline __fs32
cpu_to_fs32(struct super_block *sbp, u32 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return cpu_to_le32(n);
return (__force __fs32)cpu_to_le32(n);
else
return cpu_to_be32(n);
return (__force __fs32)cpu_to_be32(n);
}
static __inline u32
fs32_add(struct super_block *sbp, u32 *n, int d)
static inline void
fs32_add(struct super_block *sbp, __fs32 *n, int d)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return *n = cpu_to_le32(le32_to_cpu(*n)+d);
*(__le32 *)n = cpu_to_le32(le32_to_cpu(*(__le32 *)n)+d);
else
return *n = cpu_to_be32(be32_to_cpu(*n)+d);
*(__be32 *)n = cpu_to_be32(be32_to_cpu(*(__be32 *)n)+d);
}
static __inline u32
fs32_sub(struct super_block *sbp, u32 *n, int d)
static inline void
fs32_sub(struct super_block *sbp, __fs32 *n, int d)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return *n = cpu_to_le32(le32_to_cpu(*n)-d);
*(__le32 *)n = cpu_to_le32(le32_to_cpu(*(__le32 *)n)-d);
else
return *n = cpu_to_be32(be32_to_cpu(*n)-d);
*(__be32 *)n = cpu_to_be32(be32_to_cpu(*(__be32 *)n)-d);
}
static __inline u16
fs16_to_cpu(struct super_block *sbp, u16 n)
static inline u16
fs16_to_cpu(struct super_block *sbp, __fs16 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return le16_to_cpu(n);
return le16_to_cpu((__force __le16)n);
else
return be16_to_cpu(n);
return be16_to_cpu((__force __be16)n);
}
static __inline u16
static inline __fs16
cpu_to_fs16(struct super_block *sbp, u16 n)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return cpu_to_le16(n);
return (__force __fs16)cpu_to_le16(n);
else
return cpu_to_be16(n);
return (__force __fs16)cpu_to_be16(n);
}
static __inline u16
fs16_add(struct super_block *sbp, u16 *n, int d)
static inline void
fs16_add(struct super_block *sbp, __fs16 *n, int d)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return *n = cpu_to_le16(le16_to_cpu(*n)+d);
*(__le16 *)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)+d);
else
return *n = cpu_to_be16(be16_to_cpu(*n)+d);
*(__be16 *)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)+d);
}
static __inline u16
fs16_sub(struct super_block *sbp, u16 *n, int d)
static inline void
fs16_sub(struct super_block *sbp, __fs16 *n, int d)
{
if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
return *n = cpu_to_le16(le16_to_cpu(*n)-d);
*(__le16 *)n = cpu_to_le16(le16_to_cpu(*(__le16 *)n)-d);
else
return *n = cpu_to_be16(be16_to_cpu(*n)-d);
*(__be16 *)n = cpu_to_be16(be16_to_cpu(*(__be16 *)n)-d);
}
#endif /* _UFS_SWAB_H */
......@@ -74,7 +74,7 @@ static int ufs_trunc_direct (struct inode * inode)
struct super_block * sb;
struct ufs_sb_private_info * uspi;
struct buffer_head * bh;
u32 * p;
__fs32 * p;
unsigned frag1, frag2, frag3, frag4, block1, block2;
unsigned frag_to_free, free_count;
unsigned i, j, tmp;
......@@ -199,13 +199,13 @@ next2:;
}
static int ufs_trunc_indirect (struct inode * inode, unsigned offset, u32 * p)
static int ufs_trunc_indirect (struct inode * inode, unsigned offset, __fs32 *p)
{
struct super_block * sb;
struct ufs_sb_private_info * uspi;
struct ufs_buffer_head * ind_ubh;
struct buffer_head * bh;
u32 * ind;
__fs32 * ind;
unsigned indirect_block, i, j, tmp;
unsigned frag_to_free, free_count;
int retry;
......@@ -296,13 +296,13 @@ next:;
return retry;
}
static int ufs_trunc_dindirect (struct inode * inode, unsigned offset, u32 * p)
static int ufs_trunc_dindirect (struct inode *inode, unsigned offset, __fs32 *p)
{
struct super_block * sb;
struct ufs_sb_private_info * uspi;
struct ufs_buffer_head * dind_bh;
unsigned i, tmp, dindirect_block;
u32 * dind;
__fs32 * dind;
int retry = 0;
UFSD(("ENTER\n"))
......@@ -371,7 +371,7 @@ static int ufs_trunc_tindirect (struct inode * inode)
struct ufs_sb_private_info * uspi;
struct ufs_buffer_head * tind_bh;
unsigned tindirect_block, tmp, i;
u32 * tind, * p;
__fs32 * tind, * p;
int retry;
UFSD(("ENTER\n"))
......@@ -449,9 +449,9 @@ void ufs_truncate (struct inode * inode)
while (1) {
retry = ufs_trunc_direct(inode);
retry |= ufs_trunc_indirect (inode, UFS_IND_BLOCK,
(u32 *) &ufsi->i_u1.i_data[UFS_IND_BLOCK]);
(__fs32 *) &ufsi->i_u1.i_data[UFS_IND_BLOCK]);
retry |= ufs_trunc_dindirect (inode, UFS_IND_BLOCK + uspi->s_apb,
(u32 *) &ufsi->i_u1.i_data[UFS_DIND_BLOCK]);
(__fs32 *) &ufsi->i_u1.i_data[UFS_DIND_BLOCK]);
retry |= ufs_trunc_tindirect (inode);
if (!retry)
break;
......
......@@ -72,20 +72,20 @@ ufs_get_fs_npsect(struct super_block *sb, struct ufs_super_block_first *usb1,
static inline u64
ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3)
{
u64 tmp;
__fs64 tmp;
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qbmask[1];
break;
case UFS_ST_SUNx86:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qbmask[1];
break;
case UFS_ST_44BSD:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qbmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qbmask[1];
break;
}
......@@ -95,20 +95,20 @@ ufs_get_fs_qbmask(struct super_block *sb, struct ufs_super_block_third *usb3)
static inline u64
ufs_get_fs_qfmask(struct super_block *sb, struct ufs_super_block_third *usb3)
{
u64 tmp;
__fs64 tmp;
switch (UFS_SB(sb)->s_flags & UFS_ST_MASK) {
case UFS_ST_SUN:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sun.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sun.fs_qfmask[1];
break;
case UFS_ST_SUNx86:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_sunx86.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_sunx86.fs_qfmask[1];
break;
case UFS_ST_44BSD:
((u32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0];
((u32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1];
((__fs32 *)&tmp)[0] = usb3->fs_u2.fs_44.fs_qfmask[0];
((__fs32 *)&tmp)[1] = usb3->fs_u2.fs_44.fs_qfmask[1];
break;
}
......@@ -273,11 +273,11 @@ extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head
((begin) & ~uspi->s_fmask))
#define ubh_get_addr16(ubh,begin) \
(((u16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
(((__fs16*)((ubh)->bh[(begin) >> (uspi->s_fshift-1)]->b_data)) + \
((begin) & (uspi->fsize>>1) - 1)))
#define ubh_get_addr32(ubh,begin) \
(((u32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \
(((__fs32*)((ubh)->bh[(begin) >> (uspi->s_fshift-2)]->b_data)) + \
((begin) & ((uspi->s_fsize>>2) - 1)))
#define ubh_get_addr ubh_get_addr8
......@@ -315,10 +315,10 @@ extern void _ubh_memcpyubh_(struct ufs_sb_private_info *, struct ufs_buffer_head
* Macros to access cylinder group array structures
*/
#define ubh_cg_blktot(ucpi,cylno) \
(*((__u32*)ubh_get_addr(UCPI_UBH, (ucpi)->c_btotoff + ((cylno) << 2))))
(*((__fs32*)ubh_get_addr(UCPI_UBH, (ucpi)->c_btotoff + ((cylno) << 2))))
#define ubh_cg_blks(ucpi,cylno,rpos) \
(*((__u16*)ubh_get_addr(UCPI_UBH, \
(*((__fs16*)ubh_get_addr(UCPI_UBH, \
(ucpi)->c_boff + (((cylno) * uspi->s_nrpos + (rpos)) << 1 ))))
/*
......@@ -476,7 +476,7 @@ static inline void _ubh_setblock_(struct ufs_sb_private_info * uspi,
}
static inline void ufs_fragacct (struct super_block * sb, unsigned blockmap,
unsigned * fraglist, int cnt)
__fs32 * fraglist, int cnt)
{
struct ufs_sb_private_info * uspi;
unsigned fragsize, pos;
......
This diff is collapsed.
......@@ -15,9 +15,9 @@
struct ufs_inode_info {
union {
__u32 i_data[15];
__fs32 i_data[15];
__u8 i_symlink[4*15];
__u64 u2_i_data[15];
__fs64 u2_i_data[15];
} i_u1;
__u32 i_flags;
__u32 i_gen;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment