mirror of
git://projects.qi-hardware.com/xburst-tools.git
synced 2025-02-17 00:34:43 +02:00
qi-fix-ext2-sdhc.patch
This adjusts ext2fs_devread to use block addressing itself with dynamic multiplier support separately. Signed-off-by: Andy Green <andy@openmoko.com>
This commit is contained in:
parent
c4e54f889f
commit
50fe6feeac
@ -32,11 +32,13 @@ extern unsigned long partition_offset_blocks;
|
|||||||
extern unsigned long partition_length_blocks;
|
extern unsigned long partition_length_blocks;
|
||||||
|
|
||||||
|
|
||||||
int ext2fs_devread(int sector, int byte_offset, int byte_len, u8 *buf)
|
int ext2fs_devread(int sector, int filesystem_block_log2, int byte_offset, int byte_len, u8 *buf)
|
||||||
{
|
{
|
||||||
unsigned char sec_buf[SECTOR_SIZE];
|
unsigned char sec_buf[SECTOR_SIZE];
|
||||||
unsigned block_len;
|
unsigned block_len;
|
||||||
|
|
||||||
|
sector = sector << filesystem_block_log2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check partition boundaries
|
* Check partition boundaries
|
||||||
*/
|
*/
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#include <malloc.h>
|
#include <malloc.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
extern int ext2fs_devread(int sector, int byte_offset, int byte_len,
|
extern int ext2fs_devread(int sector, int log2blksize, int byte_offset, int byte_len,
|
||||||
char *buf);
|
char *buf);
|
||||||
|
|
||||||
/* Magic value used to identify an ext2 filesystem. */
|
/* Magic value used to identify an ext2 filesystem. */
|
||||||
@ -193,8 +193,8 @@ static int ext2fs_blockgroup
|
|||||||
puts("ext2fs read blockgroup\n");
|
puts("ext2fs read blockgroup\n");
|
||||||
#endif
|
#endif
|
||||||
return ext2fs_devread
|
return ext2fs_devread
|
||||||
(((__le32_to_cpu(data->sblock.first_data_block) +
|
((__le32_to_cpu(data->sblock.first_data_block) +
|
||||||
1) << LOG2_EXT2_BLOCK_SIZE(data)),
|
1), LOG2_EXT2_BLOCK_SIZE(data),
|
||||||
group * sizeof(struct ext2_block_group),
|
group * sizeof(struct ext2_block_group),
|
||||||
sizeof(struct ext2_block_group),(char *) blkgrp);
|
sizeof(struct ext2_block_group),(char *) blkgrp);
|
||||||
}
|
}
|
||||||
@ -231,10 +231,11 @@ static int ext2fs_read_inode
|
|||||||
puts("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
|
puts("ext2fs read inode blkno %d blkoff %d\n", blkno, blkoff);
|
||||||
#endif
|
#endif
|
||||||
/* Read the inode. */
|
/* Read the inode. */
|
||||||
status = ext2fs_devread((__le32_to_cpu(blkgrp.inode_table_id) +
|
|
||||||
blkno) << LOG2_EXT2_BLOCK_SIZE(data),
|
status = ext2fs_devread(__le32_to_cpu(blkgrp.inode_table_id) + blkno,
|
||||||
ext2_inode_size * blkoff,
|
LOG2_EXT2_BLOCK_SIZE(data),
|
||||||
sizeof(struct ext2_inode),(char *) inode);
|
ext2_inode_size * blkoff,
|
||||||
|
sizeof(struct ext2_inode), (char *)inode);
|
||||||
|
|
||||||
return !!status;
|
return !!status;
|
||||||
}
|
}
|
||||||
@ -284,7 +285,7 @@ static int ext2fs_read_block(ext2fs_node_t node, int fileblock) {
|
|||||||
}
|
}
|
||||||
if ((__le32_to_cpu(inode->b.blocks.indir_block) <<
|
if ((__le32_to_cpu(inode->b.blocks.indir_block) <<
|
||||||
log2_blksz) != indir1_blkno) {
|
log2_blksz) != indir1_blkno) {
|
||||||
status = ext2fs_devread(__le32_to_cpu(inode->b.blocks.indir_block) << log2_blksz,
|
status = ext2fs_devread(__le32_to_cpu(inode->b.blocks.indir_block), log2_blksz,
|
||||||
0, blksz,
|
0, blksz,
|
||||||
(char *) indir1_block);
|
(char *) indir1_block);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
@ -328,7 +329,7 @@ static int ext2fs_read_block(ext2fs_node_t node, int fileblock) {
|
|||||||
}
|
}
|
||||||
if ((__le32_to_cpu(inode->b.blocks.double_indir_block) <<
|
if ((__le32_to_cpu(inode->b.blocks.double_indir_block) <<
|
||||||
log2_blksz) != indir1_blkno) {
|
log2_blksz) != indir1_blkno) {
|
||||||
status = ext2fs_devread(__le32_to_cpu(inode->b.blocks.double_indir_block) << log2_blksz,
|
status = ext2fs_devread(__le32_to_cpu(inode->b.blocks.double_indir_block), log2_blksz,
|
||||||
0, blksz,
|
0, blksz,
|
||||||
(char *) indir1_block);
|
(char *) indir1_block);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
@ -362,7 +363,7 @@ static int ext2fs_read_block(ext2fs_node_t node, int fileblock) {
|
|||||||
}
|
}
|
||||||
if ((__le32_to_cpu(indir1_block[rblock / perblock]) <<
|
if ((__le32_to_cpu(indir1_block[rblock / perblock]) <<
|
||||||
log2_blksz) != indir1_blkno) {
|
log2_blksz) != indir1_blkno) {
|
||||||
status = ext2fs_devread(__le32_to_cpu(indir1_block[rblock / perblock]) << log2_blksz,
|
status = ext2fs_devread(__le32_to_cpu(indir1_block[rblock / perblock]), log2_blksz,
|
||||||
0, blksz,
|
0, blksz,
|
||||||
(char *) indir2_block);
|
(char *) indir2_block);
|
||||||
if (status == 0) {
|
if (status == 0) {
|
||||||
@ -434,7 +435,7 @@ int ext2fs_read_file
|
|||||||
if (blknr) {
|
if (blknr) {
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
status = ext2fs_devread(blknr, skipfirst, blockend, buf);
|
status = ext2fs_devread(blknr, 0 /* already accounted */, skipfirst, blockend, buf);
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
return -1;
|
return -1;
|
||||||
} else
|
} else
|
||||||
@ -864,7 +865,7 @@ int ext2fs_mount(void) {
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Read the superblock. */
|
/* Read the superblock. */
|
||||||
status = ext2fs_devread(1 * 2, 0, sizeof(struct ext2_sblock),
|
status = ext2fs_devread(1 * 2, 0, 0, sizeof(struct ext2_sblock),
|
||||||
(char *) &data->sblock);
|
(char *) &data->sblock);
|
||||||
if (!status)
|
if (!status)
|
||||||
goto fail;
|
goto fail;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user