Use shifts in squash4.
* grub-core/fs/squash4.c (grub_squash_data): New field log2_blksz. (squash_mount): Check block size and take logarithm. (direct_read): Use shifts.
This commit is contained in:
parent
ad03fe768e
commit
ed9ba06dd0
2 changed files with 21 additions and 6 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Use shifts in squash4.
|
||||||
|
|
||||||
|
* grub-core/fs/squash4.c (grub_squash_data): New field log2_blksz.
|
||||||
|
(squash_mount): Check block size and take logarithm.
|
||||||
|
(direct_read): Use shifts.
|
||||||
|
|
||||||
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Correct befs block counting logic.
|
Correct befs block counting logic.
|
||||||
|
|
|
@ -173,6 +173,7 @@ struct grub_squash_data
|
||||||
struct grub_squash_super sb;
|
struct grub_squash_super sb;
|
||||||
struct grub_squash_cache_inode ino;
|
struct grub_squash_cache_inode ino;
|
||||||
grub_uint64_t fragments;
|
grub_uint64_t fragments;
|
||||||
|
int log2_blksz;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct grub_fshelp_node
|
struct grub_fshelp_node
|
||||||
|
@ -267,7 +268,10 @@ squash_mount (grub_disk_t disk)
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not a squash4");
|
grub_error (GRUB_ERR_BAD_FS, "not a squash4");
|
||||||
if (err)
|
if (err)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (grub_le_to_cpu32 (sb.magic) != SQUASH_MAGIC)
|
if (grub_le_to_cpu32 (sb.magic) != SQUASH_MAGIC
|
||||||
|
|| grub_le_to_cpu32 (sb.block_size) == 0
|
||||||
|
|| ((grub_le_to_cpu32 (sb.block_size) - 1)
|
||||||
|
& grub_le_to_cpu32 (sb.block_size)))
|
||||||
{
|
{
|
||||||
grub_error (GRUB_ERR_BAD_FS, "not squash4");
|
grub_error (GRUB_ERR_BAD_FS, "not squash4");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -290,6 +294,10 @@ squash_mount (grub_disk_t disk)
|
||||||
data->disk = disk;
|
data->disk = disk;
|
||||||
data->fragments = grub_le_to_cpu64 (frag);
|
data->fragments = grub_le_to_cpu64 (frag);
|
||||||
|
|
||||||
|
for (data->log2_blksz = 0;
|
||||||
|
(1U << data->log2_blksz) < grub_le_to_cpu32 (data->sb.block_size);
|
||||||
|
data->log2_blksz++);
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -528,10 +536,9 @@ direct_read (struct grub_squash_data *data,
|
||||||
block_offset = ((char *) &ino->ino.file.block_size
|
block_offset = ((char *) &ino->ino.file.block_size
|
||||||
- (char *) &ino->ino);
|
- (char *) &ino->ino);
|
||||||
}
|
}
|
||||||
total_blocks = grub_divmod64 (total_size
|
total_blocks = ((total_size
|
||||||
+ grub_le_to_cpu32 (data->sb.block_size) - 1,
|
+ grub_le_to_cpu32 (data->sb.block_size) - 1)
|
||||||
grub_le_to_cpu32 (data->sb.block_size),
|
>> data->log2_blksz);
|
||||||
0);
|
|
||||||
ino->block_sizes = grub_malloc (total_blocks
|
ino->block_sizes = grub_malloc (total_blocks
|
||||||
* sizeof (ino->block_sizes[0]));
|
* sizeof (ino->block_sizes[0]));
|
||||||
ino->cumulated_block_sizes = grub_malloc (total_blocks
|
ino->cumulated_block_sizes = grub_malloc (total_blocks
|
||||||
|
@ -565,7 +572,7 @@ direct_read (struct grub_squash_data *data,
|
||||||
|
|
||||||
if (a == 0)
|
if (a == 0)
|
||||||
a = sizeof (struct grub_squash_super);
|
a = sizeof (struct grub_squash_super);
|
||||||
i = grub_divmod64 (off, grub_le_to_cpu32 (data->sb.block_size), 0);
|
i = off >> data->log2_blksz;
|
||||||
cumulated_uncompressed_size = grub_le_to_cpu32 (data->sb.block_size)
|
cumulated_uncompressed_size = grub_le_to_cpu32 (data->sb.block_size)
|
||||||
* (grub_disk_addr_t) i;
|
* (grub_disk_addr_t) i;
|
||||||
while (cumulated_uncompressed_size < off + len)
|
while (cumulated_uncompressed_size < off + len)
|
||||||
|
|
Loading…
Reference in a new issue