endian-annotate most on-disk structures

This annotates most on-disk structures for endianness;
however it does not annotate some, like the superblock, inodes,
mmp, etc, as these are swapped in-place at this point.  This is
a little inconsistent, but should help catch some endian mistakes,
at least.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
crypto
Eric Sandeen 2014-11-04 11:24:56 -05:00 committed by Theodore Ts'o
parent 387e03160c
commit 1224c0d3ea
6 changed files with 48 additions and 47 deletions

View File

@ -233,21 +233,21 @@ struct ext2_dx_root_info {
#define EXT2_HASH_FLAG_INCOMPAT 0x1 #define EXT2_HASH_FLAG_INCOMPAT 0x1
struct ext2_dx_entry { struct ext2_dx_entry {
__u32 hash; __le32 hash;
__u32 block; __le32 block;
}; };
struct ext2_dx_countlimit { struct ext2_dx_countlimit {
__u16 limit; __le16 limit;
__u16 count; __le16 count;
}; };
/* /*
* This goes at the end of each htree block. * This goes at the end of each htree block.
*/ */
struct ext2_dx_tail { struct ext2_dx_tail {
__u32 dt_reserved; __le32 dt_reserved;
__u32 dt_checksum; /* crc32c(uuid+inum+dxblock) */ __le32 dt_checksum; /* crc32c(uuid+inum+dxblock) */
}; };
/* /*
@ -894,6 +894,7 @@ struct ext2_dir_entry_tail {
#define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */ #define EXT4_MMP_SEQ_FSCK 0xE24D4D50U /* mmp_seq value when being fscked */
#define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */ #define EXT4_MMP_SEQ_MAX 0xE24D4D4FU /* maximum valid mmp_seq value */
/* Not endian-annotated; it's swapped at read/write time */
struct mmp_struct { struct mmp_struct {
__u32 mmp_magic; /* Magic number for MMP */ __u32 mmp_magic; /* Magic number for MMP */
__u32 mmp_seq; /* Sequence no. updated periodically */ __u32 mmp_seq; /* Sequence no. updated periodically */

View File

@ -26,7 +26,7 @@
* crammed into the end of the block without having to rebalance the tree. * crammed into the end of the block without having to rebalance the tree.
*/ */
struct ext3_extent_tail { struct ext3_extent_tail {
__u32 et_checksum; /* crc32c(uuid+inum+extent_block) */ __le32 et_checksum; /* crc32c(uuid+inum+extent_block) */
}; };
/* /*
@ -34,10 +34,10 @@ struct ext3_extent_tail {
* it's used at the bottom of the tree * it's used at the bottom of the tree
*/ */
struct ext3_extent { struct ext3_extent {
__u32 ee_block; /* first logical block extent covers */ __le32 ee_block; /* first logical block extent covers */
__u16 ee_len; /* number of blocks covered by extent */ __le16 ee_len; /* number of blocks covered by extent */
__u16 ee_start_hi; /* high 16 bits of physical block */ __le16 ee_start_hi; /* high 16 bits of physical block */
__u32 ee_start; /* low 32 bigs of physical block */ __le32 ee_start; /* low 32 bigs of physical block */
}; };
/* /*
@ -45,22 +45,22 @@ struct ext3_extent {
* it's used at all the levels, but the bottom * it's used at all the levels, but the bottom
*/ */
struct ext3_extent_idx { struct ext3_extent_idx {
__u32 ei_block; /* index covers logical blocks from 'block' */ __le32 ei_block; /* index covers logical blocks from 'block' */
__u32 ei_leaf; /* pointer to the physical block of the next * __le32 ei_leaf; /* pointer to the physical block of the next *
* level. leaf or next index could bet here */ * level. leaf or next index could bet here */
__u16 ei_leaf_hi; /* high 16 bits of physical block */ __le16 ei_leaf_hi; /* high 16 bits of physical block */
__u16 ei_unused; __le16 ei_unused;
}; };
/* /*
* each block (leaves and indexes), even inode-stored has header * each block (leaves and indexes), even inode-stored has header
*/ */
struct ext3_extent_header { struct ext3_extent_header {
__u16 eh_magic; /* probably will support different formats */ __le16 eh_magic; /* probably will support different formats */
__u16 eh_entries; /* number of valid entries */ __le16 eh_entries; /* number of valid entries */
__u16 eh_max; /* capacity of store in entries */ __le16 eh_max; /* capacity of store in entries */
__u16 eh_depth; /* has tree real underlaying blocks? */ __le16 eh_depth; /* has tree real underlaying blocks? */
__u32 eh_generation; /* generation of the tree */ __le32 eh_generation; /* generation of the tree */
}; };
#define EXT3_EXT_MAGIC 0xf30a #define EXT3_EXT_MAGIC 0xf30a

View File

@ -170,7 +170,7 @@ typedef struct journal_block_tag_s
/* Tail of descriptor block, for checksumming */ /* Tail of descriptor block, for checksumming */
struct journal_block_tail { struct journal_block_tail {
__u32 t_checksum; __be32 t_checksum;
}; };
/* /*
@ -185,7 +185,7 @@ typedef struct journal_revoke_header_s
/* Tail of revoke block, for checksumming */ /* Tail of revoke block, for checksumming */
struct journal_revoke_tail { struct journal_revoke_tail {
__u32 r_checksum; __be32 r_checksum;
}; };
/* Definitions for the journal tag flags word: */ /* Definitions for the journal tag flags word: */

View File

@ -30,8 +30,8 @@ static const char * const basenames[] = {
/* Header in all newer quotafiles */ /* Header in all newer quotafiles */
struct disk_dqheader { struct disk_dqheader {
__u32 dqh_magic; __le32 dqh_magic;
__u32 dqh_version; __le32 dqh_version;
} __attribute__ ((packed)); } __attribute__ ((packed));
/** /**

View File

@ -20,13 +20,13 @@ typedef __u32 qid_t; /* Type in which we store ids in memory */
* so there will be space for exactly 21 quota-entries in a block * so there will be space for exactly 21 quota-entries in a block
*/ */
struct qt_disk_dqdbheader { struct qt_disk_dqdbheader {
__u32 dqdh_next_free; /* Number of next block with free __le32 dqdh_next_free; /* Number of next block with free
* entry */ * entry */
__u32 dqdh_prev_free; /* Number of previous block with free __le32 dqdh_prev_free; /* Number of previous block with free
* entry */ * entry */
__u16 dqdh_entries; /* Number of valid entries in block */ __le16 dqdh_entries; /* Number of valid entries in block */
__u16 dqdh_pad1; __le16 dqdh_pad1;
__u32 dqdh_pad2; __le32 dqdh_pad2;
} __attribute__ ((packed)); } __attribute__ ((packed));
struct dquot; struct dquot;

View File

@ -16,8 +16,8 @@
#define V2_VERSION 1 #define V2_VERSION 1
struct v2_disk_dqheader { struct v2_disk_dqheader {
__u32 dqh_magic; /* Magic number identifying file */ __le32 dqh_magic; /* Magic number identifying file */
__u32 dqh_version; /* File version */ __le32 dqh_version; /* File version */
} __attribute__ ((packed)); } __attribute__ ((packed));
/* Flags for version specific files */ /* Flags for version specific files */
@ -25,30 +25,30 @@ struct v2_disk_dqheader {
/* Header with type and version specific information */ /* Header with type and version specific information */
struct v2_disk_dqinfo { struct v2_disk_dqinfo {
__u32 dqi_bgrace; /* Time before block soft limit becomes __le32 dqi_bgrace; /* Time before block soft limit becomes
* hard limit */ * hard limit */
__u32 dqi_igrace; /* Time before inode soft limit becomes __le32 dqi_igrace; /* Time before inode soft limit becomes
* hard limit */ * hard limit */
__u32 dqi_flags; /* Flags for quotafile (DQF_*) */ __le32 dqi_flags; /* Flags for quotafile (DQF_*) */
__u32 dqi_blocks; /* Number of blocks in file */ __le32 dqi_blocks; /* Number of blocks in file */
__u32 dqi_free_blk; /* Number of first free block in the list */ __le32 dqi_free_blk; /* Number of first free block in the list */
__u32 dqi_free_entry; /* Number of block with at least one __le32 dqi_free_entry; /* Number of block with at least one
* free entry */ * free entry */
} __attribute__ ((packed)); } __attribute__ ((packed));
struct v2r1_disk_dqblk { struct v2r1_disk_dqblk {
__u32 dqb_id; /* id this quota applies to */ __le32 dqb_id; /* id this quota applies to */
__u32 dqb_pad; __le32 dqb_pad;
__u64 dqb_ihardlimit; /* absolute limit on allocated inodes */ __le64 dqb_ihardlimit; /* absolute limit on allocated inodes */
__u64 dqb_isoftlimit; /* preferred inode limit */ __le64 dqb_isoftlimit; /* preferred inode limit */
__u64 dqb_curinodes; /* current # allocated inodes */ __le64 dqb_curinodes; /* current # allocated inodes */
__u64 dqb_bhardlimit; /* absolute limit on disk space __le64 dqb_bhardlimit; /* absolute limit on disk space
* (in QUOTABLOCK_SIZE) */ * (in QUOTABLOCK_SIZE) */
__u64 dqb_bsoftlimit; /* preferred limit on disk space __le64 dqb_bsoftlimit; /* preferred limit on disk space
* (in QUOTABLOCK_SIZE) */ * (in QUOTABLOCK_SIZE) */
__u64 dqb_curspace; /* current space occupied (in bytes) */ __le64 dqb_curspace; /* current space occupied (in bytes) */
__u64 dqb_btime; /* time limit for excessive disk use */ __le64 dqb_btime; /* time limit for excessive disk use */
__u64 dqb_itime; /* time limit for excessive inode use */ __le64 dqb_itime; /* time limit for excessive inode use */
} __attribute__ ((packed)); } __attribute__ ((packed));
#endif #endif