Fix wrapped HFS+ handling.

* grub-core/fs/fshelp.c (grub_fshelp_read_file): New argument
	blocks_start. All users updated.
	* grub-core/fs/hfsplus.c (grub_hfsplus_read_block): Don't add
	wrapping offset.
	(grub_hfsplus_read_file): Pass embedding offset to fshelp_read_file.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-05-09 13:02:59 +02:00
parent 607d282b29
commit f417ed0432
11 changed files with 25 additions and 14 deletions

View file

@ -1,3 +1,13 @@
2012-05-09 Vladimir Serbinenko <phcoder@gmail.com>
Fix wrapped HFS+ handling.
* grub-core/fs/fshelp.c (grub_fshelp_read_file): New argument
blocks_start. All users updated.
* grub-core/fs/hfsplus.c (grub_hfsplus_read_block): Don't add
wrapping offset.
(grub_hfsplus_read_file): Pass embedding offset to fshelp_read_file.
2012-05-09 Vladimir Serbinenko <phcoder@gmail.com> 2012-05-09 Vladimir Serbinenko <phcoder@gmail.com>
Fix long symlinks on reiserfs. Fix long symlinks on reiserfs.

View file

@ -498,7 +498,7 @@ grub_affs_read (grub_file_t file, char *buf, grub_size_t len)
file->read_hook, file->read_hook,
file->offset, len, buf, grub_affs_read_block, file->offset, len, buf, grub_affs_read_block,
grub_be_to_cpu32 (data->diropen.di.size), grub_be_to_cpu32 (data->diropen.di.size),
data->log_blocksize); data->log_blocksize, 0);
} }
static grub_int32_t static grub_int32_t

View file

@ -520,7 +520,7 @@ grub_ext2_read_file (grub_fshelp_node_t node,
pos, len, buf, grub_ext2_read_block, pos, len, buf, grub_ext2_read_block,
grub_cpu_to_le32 (node->inode.size) grub_cpu_to_le32 (node->inode.size)
| (((grub_off_t) grub_cpu_to_le32 (node->inode.size_high)) << 32), | (((grub_off_t) grub_cpu_to_le32 (node->inode.size_high)) << 32),
LOG2_EXT2_BLOCK_SIZE (node->data)); LOG2_EXT2_BLOCK_SIZE (node->data), 0);
} }

View file

