summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Viro <viro@parcelfarce.linux.theplanet.co.uk>2004-09-08 20:35:38 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-09-08 20:35:38 -0700
commit380768f5a50524ff7eab00d03d82a56cf2fdfe7b (patch)
treef55a7bd455e657d112e0885cb7146838942cb95e
parent64d7cc85eed5df8c348218e24939fc760ccbbd54 (diff)
[PATCH] affs endianness annotations
AFFS partially annotated - some fields of on-disk structures are never used and while I'm reasonably sure that they ought to be big-endian, I'd rather leave them alone for now; annotating them won't change the amount of noise since nothing in the kernel ever accesses them. Signed-off-by: Al Viro <viro@parcelfarce.linux.org.uk> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--fs/affs/amigaffs.c26
-rw-r--r--fs/affs/bitmap.c42
-rw-r--r--fs/affs/inode.c4
-rw-r--r--fs/affs/super.c6
-rw-r--r--include/linux/affs_hardblocks.h14
-rw-r--r--include/linux/amigaffs.h112
6 files changed, 103 insertions, 101 deletions
diff --git a/fs/affs/amigaffs.c b/fs/affs/amigaffs.c
index 17a4bfbb1f58..1ad6291679ec 100644
--- a/fs/affs/amigaffs.c
+++ b/fs/affs/amigaffs.c
@@ -84,7 +84,8 @@ affs_remove_hash(struct inode *dir, struct buffer_head *rem_bh)
{
struct super_block *sb;
struct buffer_head *bh;
- u32 rem_ino, hash_ino, ino;
+ u32 rem_ino, hash_ino;
+ __be32 ino;
int offset, retval;
sb = dir->i_sb;
@@ -203,9 +204,9 @@ affs_remove_link(struct dentry *dentry)
while ((ino = be32_to_cpu(AFFS_TAIL(sb, bh)->link_chain)) != 0) {
if (ino == link_ino) {
- ino = AFFS_TAIL(sb, link_bh)->link_chain;
- AFFS_TAIL(sb, bh)->link_chain = ino;
- affs_adjust_checksum(bh, be32_to_cpu(ino) - link_ino);
+ __be32 ino2 = AFFS_TAIL(sb, link_bh)->link_chain;
+ AFFS_TAIL(sb, bh)->link_chain = ino2;
+ affs_adjust_checksum(bh, be32_to_cpu(ino2) - link_ino);
mark_buffer_dirty_inode(bh, inode);
retval = 0;
/* Fix the link count, if bh is a normal header block without links */
@@ -341,12 +342,12 @@ done_unlock:
u32
affs_checksum_block(struct super_block *sb, struct buffer_head *bh)
{
- u32 *ptr = (u32 *)bh->b_data;
+ __be32 *ptr = (__be32 *)bh->b_data;
u32 sum;
int bsize;
sum = 0;
- for (bsize = sb->s_blocksize / sizeof(u32); bsize > 0; bsize--)
+ for (bsize = sb->s_blocksize / sizeof(__be32); bsize > 0; bsize--)
sum += be32_to_cpu(*ptr++);
return sum;
}
@@ -359,9 +360,10 @@ affs_checksum_block(struct super_block *sb, struct buffer_head *bh)
void
affs_fix_checksum(struct super_block *sb, struct buffer_head *bh)
{
- int cnt = sb->s_blocksize / sizeof(u32);
- u32 *ptr = (u32 *)bh->b_data;
- u32 checksum, *checksumptr;
+ int cnt = sb->s_blocksize / sizeof(__be32);
+ __be32 *ptr = (__be32 *)bh->b_data;
+ u32 checksum;
+ __be32 *checksumptr;
checksumptr = ptr + 5;
*checksumptr = 0;
@@ -384,9 +386,9 @@ secs_to_datestamp(time_t secs, struct affs_date *ds)
minute = secs / 60;
secs -= minute * 60;
- ds->days = be32_to_cpu(days);
- ds->mins = be32_to_cpu(minute);
- ds->ticks = be32_to_cpu(secs * 50);
+ ds->days = cpu_to_be32(days);
+ ds->mins = cpu_to_be32(minute);
+ ds->ticks = cpu_to_be32(secs * 50);
}
mode_t
diff --git a/fs/affs/bitmap.c b/fs/affs/bitmap.c
index 5574bbd3da3a..44e322143e39 100644
--- a/fs/affs/bitmap.c
+++ b/fs/affs/bitmap.c
@@ -72,7 +72,7 @@ affs_free_block(struct super_block *sb, u32 block)
struct affs_bm_info *bm;
struct buffer_head *bh;
u32 blk, bmap, bit, mask, tmp;
- u32 *data;
+ __be32 *data;
pr_debug("AFFS: free_block(%u)\n", block);
@@ -97,7 +97,7 @@ affs_free_block(struct super_block *sb, u32 block)
}
mask = 1 << (bit & 31);
- data = (u32 *)bh->b_data + bit / 32 + 1;
+ data = (__be32 *)bh->b_data + bit / 32 + 1;
/* mark block free */
tmp = be32_to_cpu(*data);
@@ -106,8 +106,8 @@ affs_free_block(struct super_block *sb, u32 block)
*data = cpu_to_be32(tmp | mask);
/* fix checksum */
- tmp = be32_to_cpu(*(u32 *)bh->b_data);
- *(u32 *)bh->b_data = cpu_to_be32(tmp - mask);
+ tmp = be32_to_cpu(*(__be32 *)bh->b_data);
+ *(__be32 *)bh->b_data = cpu_to_be32(tmp - mask);
mark_buffer_dirty(bh);
sb->s_dirt = 1;
@@ -149,7 +149,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
struct affs_sb_info *sbi;
struct affs_bm_info *bm;
struct buffer_head *bh;
- u32 *data, *enddata;
+ __be32 *data, *enddata;
u32 blk, bmap, bit, mask, mask2, tmp;
int i;
@@ -211,8 +211,8 @@ find_bmap_bit:
/* find an unused block in this bitmap block */
bit = blk % sbi->s_bmap_bits;
- data = (u32 *)bh->b_data + bit / 32 + 1;
- enddata = (u32 *)((u8 *)bh->b_data + sb->s_blocksize);
+ data = (__be32 *)bh->b_data + bit / 32 + 1;
+ enddata = (__be32 *)((u8 *)bh->b_data + sb->s_blocksize);
mask = ~0UL << (bit & 31);
blk &= ~31UL;
@@ -228,8 +228,8 @@ find_bmap_bit:
* if scan didn't start at 0, try next bmap
*/
goto find_bmap;
- } while (!(tmp = *data));
- tmp = be32_to_cpu(tmp);
+ } while (!*data);
+ tmp = be32_to_cpu(*data);
mask = ~0;
find_bit:
@@ -251,8 +251,8 @@ find_bit:
*data = cpu_to_be32(tmp & ~mask);
/* fix checksum */
- tmp = be32_to_cpu(*(u32 *)bh->b_data);
- *(u32 *)bh->b_data = cpu_to_be32(tmp + mask);
+ tmp = be32_to_cpu(*(__be32 *)bh->b_data);
+ *(__be32 *)bh->b_data = cpu_to_be32(tmp + mask);
mark_buffer_dirty(bh);
sb->s_dirt = 1;
@@ -276,7 +276,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
{
struct affs_bm_info *bm;
struct buffer_head *bmap_bh = NULL, *bh = NULL;
- u32 *bmap_blk;
+ __be32 *bmap_blk;
u32 size, blk, end, offset, mask;
int i, res = 0;
struct affs_sb_info *sbi = AFFS_SB(sb);
@@ -304,7 +304,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
}
memset(sbi->s_bitmap, 0, size);
- bmap_blk = (u32 *)sbi->s_root_bh->b_data;
+ bmap_blk = (__be32 *)sbi->s_root_bh->b_data;
blk = sb->s_blocksize / 4 - 49;
end = blk + 25;
@@ -340,7 +340,7 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
res = -EIO;
goto out;
}
- bmap_blk = (u32 *)bmap_bh->b_data;
+ bmap_blk = (__be32 *)bmap_bh->b_data;
blk = 0;
end = sb->s_blocksize / 4 - 1;
}
@@ -354,23 +354,23 @@ int affs_init_bitmap(struct super_block *sb, int *flags)
u32 old, new;
/* Mark unused bits in the last word as allocated */
- old = be32_to_cpu(((u32 *)bh->b_data)[offset]);
+ old = be32_to_cpu(((__be32 *)bh->b_data)[offset]);
new = old & mask;
//if (old != new) {
- ((u32 *)bh->b_data)[offset] = cpu_to_be32(new);
+ ((__be32 *)bh->b_data)[offset] = cpu_to_be32(new);
/* fix checksum */
//new -= old;
- //old = be32_to_cpu(*(u32 *)bh->b_data);
- //*(u32 *)bh->b_data = cpu_to_be32(old - new);
+ //old = be32_to_cpu(*(__be32 *)bh->b_data);
+ //*(__be32 *)bh->b_data = cpu_to_be32(old - new);
//mark_buffer_dirty(bh);
//}
/* correct offset for the bitmap count below */
//offset++;
}
while (++offset < sb->s_blocksize / 4)
- ((u32 *)bh->b_data)[offset] = 0;
- ((u32 *)bh->b_data)[0] = 0;
- ((u32 *)bh->b_data)[0] = cpu_to_be32(-affs_checksum_block(sb, bh));
+ ((__be32 *)bh->b_data)[offset] = 0;
+ ((__be32 *)bh->b_data)[0] = 0;
+ ((__be32 *)bh->b_data)[0] = cpu_to_be32(-affs_checksum_block(sb, bh));
mark_buffer_dirty(bh);
/* recalculate bitmap count for last block */
diff --git a/fs/affs/inode.c b/fs/affs/inode.c
index f94afc028e2c..9f929f70640c 100644
--- a/fs/affs/inode.c
+++ b/fs/affs/inode.c
@@ -201,7 +201,7 @@ affs_write_inode(struct inode *inode, int unused)
return;
}
tail = AFFS_TAIL(sb, bh);
- if (tail->stype == be32_to_cpu(ST_ROOT)) {
+ if (tail->stype == cpu_to_be32(ST_ROOT)) {
secs_to_datestamp(inode->i_mtime.tv_sec,&AFFS_ROOT_TAIL(sb, bh)->root_change);
} else {
tail->protect = cpu_to_be32(AFFS_I(inode)->i_protect);
@@ -396,7 +396,7 @@ affs_add_entry(struct inode *dir, struct inode *inode, struct dentry *dentry, s3
AFFS_TAIL(sb, bh)->parent = cpu_to_be32(dir->i_ino);
if (inode_bh) {
- u32 chain;
+ __be32 chain;
chain = AFFS_TAIL(sb, inode_bh)->link_chain;
AFFS_TAIL(sb, bh)->original = cpu_to_be32(inode->i_ino);
AFFS_TAIL(sb, bh)->link_chain = chain;
diff --git a/fs/affs/super.c b/fs/affs/super.c
index a0358130f498..073e80cbed85 100644
--- a/fs/affs/super.c
+++ b/fs/affs/super.c
@@ -44,7 +44,7 @@ affs_put_super(struct super_block *sb)
pr_debug("AFFS: put_super()\n");
if (!(sb->s_flags & MS_RDONLY)) {
- AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(1);
+ AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(1);
secs_to_datestamp(get_seconds(),
&AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
affs_fix_checksum(sb, sbi->s_root_bh);
@@ -70,7 +70,7 @@ affs_write_super(struct super_block *sb)
// if (sbi->s_bitmap[i].bm_bh) {
// if (buffer_dirty(sbi->s_bitmap[i].bm_bh)) {
// clean = 0;
- AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = be32_to_cpu(clean);
+ AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->bm_flag = cpu_to_be32(clean);
secs_to_datestamp(get_seconds(),
&AFFS_ROOT_TAIL(sb, sbi->s_root_bh)->disk_change);
affs_fix_checksum(sb, sbi->s_root_bh);
@@ -387,7 +387,7 @@ got_root:
printk(KERN_ERR "AFFS: Cannot read boot block\n");
goto out_error;
}
- chksum = be32_to_cpu(*(u32 *)boot_bh->b_data);
+ chksum = be32_to_cpu(*(__be32 *)boot_bh->b_data);
brelse(boot_bh);
/* Dircache filesystems are compatible with non-dircache ones
diff --git a/include/linux/affs_hardblocks.h b/include/linux/affs_hardblocks.h
index ae893e022f1a..3fb869939d82 100644
--- a/include/linux/affs_hardblocks.h
+++ b/include/linux/affs_hardblocks.h
@@ -5,13 +5,13 @@
struct RigidDiskBlock {
u32 rdb_ID;
- u32 rdb_SummedLongs;
+ __be32 rdb_SummedLongs;
s32 rdb_ChkSum;
u32 rdb_HostID;
- u32 rdb_BlockBytes;
+ __be32 rdb_BlockBytes;
u32 rdb_Flags;
u32 rdb_BadBlockList;
- u32 rdb_PartitionList;
+ __be32 rdb_PartitionList;
u32 rdb_FileSysHeaderList;
u32 rdb_DriveInit;
u32 rdb_Reserved1[6];
@@ -45,17 +45,17 @@ struct RigidDiskBlock {
#define IDNAME_RIGIDDISK 0x5244534B /* "RDSK" */
struct PartitionBlock {
- u32 pb_ID;
- u32 pb_SummedLongs;
+ __be32 pb_ID;
+ __be32 pb_SummedLongs;
s32 pb_ChkSum;
u32 pb_HostID;
- u32 pb_Next;
+ __be32 pb_Next;
u32 pb_Flags;
u32 pb_Reserved1[2];
u32 pb_DevFlags;
u8 pb_DriveName[32];
u32 pb_Reserved2[15];
- u32 pb_Environment[17];
+ __be32 pb_Environment[17];
u32 pb_EReserved[15];
};
diff --git a/include/linux/amigaffs.h b/include/linux/amigaffs.h
index 6fb6bb5c6696..b9a0ee68cbcf 100644
--- a/include/linux/amigaffs.h
+++ b/include/linux/amigaffs.h
@@ -80,14 +80,14 @@ affs_brelse(struct buffer_head *bh)
static inline void
affs_adjust_checksum(struct buffer_head *bh, u32 val)
{
- u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[5]);
- ((u32 *)bh->b_data)[5] = cpu_to_be32(tmp - val);
+ u32 tmp = be32_to_cpu(((__be32 *)bh->b_data)[5]);
+ ((__be32 *)bh->b_data)[5] = cpu_to_be32(tmp - val);
}
static inline void
affs_adjust_bitmapchecksum(struct buffer_head *bh, u32 val)
{
- u32 tmp = be32_to_cpu(((u32 *)bh->b_data)[0]);
- ((u32 *)bh->b_data)[0] = cpu_to_be32(tmp - val);
+ u32 tmp = be32_to_cpu(((__be32 *)bh->b_data)[0]);
+ ((__be32 *)bh->b_data)[0] = cpu_to_be32(tmp - val);
}
static inline void
@@ -164,89 +164,89 @@ affs_unlock_ext(struct inode *inode)
#define AFFS_DATA(bh) (((struct affs_data_head *)(bh)->b_data)->data)
struct affs_date {
- u32 days;
- u32 mins;
- u32 ticks;
+ __be32 days;
+ __be32 mins;
+ __be32 ticks;
};
struct affs_short_date {
- u16 days;
- u16 mins;
- u16 ticks;
+ __be16 days;
+ __be16 mins;
+ __be16 ticks;
};
struct affs_root_head {
- u32 ptype;
- u32 spare1;
- u32 spare2;
- u32 hash_size;
- u32 spare3;
- u32 checksum;
- u32 hashtable[1];
+ __be32 ptype;
+ __be32 spare1;
+ __be32 spare2;
+ __be32 hash_size;
+ __be32 spare3;
+ __be32 checksum;
+ __be32 hashtable[1];
};
struct affs_root_tail {
- u32 bm_flag;
- u32 bm_blk[AFFS_ROOT_BMAPS];
- u32 bm_ext;
+ __be32 bm_flag;
+ __be32 bm_blk[AFFS_ROOT_BMAPS];
+ __be32 bm_ext;
struct affs_date root_change;
u8 disk_name[32];
- u32 spare1;
- u32 spare2;
+ __be32 spare1;
+ __be32 spare2;
struct affs_date disk_change;
struct affs_date disk_create;
- u32 spare3;
- u32 spare4;
- u32 dcache;
- u32 stype;
+ __be32 spare3;
+ __be32 spare4;
+ __be32 dcache;
+ __be32 stype;
};
struct affs_head {
- u32 ptype;
- u32 key;
- u32 block_count;
- u32 spare1;
- u32 first_data;
- u32 checksum;
- u32 table[1];
+ __be32 ptype;
+ __be32 key;
+ __be32 block_count;
+ __be32 spare1;
+ __be32 first_data;
+ __be32 checksum;
+ __be32 table[1];
};
struct affs_tail {
- u32 spare1;
- u16 uid;
- u16 gid;
- u32 protect;
- u32 size;
+ __be32 spare1;
+ __be16 uid;
+ __be16 gid;
+ __be32 protect;
+ __be32 size;
u8 comment[92];
struct affs_date change;
u8 name[32];
- u32 spare2;
- u32 original;
- u32 link_chain;
- u32 spare[5];
- u32 hash_chain;
- u32 parent;
- u32 extension;
- u32 stype;
+ __be32 spare2;
+ __be32 original;
+ __be32 link_chain;
+ __be32 spare[5];
+ __be32 hash_chain;
+ __be32 parent;
+ __be32 extension;
+ __be32 stype;
};
struct slink_front
{
- u32 ptype;
- u32 key;
- u32 spare1[3];
- u32 checksum;
+ __be32 ptype;
+ __be32 key;
+ __be32 spare1[3];
+ __be32 checksum;
u8 symname[1]; /* depends on block size */
};
struct affs_data_head
{
- u32 ptype;
- u32 key;
- u32 sequence;
- u32 size;
- u32 next;
- u32 checksum;
+ __be32 ptype;
+ __be32 key;
+ __be32 sequence;
+ __be32 size;
+ __be32 next;
+ __be32 checksum;
u8 data[1]; /* depends on block size */
};