fs/minix: Fix sector promotion to 64-bit.
While on it make GRUB_MINIX_ZONE2SECT into function. Found by: Coverity scan
This commit is contained in:
parent
ac602ce700
commit
ca793e9c05
1 changed files with 23 additions and 16 deletions
|
@ -82,17 +82,6 @@ typedef grub_uint16_t grub_minix_ino_t;
|
||||||
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
|
#define GRUB_MINIX_INODE_DINDIR_ZONE(data) (grub_minix_to_cpu_n \
|
||||||
(data->inode.double_indir_zone))
|
(data->inode.double_indir_zone))
|
||||||
|
|
||||||
#ifndef MODE_MINIX3
|
|
||||||
#define GRUB_MINIX_LOG2_ZONESZ (GRUB_MINIX_LOG2_BSIZE \
|
|
||||||
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef MODE_MINIX3
|
|
||||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) * data->block_size)
|
|
||||||
#else
|
|
||||||
#define GRUB_MINIX_ZONE2SECT(zone) ((zone) << GRUB_MINIX_LOG2_ZONESZ)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef MODE_MINIX3
|
#ifdef MODE_MINIX3
|
||||||
struct grub_minix_sblock
|
struct grub_minix_sblock
|
||||||
|
@ -182,6 +171,23 @@ static grub_dl_t my_mod;
|
||||||
static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
|
static grub_err_t grub_minix_find_file (struct grub_minix_data *data,
|
||||||
const char *path);
|
const char *path);
|
||||||
|
|
||||||
|
#ifdef MODE_MINIX3
|
||||||
|
static inline grub_disk_addr_t
|
||||||
|
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
|
||||||
|
{
|
||||||
|
return ((grub_disk_addr_t) zone) * data->block_size;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
static inline grub_disk_addr_t
|
||||||
|
grub_minix_zone2sect (struct grub_minix_data *data, grub_minix_uintn_t zone)
|
||||||
|
{
|
||||||
|
int log2_zonesz = (GRUB_MINIX_LOG2_BSIZE
|
||||||
|
+ grub_minix_to_cpu16 (data->sblock.log2_zone_size));
|
||||||
|
return (((grub_disk_addr_t) zone) << log2_zonesz);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Read the block pointer in ZONE, on the offset NUM. */
|
/* Read the block pointer in ZONE, on the offset NUM. */
|
||||||
static grub_minix_uintn_t
|
static grub_minix_uintn_t
|
||||||
grub_get_indir (struct grub_minix_data *data,
|
grub_get_indir (struct grub_minix_data *data,
|
||||||
|
@ -190,7 +196,7 @@ grub_get_indir (struct grub_minix_data *data,
|
||||||
{
|
{
|
||||||
grub_minix_uintn_t indirn;
|
grub_minix_uintn_t indirn;
|
||||||
grub_disk_read (data->disk,
|
grub_disk_read (data->disk,
|
||||||
GRUB_MINIX_ZONE2SECT(zone),
|
grub_minix_zone2sect(data, zone),
|
||||||
sizeof (grub_minix_uintn_t) * num,
|
sizeof (grub_minix_uintn_t) * num,
|
||||||
sizeof (grub_minix_uintn_t), (char *) &indirn);
|
sizeof (grub_minix_uintn_t), (char *) &indirn);
|
||||||
return grub_minix_to_cpu_n (indirn);
|
return grub_minix_to_cpu_n (indirn);
|
||||||
|
@ -281,7 +287,7 @@ grub_minix_read_file (struct grub_minix_data *data,
|
||||||
|
|
||||||
for (i = posblock; i < blockcnt; i++)
|
for (i = posblock; i < blockcnt; i++)
|
||||||
{
|
{
|
||||||
grub_disk_addr_t blknr;
|
grub_minix_uintn_t blknr;
|
||||||
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
|
grub_uint64_t blockend = data->block_size << GRUB_DISK_SECTOR_BITS;
|
||||||
grub_off_t skipfirst = 0;
|
grub_off_t skipfirst = 0;
|
||||||
|
|
||||||
|
@ -310,7 +316,7 @@ grub_minix_read_file (struct grub_minix_data *data,
|
||||||
data->disk->read_hook = read_hook;
|
data->disk->read_hook = read_hook;
|
||||||
data->disk->read_hook_data = read_hook_data;
|
data->disk->read_hook_data = read_hook_data;
|
||||||
grub_disk_read (data->disk,
|
grub_disk_read (data->disk,
|
||||||
GRUB_MINIX_ZONE2SECT(blknr),
|
grub_minix_zone2sect(data, blknr),
|
||||||
skipfirst, blockend, buf);
|
skipfirst, blockend, buf);
|
||||||
data->disk->read_hook = 0;
|
data->disk->read_hook = 0;
|
||||||
if (grub_errno)
|
if (grub_errno)
|
||||||
|
@ -336,7 +342,8 @@ grub_minix_read_inode (struct grub_minix_data *data, grub_minix_ino_t ino)
|
||||||
|
|
||||||
/* The first inode in minix is inode 1. */
|
/* The first inode in minix is inode 1. */
|
||||||
ino--;
|
ino--;
|
||||||
block = GRUB_MINIX_ZONE2SECT (2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
|
block = grub_minix_zone2sect (data,
|
||||||
|
2 + grub_minix_to_cpu16 (sblock->inode_bmap_size)
|
||||||
+ grub_minix_to_cpu16 (sblock->zone_bmap_size));
|
+ grub_minix_to_cpu16 (sblock->zone_bmap_size));
|
||||||
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
|
block += ino / (GRUB_DISK_SECTOR_SIZE / sizeof (struct grub_minix_inode));
|
||||||
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
|
int offs = (ino % (GRUB_DISK_SECTOR_SIZE
|
||||||
|
|
Loading…
Reference in a new issue