@ -233,7 +233,8 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
grub_off_t pos, grub_size_t len, char *buf, grub_off_t pos, grub_size_t len, char *buf,
grub_disk_addr_t (*get_block) (grub_fshelp_node_t node, grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,
grub_disk_addr_t block), grub_disk_addr_t block),
grub_off_t filesize, int log2blocksize) grub_off_t filesize, int log2blocksize,
grub_disk_addr_t blocks_start)
{ {
grub_disk_addr_t i, blockcnt; grub_disk_addr_t i, blockcnt;
int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS); int blocksize = 1 << (log2blocksize + GRUB_DISK_SECTOR_BITS);
@ -281,7 +282,7 @@ grub_fshelp_read_file (grub_disk_t disk, grub_fshelp_node_t node,
{ {
disk->read_hook = read_hook; disk->read_hook = read_hook;
grub_disk_read (disk, blknr, skipfirst, grub_disk_read (disk, blknr + blocks_start, skipfirst,
blockend, buf); blockend, buf);
disk->read_hook = 0; disk->read_hook = 0;
if (grub_errno) if (grub_errno)

View file

@ -327,9 +327,7 @@ grub_hfsplus_read_block (grub_fshelp_node_t node, grub_disk_addr_t fileblock)
nnode = 0; nnode = 0;
if (blk != 0xffffffffffffffffULL) if (blk != 0xffffffffffffffffULL)
return (blk return blk;
+ (node->data->embedded_offset >> (node->data->log2blksize
- GRUB_DISK_SECTOR_BITS)));
/* For the extent overflow file, extra extents can't be found in /* For the extent overflow file, extra extents can't be found in
the extent overflow file. If this happens, you found a the extent overflow file. If this happens, you found a
@ -382,7 +380,8 @@ grub_hfsplus_read_file (grub_fshelp_node_t node,
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_hfsplus_read_block, pos, len, buf, grub_hfsplus_read_block,
node->size, node->size,
node->data->log2blksize - GRUB_DISK_SECTOR_BITS); node->data->log2blksize - GRUB_DISK_SECTOR_BITS,
node->data->embedded_offset);
} }
static struct grub_hfsplus_data * static struct grub_hfsplus_data *

View file

@ -635,7 +635,7 @@ grub_nilfs2_read_file (grub_fshelp_node_t node,
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_nilfs2_read_block, pos, len, buf, grub_nilfs2_read_block,
grub_le_to_cpu64 (node->inode.i_size), grub_le_to_cpu64 (node->inode.i_size),
LOG2_NILFS2_BLOCK_SIZE (node->data)); LOG2_NILFS2_BLOCK_SIZE (node->data), 0);
} }

View file

@ -483,7 +483,7 @@ read_data (struct grub_ntfs_attr *at, char *pa, char *dest,
if (!grub_fshelp_log2blksize (ctx->comp.spc, &pow)) if (!grub_fshelp_log2blksize (ctx->comp.spc, &pow))
grub_fshelp_read_file (ctx->comp.disk, (grub_fshelp_node_t) ctx, grub_fshelp_read_file (ctx->comp.disk, (grub_fshelp_node_t) ctx,
read_hook, ofs, len, dest, read_hook, ofs, len, dest,
grub_ntfs_read_block, ofs + len, pow); grub_ntfs_read_block, ofs + len, pow, 0);
return grub_errno; return grub_errno;
} }

View file

@ -351,7 +351,7 @@ grub_sfs_read_file (grub_fshelp_node_t node,
{ {
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_sfs_read_block, pos, len, buf, grub_sfs_read_block,
node->size, node->data->log_blocksize); node->size, node->data->log_blocksize, 0);
} }

View file

@ -594,7 +594,7 @@ grub_udf_read_file (grub_fshelp_node_t node,
return grub_fshelp_read_file (node->data->disk, node, read_hook, return grub_fshelp_read_file (node->data->disk, node, read_hook,
pos, len, buf, grub_udf_read_block, pos, len, buf, grub_udf_read_block,
U64 (node->block.fe.file_size), U64 (node->block.fe.file_size),
node->data->lbshift); node->data->lbshift, 0);
} }
static unsigned sblocklist[] = { 256, 512, 0 }; static unsigned sblocklist[] = { 256, 512, 0 };

View file

@ -389,7 +389,7 @@ grub_xfs_read_file (grub_fshelp_node_t node,
pos, len, buf, grub_xfs_read_block, pos, len, buf, grub_xfs_read_block,
grub_be_to_cpu64 (node->inode.size), grub_be_to_cpu64 (node->inode.size),
node->data->sblock.log2_bsize node->data->sblock.log2_bsize
- GRUB_DISK_SECTOR_BITS); - GRUB_DISK_SECTOR_BITS, 0);
} }

View file

@ -73,7 +73,8 @@ EXPORT_FUNC(grub_fshelp_read_file) (grub_disk_t disk, grub_fshelp_node_t node,
grub_off_t pos, grub_size_t len, char *buf, grub_off_t pos, grub_size_t len, char *buf,
grub_disk_addr_t (*get_block) (grub_fshelp_node_t node, grub_disk_addr_t (*get_block) (grub_fshelp_node_t node,
grub_disk_addr_t block), grub_disk_addr_t block),
grub_off_t filesize, int log2blocksize); grub_off_t filesize, int log2blocksize,
grub_disk_addr_t blocks_start);
unsigned int unsigned int
EXPORT_FUNC(grub_fshelp_log2blksize) (unsigned int blksize, EXPORT_FUNC(grub_fshelp_log2blksize) (unsigned int blksize,