Use shifts in minix filesystem.
* grub-core/fs/minix.c (GRUB_MINIX_ZONESZ): Use log_block_size. (GRUB_MINIX_ZONE2SECT): Likewise. (grub_minix_data): Replace block_size with log_block_size. (grub_minix_read_file): Use shifts. (grub_minix_mount): Check block size and take a logarithm.
This commit is contained in:
parent
ed9ba06dd0
commit
564dd58c2a
2 changed files with 29 additions and 13 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
|
Use shifts in minix filesystem.
|
||||||
|
|
||||||
|
* grub-core/fs/minix.c (GRUB_MINIX_ZONESZ): Use log_block_size.
|
||||||
|
(GRUB_MINIX_ZONE2SECT): Likewise.
|
||||||
|
(grub_minix_data): Replace block_size with log_block_size.
|
||||||
|
(grub_minix_read_file): Use shifts.
|
||||||
|
(grub_minix_mount): Check block size and take a logarithm.
|
||||||
|
|
||||||
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
2011-10-28 Vladimir Serbinenko <phcoder@gmail.com>
|
||||||
|
|
||||||
Use shifts in squash4.
|
Use shifts in squash4.
|
||||||
|
|
|
@ -76,11 +76,11 @@ typedef grub_uint16_t grub_minix_ino_t;
|
||||||
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
|
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
|
||||||
+ grub_le_to_cpu16 (data->sblock.log2_zone_size))
|
+ grub_le_to_cpu16 (data->sblock.log2_zone_size))
|
||||||
#endif
|
#endif
|
||||||
#define GRUB_MINIX_ZONESZ (data->block_size \
|
#define GRUB_MINIX_ZONESZ (1 << (data->log_block_size \
|
||||||
<< grub_le_to_cpu16 (data->sblock.log2_zone_size))
|
+ grub_le_to_cpu16 (data->sblock.log2_zone_size)))
|
||||||
|
|
||||||
#ifdef MODE_MINIX3
|
#ifdef MODE_MINIX3
|
||||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * (data->block_size / GRUB_DISK_SECTOR_SIZE))
|
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << (data->log_block_size - GRUB_DISK_SECTOR_BITS))
|
||||||
#else
|
#else
|
||||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
|
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
|
||||||
#endif
|
#endif
|
||||||
|
@ -159,7 +159,7 @@ struct grub_minix_data
|
||||||
int linknest;
|
int linknest;
|
||||||
grub_disk_t disk;
|
grub_disk_t disk;
|
||||||
int filename_size;
|
int filename_size;
|
||||||
grub_size_t block_size;
|
grub_size_t log_block_size;
|
||||||
};
|
};
|
||||||
|
|
||||||
static grub_dl_t my_mod;
|
static grub_dl_t my_mod;
|
||||||
|
@ -251,14 +251,15 @@ grub_minix_read_file (struct grub_minix_data *data,
|
||||||
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
|
if (len + pos > GRUB_MINIX_INODE_SIZE (data))
|
||||||
len = GRUB_MINIX_INODE_SIZE (data) - pos;
|
len = GRUB_MINIX_INODE_SIZE (data) - pos;
|
||||||
|
|
||||||
blockcnt = grub_divmod64 ((len + pos + data->block_size - 1),
|
blockcnt = ((len + pos + (1 << data->log_block_size) - 1)
|
||||||
data->block_size, 0);
|
>> data->log_block_size);
|
||||||
posblock = grub_divmod64 (pos, data->block_size, &blockoff);
|
posblock = pos >> data->log_block_size;
|
||||||
|
blockoff = pos & ((1 << data->log_block_size) - 1);
|
||||||
|
|
||||||
for (i = posblock; i < blockcnt; i++)
|
for (i = posblock; i < blockcnt; i++)
|
||||||
{
|
{
|
||||||
grub_disk_addr_t blknr;
|
grub_disk_addr_t blknr;
|
||||||
grub_uint64_t blockend = data->block_size;
|
grub_uint64_t blockend = 1 << data->log_block_size;
|
||||||
grub_off_t skipfirst = 0;
|
grub_off_t skipfirst = 0;
|
||||||
|
|
||||||
blknr = grub_minix_get_file_block (data, i);
|
blknr = grub_minix_get_file_block (data, i);
|
||||||
|
@ -268,10 +269,10 @@ grub_minix_read_file (struct grub_minix_data *data,
|
||||||
/* Last block. */
|
/* Last block. */
|
||||||
if (i == blockcnt - 1)
|
if (i == blockcnt - 1)
|
||||||
{
|
{
|
||||||
grub_divmod64 (len + pos, data->block_size, &blockend);
|
blockend = (len + pos) & ((1 << data->log_block_size) - 1);
|
||||||
|
|
||||||
if (!blockend)
|
if (!blockend)
|
||||||
blockend = data->block_size;
|
blockend = 1 << data->log_block_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First block. */
|
/* First block. */
|
||||||
|
@ -289,7 +290,7 @@ grub_minix_read_file (struct grub_minix_data *data,
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
buf += data->block_size - skipfirst;
|
buf += (1 << data->log_block_size) - skipfirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
@ -479,9 +480,14 @@ grub_minix_mount (grub_disk_t disk)
|
||||||
data->disk = disk;
|
data->disk = disk;
|
||||||
data->linknest = 0;
|
data->linknest = 0;
|
||||||
#ifdef MODE_MINIX3
|
#ifdef MODE_MINIX3
|
||||||
data->block_size = grub_le_to_cpu16 (data->sblock.block_size);
|
if ((grub_le_to_cpu16 (data->sblock.block_size)
|
||||||
|
& (grub_le_to_cpu16 (data->sblock.block_size) - 1))
|
||||||
|
|| grub_le_to_cpu16 (data->sblock.block_size) == 0)
|
||||||
|
goto fail;
|
||||||
|
for (data->log_block_size = 0; (1 << data->log_block_size)
|
||||||
|
< grub_le_to_cpu16 (data->sblock.block_size); data->log_block_size++);
|
||||||
#else
|
#else
|
||||||
data->block_size = 1024U;
|
data->log_block_size = 10;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
Loading…
Reference in a new issue