Commit 5c520b7f authored by Alexander Viro's avatar Alexander Viro Committed by Linus Torvalds

[PATCH] ext3 endianness annotations and bugfixes

	* missing le32_to_cpu() in a bunch of printks
	* on big-endian boxen ext3_error() failed to set EXT3_ERROR_FS in
->s_state (cpu_to_le32() instead of cpu_to_le16())
Signed-off-by: default avatarAl Viro <viro@parcelfarce.linux.org.uk>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 31cb962e
...@@ -10,18 +10,18 @@ ...@@ -10,18 +10,18 @@
#define EXT3_ACL_MAX_ENTRIES 32 #define EXT3_ACL_MAX_ENTRIES 32
typedef struct { typedef struct {
__u16 e_tag; __le16 e_tag;
__u16 e_perm; __le16 e_perm;
__u32 e_id; __le32 e_id;
} ext3_acl_entry; } ext3_acl_entry;
typedef struct { typedef struct {
__u16 e_tag; __le16 e_tag;
__u16 e_perm; __le16 e_perm;
} ext3_acl_entry_short; } ext3_acl_entry_short;
typedef struct { typedef struct {
__u32 a_version; __le32 a_version;
} ext3_acl_header; } ext3_acl_header;
static inline size_t ext3_acl_size(int count) static inline size_t ext3_acl_size(int count)
......
...@@ -91,8 +91,8 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group) ...@@ -91,8 +91,8 @@ read_block_bitmap(struct super_block *sb, unsigned int block_group)
if (!bh) if (!bh)
ext3_error (sb, "read_block_bitmap", ext3_error (sb, "read_block_bitmap",
"Cannot read block bitmap - " "Cannot read block bitmap - "
"block_group = %d, block_bitmap = %lu", "block_group = %d, block_bitmap = %u",
block_group, (unsigned long) desc->bg_block_bitmap); block_group, le32_to_cpu(desc->bg_block_bitmap));
error_out: error_out:
return bh; return bh;
} }
......
...@@ -64,8 +64,8 @@ read_inode_bitmap(struct super_block * sb, unsigned long block_group) ...@@ -64,8 +64,8 @@ read_inode_bitmap(struct super_block * sb, unsigned long block_group)
if (!bh) if (!bh)
ext3_error(sb, "read_inode_bitmap", ext3_error(sb, "read_inode_bitmap",
"Cannot read inode bitmap - " "Cannot read inode bitmap - "
"block_group = %lu, inode_bitmap = %lu", "block_group = %lu, inode_bitmap = %u",
block_group, (unsigned long) desc->bg_inode_bitmap); block_group, le32_to_cpu(desc->bg_inode_bitmap));
error_out: error_out:
return bh; return bh;
} }
......
...@@ -305,12 +305,12 @@ static int ext3_alloc_block (handle_t *handle, ...@@ -305,12 +305,12 @@ static int ext3_alloc_block (handle_t *handle,
typedef struct { typedef struct {
u32 *p; __le32 *p;
u32 key; __le32 key;
struct buffer_head *bh; struct buffer_head *bh;
} Indirect; } Indirect;
static inline void add_chain(Indirect *p, struct buffer_head *bh, u32 *v) static inline void add_chain(Indirect *p, struct buffer_head *bh, __le32 *v)
{ {
p->key = *(p->p = v); p->key = *(p->p = v);
p->bh = bh; p->bh = bh;
...@@ -441,7 +441,7 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets, ...@@ -441,7 +441,7 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets,
/* Reader: pointers */ /* Reader: pointers */
if (!verify_chain(chain, p)) if (!verify_chain(chain, p))
goto changed; goto changed;
add_chain(++p, bh, (u32*)bh->b_data + *++offsets); add_chain(++p, bh, (__le32*)bh->b_data + *++offsets);
/* Reader: end */ /* Reader: end */
if (!p->key) if (!p->key)
goto no_block; goto no_block;
...@@ -482,8 +482,8 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets, ...@@ -482,8 +482,8 @@ static Indirect *ext3_get_branch(struct inode *inode, int depth, int *offsets,
static unsigned long ext3_find_near(struct inode *inode, Indirect *ind) static unsigned long ext3_find_near(struct inode *inode, Indirect *ind)
{ {
struct ext3_inode_info *ei = EXT3_I(inode); struct ext3_inode_info *ei = EXT3_I(inode);
u32 *start = ind->bh ? (u32*) ind->bh->b_data : ei->i_data; __le32 *start = ind->bh ? (__le32*) ind->bh->b_data : ei->i_data;
u32 *p; __le32 *p;
unsigned long bg_start; unsigned long bg_start;
unsigned long colour; unsigned long colour;
...@@ -611,7 +611,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode, ...@@ -611,7 +611,7 @@ static int ext3_alloc_branch(handle_t *handle, struct inode *inode,
} }
memset(bh->b_data, 0, blocksize); memset(bh->b_data, 0, blocksize);
branch[n].p = (u32*) bh->b_data + offsets[n]; branch[n].p = (__le32*) bh->b_data + offsets[n];
*branch[n].p = branch[n].key; *branch[n].p = branch[n].key;
BUFFER_TRACE(bh, "marking uptodate"); BUFFER_TRACE(bh, "marking uptodate");
set_buffer_uptodate(bh); set_buffer_uptodate(bh);
...@@ -1767,7 +1767,7 @@ static int ext3_block_truncate_page(handle_t *handle, struct page *page, ...@@ -1767,7 +1767,7 @@ static int ext3_block_truncate_page(handle_t *handle, struct page *page,
* or memcmp with zero_page, whatever is better for particular architecture. * or memcmp with zero_page, whatever is better for particular architecture.
* Linus? * Linus?
*/ */
static inline int all_zeroes(u32 *p, u32 *q) static inline int all_zeroes(__le32 *p, __le32 *q)
{ {
while (p < q) while (p < q)
if (*p++) if (*p++)
...@@ -1814,7 +1814,7 @@ static Indirect *ext3_find_shared(struct inode *inode, ...@@ -1814,7 +1814,7 @@ static Indirect *ext3_find_shared(struct inode *inode,
int depth, int depth,
int offsets[4], int offsets[4],
Indirect chain[4], Indirect chain[4],
u32 *top) __le32 *top)
{ {
Indirect *partial, *p; Indirect *partial, *p;
int k, err; int k, err;
...@@ -1834,7 +1834,7 @@ static Indirect *ext3_find_shared(struct inode *inode, ...@@ -1834,7 +1834,7 @@ static Indirect *ext3_find_shared(struct inode *inode,
if (!partial->key && *partial->p) if (!partial->key && *partial->p)
/* Writer: end */ /* Writer: end */
goto no_top; goto no_top;
for (p=partial; p>chain && all_zeroes((u32*)p->bh->b_data,p->p); p--) for (p=partial; p>chain && all_zeroes((__le32*)p->bh->b_data,p->p); p--)
; ;
/* /*
* OK, we've found the last block that must survive. The rest of our * OK, we've found the last block that must survive. The rest of our
...@@ -1873,9 +1873,9 @@ static Indirect *ext3_find_shared(struct inode *inode, ...@@ -1873,9 +1873,9 @@ static Indirect *ext3_find_shared(struct inode *inode,
static void static void
ext3_clear_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh, ext3_clear_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh,
unsigned long block_to_free, unsigned long count, unsigned long block_to_free, unsigned long count,
u32 *first, u32 *last) __le32 *first, __le32 *last)
{ {
u32 *p; __le32 *p;
if (try_to_extend_transaction(handle, inode)) { if (try_to_extend_transaction(handle, inode)) {
if (bh) { if (bh) {
BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(bh, "call ext3_journal_dirty_metadata");
...@@ -1931,15 +1931,16 @@ ext3_clear_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh, ...@@ -1931,15 +1931,16 @@ ext3_clear_blocks(handle_t *handle, struct inode *inode, struct buffer_head *bh,
* block pointers. * block pointers.
*/ */
static void ext3_free_data(handle_t *handle, struct inode *inode, static void ext3_free_data(handle_t *handle, struct inode *inode,
struct buffer_head *this_bh, u32 *first, u32 *last) struct buffer_head *this_bh,
__le32 *first, __le32 *last)
{ {
unsigned long block_to_free = 0; /* Starting block # of a run */ unsigned long block_to_free = 0; /* Starting block # of a run */
unsigned long count = 0; /* Number of blocks in the run */ unsigned long count = 0; /* Number of blocks in the run */
u32 *block_to_free_p = NULL; /* Pointer into inode/ind __le32 *block_to_free_p = NULL; /* Pointer into inode/ind
corresponding to corresponding to
block_to_free */ block_to_free */
unsigned long nr; /* Current block # */ unsigned long nr; /* Current block # */
u32 *p; /* Pointer into inode/ind __le32 *p; /* Pointer into inode/ind
for current block */ for current block */
int err; int err;
...@@ -1998,10 +1999,10 @@ static void ext3_free_data(handle_t *handle, struct inode *inode, ...@@ -1998,10 +1999,10 @@ static void ext3_free_data(handle_t *handle, struct inode *inode,
*/ */
static void ext3_free_branches(handle_t *handle, struct inode *inode, static void ext3_free_branches(handle_t *handle, struct inode *inode,
struct buffer_head *parent_bh, struct buffer_head *parent_bh,
u32 *first, u32 *last, int depth) __le32 *first, __le32 *last, int depth)
{ {
unsigned long nr; unsigned long nr;
u32 *p; __le32 *p;
if (is_handle_aborted(handle)) if (is_handle_aborted(handle))
return; return;
...@@ -2031,8 +2032,9 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode, ...@@ -2031,8 +2032,9 @@ static void ext3_free_branches(handle_t *handle, struct inode *inode,
/* This zaps the entire block. Bottom up. */ /* This zaps the entire block. Bottom up. */
BUFFER_TRACE(bh, "free child branches"); BUFFER_TRACE(bh, "free child branches");
ext3_free_branches(handle, inode, bh, (u32*)bh->b_data, ext3_free_branches(handle, inode, bh,
(u32*)bh->b_data + addr_per_block, (__le32*)bh->b_data,
(__le32*)bh->b_data + addr_per_block,
depth); depth);
/* /*
...@@ -2137,13 +2139,13 @@ void ext3_truncate(struct inode * inode) ...@@ -2137,13 +2139,13 @@ void ext3_truncate(struct inode * inode)
{ {
handle_t *handle; handle_t *handle;
struct ext3_inode_info *ei = EXT3_I(inode); struct ext3_inode_info *ei = EXT3_I(inode);
u32 *i_data = ei->i_data; __le32 *i_data = ei->i_data;
int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb); int addr_per_block = EXT3_ADDR_PER_BLOCK(inode->i_sb);
struct address_space *mapping = inode->i_mapping; struct address_space *mapping = inode->i_mapping;
int offsets[4]; int offsets[4];
Indirect chain[4]; Indirect chain[4];
Indirect *partial; Indirect *partial;
int nr = 0; __le32 nr = 0;
int n; int n;
long last_block; long last_block;
unsigned blocksize = inode->i_sb->s_blocksize; unsigned blocksize = inode->i_sb->s_blocksize;
...@@ -2250,7 +2252,7 @@ void ext3_truncate(struct inode * inode) ...@@ -2250,7 +2252,7 @@ void ext3_truncate(struct inode * inode)
/* Clear the ends of indirect blocks on the shared branch */ /* Clear the ends of indirect blocks on the shared branch */
while (partial > chain) { while (partial > chain) {
ext3_free_branches(handle, inode, partial->bh, partial->p + 1, ext3_free_branches(handle, inode, partial->bh, partial->p + 1,
(u32*)partial->bh->b_data + addr_per_block, (__le32*)partial->bh->b_data+addr_per_block,
(chain+n-1) - partial); (chain+n-1) - partial);
BUFFER_TRACE(partial->bh, "call brelse"); BUFFER_TRACE(partial->bh, "call brelse");
brelse (partial->bh); brelse (partial->bh);
......
...@@ -71,9 +71,6 @@ static struct buffer_head *ext3_append(handle_t *handle, ...@@ -71,9 +71,6 @@ static struct buffer_head *ext3_append(handle_t *handle,
#define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0) #define swap(x, y) do { typeof(x) z = x; x = y; y = z; } while (0)
#endif #endif
typedef struct { u32 v; } le_u32;
typedef struct { u16 v; } le_u16;
#ifdef DX_DEBUG #ifdef DX_DEBUG
#define dxtrace(command) command #define dxtrace(command) command
#else #else
...@@ -82,22 +79,22 @@ typedef struct { u16 v; } le_u16; ...@@ -82,22 +79,22 @@ typedef struct { u16 v; } le_u16;
struct fake_dirent struct fake_dirent
{ {
/*le*/u32 inode; __le32 inode;
/*le*/u16 rec_len; __le16 rec_len;
u8 name_len; u8 name_len;
u8 file_type; u8 file_type;
}; };
struct dx_countlimit struct dx_countlimit
{ {
le_u16 limit; __le16 limit;
le_u16 count; __le16 count;
}; };
struct dx_entry struct dx_entry
{ {
le_u32 hash; __le32 hash;
le_u32 block; __le32 block;
}; };
/* /*
...@@ -114,7 +111,7 @@ struct dx_root ...@@ -114,7 +111,7 @@ struct dx_root
char dotdot_name[4]; char dotdot_name[4];
struct dx_root_info struct dx_root_info
{ {
le_u32 reserved_zero; __le32 reserved_zero;
u8 hash_version; u8 hash_version;
u8 info_length; /* 8 */ u8 info_length; /* 8 */
u8 indirect_levels; u8 indirect_levels;
...@@ -184,42 +181,42 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry, ...@@ -184,42 +181,42 @@ static int ext3_dx_add_entry(handle_t *handle, struct dentry *dentry,
static inline unsigned dx_get_block (struct dx_entry *entry) static inline unsigned dx_get_block (struct dx_entry *entry)
{ {
return le32_to_cpu(entry->block.v) & 0x00ffffff; return le32_to_cpu(entry->block) & 0x00ffffff;
} }
static inline void dx_set_block (struct dx_entry *entry, unsigned value) static inline void dx_set_block (struct dx_entry *entry, unsigned value)
{ {
entry->block.v = cpu_to_le32(value); entry->block = cpu_to_le32(value);
} }
static inline unsigned dx_get_hash (struct dx_entry *entry) static inline unsigned dx_get_hash (struct dx_entry *entry)
{ {
return le32_to_cpu(entry->hash.v); return le32_to_cpu(entry->hash);
} }
static inline void dx_set_hash (struct dx_entry *entry, unsigned value) static inline void dx_set_hash (struct dx_entry *entry, unsigned value)
{ {
entry->hash.v = cpu_to_le32(value); entry->hash = cpu_to_le32(value);
} }
static inline unsigned dx_get_count (struct dx_entry *entries) static inline unsigned dx_get_count (struct dx_entry *entries)
{ {
return le16_to_cpu(((struct dx_countlimit *) entries)->count.v); return le16_to_cpu(((struct dx_countlimit *) entries)->count);
} }
static inline unsigned dx_get_limit (struct dx_entry *entries) static inline unsigned dx_get_limit (struct dx_entry *entries)
{ {
return le16_to_cpu(((struct dx_countlimit *) entries)->limit.v); return le16_to_cpu(((struct dx_countlimit *) entries)->limit);
} }
static inline void dx_set_count (struct dx_entry *entries, unsigned value) static inline void dx_set_count (struct dx_entry *entries, unsigned value)
{ {
((struct dx_countlimit *) entries)->count.v = cpu_to_le16(value); ((struct dx_countlimit *) entries)->count = cpu_to_le16(value);
} }
static inline void dx_set_limit (struct dx_entry *entries, unsigned value) static inline void dx_set_limit (struct dx_entry *entries, unsigned value)
{ {
((struct dx_countlimit *) entries)->limit.v = cpu_to_le16(value); ((struct dx_countlimit *) entries)->limit = cpu_to_le16(value);
} }
static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize) static inline unsigned dx_root_limit (struct inode *dir, unsigned infosize)
...@@ -2258,7 +2255,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, ...@@ -2258,7 +2255,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
} else { } else {
BUFFER_TRACE(new_bh, "get write access"); BUFFER_TRACE(new_bh, "get write access");
ext3_journal_get_write_access(handle, new_bh); ext3_journal_get_write_access(handle, new_bh);
new_de->inode = le32_to_cpu(old_inode->i_ino); new_de->inode = cpu_to_le32(old_inode->i_ino);
if (EXT3_HAS_INCOMPAT_FEATURE(new_dir->i_sb, if (EXT3_HAS_INCOMPAT_FEATURE(new_dir->i_sb,
EXT3_FEATURE_INCOMPAT_FILETYPE)) EXT3_FEATURE_INCOMPAT_FILETYPE))
new_de->file_type = old_de->file_type; new_de->file_type = old_de->file_type;
...@@ -2313,7 +2310,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry, ...@@ -2313,7 +2310,7 @@ static int ext3_rename (struct inode * old_dir, struct dentry *old_dentry,
if (dir_bh) { if (dir_bh) {
BUFFER_TRACE(dir_bh, "get_write_access"); BUFFER_TRACE(dir_bh, "get_write_access");
ext3_journal_get_write_access(handle, dir_bh); ext3_journal_get_write_access(handle, dir_bh);
PARENT_INO(dir_bh->b_data) = le32_to_cpu(new_dir->i_ino); PARENT_INO(dir_bh->b_data) = cpu_to_le32(new_dir->i_ino);
BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata"); BUFFER_TRACE(dir_bh, "call ext3_journal_dirty_metadata");
ext3_journal_dirty_metadata(handle, dir_bh); ext3_journal_dirty_metadata(handle, dir_bh);
old_dir->i_nlink--; old_dir->i_nlink--;
......
...@@ -138,7 +138,7 @@ static void ext3_handle_error(struct super_block *sb) ...@@ -138,7 +138,7 @@ static void ext3_handle_error(struct super_block *sb)
struct ext3_super_block *es = EXT3_SB(sb)->s_es; struct ext3_super_block *es = EXT3_SB(sb)->s_es;
EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS; EXT3_SB(sb)->s_mount_state |= EXT3_ERROR_FS;
es->s_state |= cpu_to_le32(EXT3_ERROR_FS); es->s_state |= cpu_to_le16(EXT3_ERROR_FS);
if (sb->s_flags & MS_RDONLY) if (sb->s_flags & MS_RDONLY)
return; return;
...@@ -377,7 +377,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi) ...@@ -377,7 +377,7 @@ static void dump_orphan_list(struct super_block *sb, struct ext3_sb_info *sbi)
"inode %s:%ld at %p: mode %o, nlink %d, next %d\n", "inode %s:%ld at %p: mode %o, nlink %d, next %d\n",
inode->i_sb->s_id, inode->i_ino, inode, inode->i_sb->s_id, inode->i_ino, inode,
inode->i_mode, inode->i_nlink, inode->i_mode, inode->i_nlink,
le32_to_cpu(NEXT_ORPHAN(inode))); NEXT_ORPHAN(inode));
} }
} }
...@@ -391,7 +391,7 @@ void ext3_put_super (struct super_block * sb) ...@@ -391,7 +391,7 @@ void ext3_put_super (struct super_block * sb)
journal_destroy(sbi->s_journal); journal_destroy(sbi->s_journal);
if (!(sb->s_flags & MS_RDONLY)) { if (!(sb->s_flags & MS_RDONLY)) {
EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER); EXT3_CLEAR_INCOMPAT_FEATURE(sb, EXT3_FEATURE_INCOMPAT_RECOVER);
es->s_state = le16_to_cpu(sbi->s_mount_state); es->s_state = cpu_to_le16(sbi->s_mount_state);
BUFFER_TRACE(sbi->s_sbh, "marking dirty"); BUFFER_TRACE(sbi->s_sbh, "marking dirty");
mark_buffer_dirty(sbi->s_sbh); mark_buffer_dirty(sbi->s_sbh);
ext3_commit_super(sb, es, 1); ext3_commit_super(sb, es, 1);
...@@ -964,8 +964,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es, ...@@ -964,8 +964,7 @@ static int ext3_setup_super(struct super_block *sb, struct ext3_super_block *es,
es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3_VALID_FS); es->s_state = cpu_to_le16(le16_to_cpu(es->s_state) & ~EXT3_VALID_FS);
#endif #endif
if (!(__s16) le16_to_cpu(es->s_max_mnt_count)) if (!(__s16) le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = es->s_max_mnt_count = cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
(__s16) cpu_to_le16(EXT3_DFL_MAX_MNT_COUNT);
es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1); es->s_mnt_count=cpu_to_le16(le16_to_cpu(es->s_mnt_count) + 1);
es->s_mtime = cpu_to_le32(get_seconds()); es->s_mtime = cpu_to_le32(get_seconds());
ext3_update_dynamic_rev(sb); ext3_update_dynamic_rev(sb);
...@@ -1221,6 +1220,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1221,6 +1220,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
int db_count; int db_count;
int i; int i;
int needs_recovery; int needs_recovery;
__le32 features;
sbi = kmalloc(sizeof(*sbi), GFP_KERNEL); sbi = kmalloc(sizeof(*sbi), GFP_KERNEL);
if (!sbi) if (!sbi)
...@@ -1313,17 +1313,18 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1313,17 +1313,18 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
* previously didn't change the revision level when setting the flags, * previously didn't change the revision level when setting the flags,
* so there is a chance incompat flags are set on a rev 0 filesystem. * so there is a chance incompat flags are set on a rev 0 filesystem.
*/ */
if ((i = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP))) { features = EXT3_HAS_INCOMPAT_FEATURE(sb, ~EXT3_FEATURE_INCOMPAT_SUPP);
if (features) {
printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of " printk(KERN_ERR "EXT3-fs: %s: couldn't mount because of "
"unsupported optional features (%x).\n", "unsupported optional features (%x).\n",
sb->s_id, i); sb->s_id, le32_to_cpu(features));
goto failed_mount; goto failed_mount;
} }
if (!(sb->s_flags & MS_RDONLY) && features = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP);
(i = EXT3_HAS_RO_COMPAT_FEATURE(sb, ~EXT3_FEATURE_RO_COMPAT_SUPP))){ if (!(sb->s_flags & MS_RDONLY) && features) {
printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of " printk(KERN_ERR "EXT3-fs: %s: couldn't mount RDWR because of "
"unsupported optional features (%x).\n", "unsupported optional features (%x).\n",
sb->s_id, i); sb->s_id, le32_to_cpu(features));
goto failed_mount; goto failed_mount;
} }
blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size); blocksize = BLOCK_SIZE << le32_to_cpu(es->s_log_block_size);
...@@ -1360,7 +1361,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent) ...@@ -1360,7 +1361,7 @@ static int ext3_fill_super (struct super_block *sb, void *data, int silent)
} }
es = (struct ext3_super_block *)(((char *)bh->b_data) + offset); es = (struct ext3_super_block *)(((char *)bh->b_data) + offset);
sbi->s_es = es; sbi->s_es = es;
if (es->s_magic != le16_to_cpu(EXT3_SUPER_MAGIC)) { if (es->s_magic != cpu_to_le16(EXT3_SUPER_MAGIC)) {
printk (KERN_ERR printk (KERN_ERR
"EXT3-fs: Magic mismatch, very weird !\n"); "EXT3-fs: Magic mismatch, very weird !\n");
goto failed_mount; goto failed_mount;
...@@ -1737,10 +1738,10 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb, ...@@ -1737,10 +1738,10 @@ static journal_t *ext3_get_dev_journal(struct super_block *sb,
printk(KERN_ERR "EXT3-fs: I/O error on journal device\n"); printk(KERN_ERR "EXT3-fs: I/O error on journal device\n");
goto out_journal; goto out_journal;
} }
if (ntohl(journal->j_superblock->s_nr_users) != 1) { if (be32_to_cpu(journal->j_superblock->s_nr_users) != 1) {
printk(KERN_ERR "EXT3-fs: External journal has more than one " printk(KERN_ERR "EXT3-fs: External journal has more than one "
"user (unsupported) - %d\n", "user (unsupported) - %d\n",
ntohl(journal->j_superblock->s_nr_users)); be32_to_cpu(journal->j_superblock->s_nr_users));
goto out_journal; goto out_journal;
} }
EXT3_SB(sb)->journal_bdev = bdev; EXT3_SB(sb)->journal_bdev = bdev;
...@@ -2065,13 +2066,13 @@ int ext3_remount (struct super_block * sb, int * flags, char * data) ...@@ -2065,13 +2066,13 @@ int ext3_remount (struct super_block * sb, int * flags, char * data)
ext3_mark_recovery_complete(sb, es); ext3_mark_recovery_complete(sb, es);
} else { } else {
int ret; __le32 ret;
if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb, if ((ret = EXT3_HAS_RO_COMPAT_FEATURE(sb,
~EXT3_FEATURE_RO_COMPAT_SUPP))) { ~EXT3_FEATURE_RO_COMPAT_SUPP))) {
printk(KERN_WARNING "EXT3-fs: %s: couldn't " printk(KERN_WARNING "EXT3-fs: %s: couldn't "
"remount RDWR because of unsupported " "remount RDWR because of unsupported "
"optional features (%x).\n", "optional features (%x).\n",
sb->s_id, ret); sb->s_id, le32_to_cpu(ret));
return -EROFS; return -EROFS;
} }
/* /*
......
...@@ -1130,7 +1130,7 @@ static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header, ...@@ -1130,7 +1130,7 @@ static inline void ext3_xattr_hash_entry(struct ext3_xattr_header *header,
} }
if (entry->e_value_block == 0 && entry->e_value_size != 0) { if (entry->e_value_block == 0 && entry->e_value_size != 0) {
__u32 *value = (__u32 *)((char *)header + __le32 *value = (__le32 *)((char *)header +
le16_to_cpu(entry->e_value_offs)); le16_to_cpu(entry->e_value_offs));
for (n = (le32_to_cpu(entry->e_value_size) + for (n = (le32_to_cpu(entry->e_value_size) +
EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) { EXT3_XATTR_ROUND) >> EXT3_XATTR_PAD_BITS; n; n--) {
......
...@@ -25,20 +25,20 @@ ...@@ -25,20 +25,20 @@
#define EXT3_XATTR_INDEX_SECURITY 6 #define EXT3_XATTR_INDEX_SECURITY 6
struct ext3_xattr_header { struct ext3_xattr_header {
__u32 h_magic; /* magic number for identification */ __le32 h_magic; /* magic number for identification */
__u32 h_refcount; /* reference count */ __le32 h_refcount; /* reference count */
__u32 h_blocks; /* number of disk blocks used */ __le32 h_blocks; /* number of disk blocks used */
__u32 h_hash; /* hash value of all attributes */ __le32 h_hash; /* hash value of all attributes */
__u32 h_reserved[4]; /* zero right now */ __u32 h_reserved[4]; /* zero right now */
}; };
struct ext3_xattr_entry { struct ext3_xattr_entry {
__u8 e_name_len; /* length of name */ __u8 e_name_len; /* length of name */
__u8 e_name_index; /* attribute name index */ __u8 e_name_index; /* attribute name index */
__u16 e_value_offs; /* offset in disk block of value */ __le16 e_value_offs; /* offset in disk block of value */
__u32 e_value_block; /* disk block attribute is stored on (n/i) */ __le32 e_value_block; /* disk block attribute is stored on (n/i) */
__u32 e_value_size; /* size of attribute value */ __le32 e_value_size; /* size of attribute value */
__u32 e_hash; /* hash value of name and value */ __le32 e_hash; /* hash value of name and value */
char e_name[0]; /* attribute name */ char e_name[0]; /* attribute name */
}; };
......
...@@ -129,14 +129,14 @@ struct statfs; ...@@ -129,14 +129,14 @@ struct statfs;
*/ */
struct ext3_group_desc struct ext3_group_desc
{ {
__u32 bg_block_bitmap; /* Blocks bitmap block */ __le32 bg_block_bitmap; /* Blocks bitmap block */
__u32 bg_inode_bitmap; /* Inodes bitmap block */ __le32 bg_inode_bitmap; /* Inodes bitmap block */
__u32 bg_inode_table; /* Inodes table block */ __le32 bg_inode_table; /* Inodes table block */
__u16 bg_free_blocks_count; /* Free blocks count */ __le16 bg_free_blocks_count; /* Free blocks count */
__u16 bg_free_inodes_count; /* Free inodes count */ __le16 bg_free_inodes_count; /* Free inodes count */
__u16 bg_used_dirs_count; /* Directories count */ __le16 bg_used_dirs_count; /* Directories count */
__u16 bg_pad; __u16 bg_pad;
__u32 bg_reserved[3]; __le32 bg_reserved[3];
}; };
/* /*
...@@ -213,17 +213,17 @@ struct ext3_group_desc ...@@ -213,17 +213,17 @@ struct ext3_group_desc
* Structure of an inode on the disk * Structure of an inode on the disk
*/ */
struct ext3_inode { struct ext3_inode {
__u16 i_mode; /* File mode */ __le16 i_mode; /* File mode */
__u16 i_uid; /* Low 16 bits of Owner Uid */ __le16 i_uid; /* Low 16 bits of Owner Uid */
__u32 i_size; /* Size in bytes */ __le32 i_size; /* Size in bytes */
__u32 i_atime; /* Access time */ __le32 i_atime; /* Access time */
__u32 i_ctime; /* Creation time */ __le32 i_ctime; /* Creation time */
__u32 i_mtime; /* Modification time */ __le32 i_mtime; /* Modification time */
__u32 i_dtime; /* Deletion Time */ __le32 i_dtime; /* Deletion Time */
__u16 i_gid; /* Low 16 bits of Group Id */ __le16 i_gid; /* Low 16 bits of Group Id */
__u16 i_links_count; /* Links count */ __le16 i_links_count; /* Links count */
__u32 i_blocks; /* Blocks count */ __le32 i_blocks; /* Blocks count */
__u32 i_flags; /* File flags */ __le32 i_flags; /* File flags */
union { union {
struct { struct {
__u32 l_i_reserved1; __u32 l_i_reserved1;
...@@ -235,18 +235,18 @@ struct ext3_inode { ...@@ -235,18 +235,18 @@ struct ext3_inode {
__u32 m_i_reserved1; __u32 m_i_reserved1;
} masix1; } masix1;
} osd1; /* OS dependent 1 */ } osd1; /* OS dependent 1 */
__u32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */ __le32 i_block[EXT3_N_BLOCKS];/* Pointers to blocks */
__u32 i_generation; /* File version (for NFS) */ __le32 i_generation; /* File version (for NFS) */
__u32 i_file_acl; /* File ACL */ __le32 i_file_acl; /* File ACL */
__u32 i_dir_acl; /* Directory ACL */ __le32 i_dir_acl; /* Directory ACL */
__u32 i_faddr; /* Fragment address */ __le32 i_faddr; /* Fragment address */
union { union {
struct { struct {
__u8 l_i_frag; /* Fragment number */ __u8 l_i_frag; /* Fragment number */
__u8 l_i_fsize; /* Fragment size */ __u8 l_i_fsize; /* Fragment size */
__u16 i_pad1; __u16 i_pad1;
__u16 l_i_uid_high; /* these 2 fields */ __le16 l_i_uid_high; /* these 2 fields */
__u16 l_i_gid_high; /* were reserved2[0] */ __le16 l_i_gid_high; /* were reserved2[0] */
__u32 l_i_reserved2; __u32 l_i_reserved2;
} linux2; } linux2;
struct { struct {
...@@ -364,31 +364,31 @@ struct ext3_inode { ...@@ -364,31 +364,31 @@ struct ext3_inode {
* Structure of the super block * Structure of the super block
*/ */
struct ext3_super_block { struct ext3_super_block {
/*00*/ __u32 s_inodes_count; /* Inodes count */ /*00*/ __le32 s_inodes_count; /* Inodes count */
__u32 s_blocks_count; /* Blocks count */ __le32 s_blocks_count; /* Blocks count */
__u32 s_r_blocks_count; /* Reserved blocks count */ __le32 s_r_blocks_count; /* Reserved blocks count */
__u32 s_free_blocks_count; /* Free blocks count */ __le32 s_free_blocks_count; /* Free blocks count */
/*10*/ __u32 s_free_inodes_count; /* Free inodes count */ /*10*/ __le32 s_free_inodes_count; /* Free inodes count */
__u32 s_first_data_block; /* First Data Block */ __le32 s_first_data_block; /* First Data Block */
__u32 s_log_block_size; /* Block size */ __le32 s_log_block_size; /* Block size */
__s32 s_log_frag_size; /* Fragment size */ __le32 s_log_frag_size; /* Fragment size */
/*20*/ __u32 s_blocks_per_group; /* # Blocks per group */ /*20*/ __le32 s_blocks_per_group; /* # Blocks per group */
__u32 s_frags_per_group; /* # Fragments per group */ __le32 s_frags_per_group; /* # Fragments per group */
__u32 s_inodes_per_group; /* # Inodes per group */ __le32 s_inodes_per_group; /* # Inodes per group */
__u32 s_mtime; /* Mount time */ __le32 s_mtime; /* Mount time */
/*30*/ __u32 s_wtime; /* Write time */ /*30*/ __le32 s_wtime; /* Write time */
__u16 s_mnt_count; /* Mount count */ __le16 s_mnt_count; /* Mount count */
__s16 s_max_mnt_count; /* Maximal mount count */ __le16 s_max_mnt_count; /* Maximal mount count */
__u16 s_magic; /* Magic signature */ __le16 s_magic; /* Magic signature */
__u16 s_state; /* File system state */ __le16 s_state; /* File system state */
__u16 s_errors; /* Behaviour when detecting errors */ __le16 s_errors; /* Behaviour when detecting errors */
__u16 s_minor_rev_level; /* minor revision level */ __le16 s_minor_rev_level; /* minor revision level */
/*40*/ __u32 s_lastcheck; /* time of last check */ /*40*/ __le32 s_lastcheck; /* time of last check */
__u32 s_checkinterval; /* max. time between checks */ __le32 s_checkinterval; /* max. time between checks */
__u32 s_creator_os; /* OS */ __le32 s_creator_os; /* OS */
__u32 s_rev_level; /* Revision level */ __le32 s_rev_level; /* Revision level */
/*50*/ __u16 s_def_resuid; /* Default uid for reserved blocks */ /*50*/ __le16 s_def_resuid; /* Default uid for reserved blocks */
__u16 s_def_resgid; /* Default gid for reserved blocks */ __le16 s_def_resgid; /* Default gid for reserved blocks */
/* /*
* These fields are for EXT3_DYNAMIC_REV superblocks only. * These fields are for EXT3_DYNAMIC_REV superblocks only.
* *
...@@ -402,16 +402,16 @@ struct ext3_super_block { ...@@ -402,16 +402,16 @@ struct ext3_super_block {
* feature set, it must abort and not try to meddle with * feature set, it must abort and not try to meddle with
* things it doesn't understand... * things it doesn't understand...
*/ */
__u32 s_first_ino; /* First non-reserved inode */ __le32 s_first_ino; /* First non-reserved inode */
__u16 s_inode_size; /* size of inode structure */ __le16 s_inode_size; /* size of inode structure */
__u16 s_block_group_nr; /* block group # of this superblock */ __le16 s_block_group_nr; /* block group # of this superblock */
__u32 s_feature_compat; /* compatible feature set */ __le32 s_feature_compat; /* compatible feature set */
/*60*/ __u32 s_feature_incompat; /* incompatible feature set */ /*60*/ __le32 s_feature_incompat; /* incompatible feature set */
__u32 s_feature_ro_compat; /* readonly-compatible feature set */ __le32 s_feature_ro_compat; /* readonly-compatible feature set */
/*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */ /*68*/ __u8 s_uuid[16]; /* 128-bit uuid for volume */
/*78*/ char s_volume_name[16]; /* volume name */ /*78*/ char s_volume_name[16]; /* volume name */
/*88*/ char s_last_mounted[64]; /* directory where last mounted */ /*88*/ char s_last_mounted[64]; /* directory where last mounted */
/*C8*/ __u32 s_algorithm_usage_bitmap; /* For compression */ /*C8*/ __le32 s_algorithm_usage_bitmap; /* For compression */
/* /*
* Performance hints. Directory preallocation should only * Performance hints. Directory preallocation should only
* happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on. * happen if the EXT3_FEATURE_COMPAT_DIR_PREALLOC flag is on.
...@@ -423,15 +423,15 @@ struct ext3_super_block { ...@@ -423,15 +423,15 @@ struct ext3_super_block {
* Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set. * Journaling support valid if EXT3_FEATURE_COMPAT_HAS_JOURNAL set.
*/ */
/*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */ /*D0*/ __u8 s_journal_uuid[16]; /* uuid of journal superblock */
/*E0*/ __u32 s_journal_inum; /* inode number of journal file */ /*E0*/ __le32 s_journal_inum; /* inode number of journal file */
__u32 s_journal_dev; /* device number of journal file */ __le32 s_journal_dev; /* device number of journal file */
__u32 s_last_orphan; /* start of list of inodes to delete */ __le32 s_last_orphan; /* start of list of inodes to delete */
__u32 s_hash_seed[4]; /* HTREE hash seed */ __le32 s_hash_seed[4]; /* HTREE hash seed */
__u8 s_def_hash_version; /* Default hash version to use */ __u8 s_def_hash_version; /* Default hash version to use */
__u8 s_reserved_char_pad; __u8 s_reserved_char_pad;
__u16 s_reserved_word_pad; __u16 s_reserved_word_pad;
__u32 s_default_mount_opts; __le32 s_default_mount_opts;
__u32 s_first_meta_bg; /* First metablock block group */ __le32 s_first_meta_bg; /* First metablock block group */
__u32 s_reserved[190]; /* Padding to the end of the block */ __u32 s_reserved[190]; /* Padding to the end of the block */
}; };
...@@ -546,9 +546,9 @@ static inline struct ext3_inode_info *EXT3_I(struct inode *inode) ...@@ -546,9 +546,9 @@ static inline struct ext3_inode_info *EXT3_I(struct inode *inode)
#define EXT3_NAME_LEN 255 #define EXT3_NAME_LEN 255
struct ext3_dir_entry { struct ext3_dir_entry {
__u32 inode; /* Inode number */ __le32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */ __le16 rec_len; /* Directory entry length */
__u16 name_len; /* Name length */ __le16 name_len; /* Name length */
char name[EXT3_NAME_LEN]; /* File name */ char name[EXT3_NAME_LEN]; /* File name */
}; };
...@@ -559,8 +559,8 @@ struct ext3_dir_entry { ...@@ -559,8 +559,8 @@ struct ext3_dir_entry {
* file_type field. * file_type field.
*/ */
struct ext3_dir_entry_2 { struct ext3_dir_entry_2 {
__u32 inode; /* Inode number */ __le32 inode; /* Inode number */
__u16 rec_len; /* Directory entry length */ __le16 rec_len; /* Directory entry length */
__u8 name_len; /* Name length */ __u8 name_len; /* Name length */
__u8 file_type; __u8 file_type;
char name[EXT3_NAME_LEN]; /* File name */ char name[EXT3_NAME_LEN]; /* File name */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
* second extended file system inode data in memory * second extended file system inode data in memory
*/ */
struct ext3_inode_info { struct ext3_inode_info {
__u32 i_data[15]; __le32 i_data[15]; /* unconverted */
__u32 i_flags; __u32 i_flags;
#ifdef EXT3_FRAGMENTS #ifdef EXT3_FRAGMENTS
__u32 i_faddr; __u32 i_faddr;
......
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