提交 58a9ecba 编写于 作者: M Michael Walle 提交者: Tom Rini

ext4: fix endianess problems in ext4 write support

All fields were accessed directly instead of using the proper byte swap
functions. Thus, ext4 write support was only usable on little-endian
architectures. Fix this.
Signed-off-by: NMichael Walle <michael@walle.cc>
上级 7f101be3
此差异已折叠。
......@@ -59,10 +59,10 @@ int ext4fs_iterate_dir(struct ext2fs_node *dir, char *name,
#if defined(CONFIG_EXT4_WRITE)
uint32_t ext4fs_div_roundup(uint32_t size, uint32_t n);
int ext4fs_checksum_update(unsigned int i);
uint16_t ext4fs_checksum_update(unsigned int i);
int ext4fs_get_parent_inode_num(const char *dirname, char *dname, int flags);
void ext4fs_update_parent_dentry(char *filename, int *p_ino, int file_type);
long int ext4fs_get_new_blk_no(void);
uint32_t ext4fs_get_new_blk_no(void);
int ext4fs_get_new_inode_no(void);
void ext4fs_reset_block_bmap(long int blockno, unsigned char *buffer,
int index);
......
......@@ -151,7 +151,7 @@ int ext4fs_log_gdt(char *gd_table)
* journal_buffer -- Buffer containing meta data
* blknr -- Block number on disk of the meta data buffer
*/
int ext4fs_log_journal(char *journal_buffer, long int blknr)
int ext4fs_log_journal(char *journal_buffer, uint32_t blknr)
{
struct ext_filesystem *fs = get_fs();
short i;
......@@ -183,7 +183,7 @@ int ext4fs_log_journal(char *journal_buffer, long int blknr)
* metadata_buffer -- Buffer containing meta data
* blknr -- Block number on disk of the meta data buffer
*/
int ext4fs_put_metadata(char *metadata_buffer, long int blknr)
int ext4fs_put_metadata(char *metadata_buffer, uint32_t blknr)
{
struct ext_filesystem *fs = get_fs();
if (!metadata_buffer) {
......@@ -215,7 +215,7 @@ void print_revoke_blks(char *revk_blk)
printf("total bytes %d\n", max);
while (offset < max) {
blocknr = be32_to_cpu(*((long int *)(revk_blk + offset)));
blocknr = be32_to_cpu(*((__be32 *)(revk_blk + offset)));
printf("revoke blknr is %ld\n", blocknr);
offset += 4;
}
......@@ -302,7 +302,7 @@ int check_blknr_for_revoke(long int blknr, int sequence_no)
max = be32_to_cpu(header->r_count);
while (offset < max) {
blocknr = be32_to_cpu(*((long int *)
blocknr = be32_to_cpu(*((__be32 *)
(revk_blk + offset)));
if (blocknr == blknr)
goto found;
......@@ -420,7 +420,7 @@ int ext4fs_check_journal_state(int recovery_flag)
temp_buff);
jsb = (struct journal_superblock_t *) temp_buff;
if (fs->sb->feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
if (le32_to_cpu(fs->sb->feature_incompat) & EXT3_FEATURE_INCOMPAT_RECOVER) {
if (recovery_flag == RECOVER)
printf("Recovery required\n");
} else {
......@@ -517,11 +517,14 @@ int ext4fs_check_journal_state(int recovery_flag)
end:
if (recovery_flag == RECOVER) {
uint32_t new_feature_incompat;
jsb->s_start = cpu_to_be32(1);
jsb->s_sequence = cpu_to_be32(be32_to_cpu(jsb->s_sequence) + 1);
/* get the superblock */
ext4_read_superblock((char *)fs->sb);
fs->sb->feature_incompat |= EXT3_FEATURE_INCOMPAT_RECOVER;
new_feature_incompat = le32_to_cpu(fs->sb->feature_incompat);
new_feature_incompat |= EXT3_FEATURE_INCOMPAT_RECOVER;
fs->sb->feature_incompat = cpu_to_le32(new_feature_incompat);
/* Update the super block */
put_ext4((uint64_t) (SUPERBLOCK_SIZE),
......
......@@ -115,8 +115,8 @@ extern struct ext2_data *ext4fs_root;
int ext4fs_init_journal(void);
int ext4fs_log_gdt(char *gd_table);
int ext4fs_check_journal_state(int recovery_flag);
int ext4fs_log_journal(char *journal_buffer, long int blknr);
int ext4fs_put_metadata(char *metadata_buffer, long int blknr);
int ext4fs_log_journal(char *journal_buffer, uint32_t blknr);
int ext4fs_put_metadata(char *metadata_buffer, uint32_t blknr);
void ext4fs_update_journal(void);
void ext4fs_dump_metadata(void);
void ext4fs_push_revoke_blk(char *buffer);
......
此差异已折叠。
......@@ -52,7 +52,7 @@
#define LOG2_BLOCK_SIZE(data) (le32_to_cpu \
(data->sblock.log2_block_size) \
+ EXT2_MIN_BLOCK_LOG_SIZE)
#define INODE_SIZE_FILESYSTEM(data) (le32_to_cpu \
#define INODE_SIZE_FILESYSTEM(data) (le16_to_cpu \
(data->sblock.inode_size))
#define EXT2_FT_DIR 2
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册