mirror of
https://github.com/vivier/EMILE.git
synced 2024-12-22 10:29:31 +00:00
use directly block address instead of computing it with blocksize, correct parameter of get_blocksize()
This commit is contained in:
parent
642feb9d59
commit
3eb3d6005e
@ -17,13 +17,19 @@ map_t* map_open(device_io_t *device)
|
|||||||
{
|
{
|
||||||
map_t *map;
|
map_t *map;
|
||||||
int ret;
|
int ret;
|
||||||
int blocksize = device->get_blocksize(device);
|
int blocksize = device->get_blocksize(device->data);
|
||||||
|
|
||||||
ASSERT_DD(printf("INTERNAL ERROR: Bad Block 0 size structure\n");
|
ASSERT_DD(printf("INTERNAL ERROR: Bad Block 0 size structure\n");
|
||||||
return NULL;)
|
return NULL;)
|
||||||
ASSERT_P(printf("INTERNAL ERROR: Bad Partition size structure\n");
|
ASSERT_P(printf("INTERNAL ERROR: Bad Partition size structure\n");
|
||||||
return NULL;)
|
return NULL;)
|
||||||
|
|
||||||
|
if (blocksize > MAP_BLOCKSIZE)
|
||||||
|
{
|
||||||
|
printf("device block size too big (%d)\n", blocksize);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
map = (map_t*)malloc(sizeof(map_t));
|
map = (map_t*)malloc(sizeof(map_t));
|
||||||
if (map == NULL)
|
if (map == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -36,18 +42,20 @@ map_t* map_open(device_io_t *device)
|
|||||||
}
|
}
|
||||||
memcpy(map->device, device, sizeof(device_io_t));
|
memcpy(map->device, device, sizeof(device_io_t));
|
||||||
|
|
||||||
ret = device->read_sector(map->device->data, 0,
|
ret = map->device->read_sector(map->device->data, 0,
|
||||||
&map->drivers, sizeof(map->drivers));
|
&map->drivers, blocksize);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
|
printf("Cannot read block 0\n");
|
||||||
free(map);
|
free(map);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = device->read_sector(map->device->data, sizeof(map->drivers) / blocksize,
|
ret = map->device->read_sector(map->device->data, 1,
|
||||||
&map->partition, sizeof(map->partition));
|
&map->partition, blocksize);
|
||||||
if (ret == -1)
|
if (ret == -1)
|
||||||
{
|
{
|
||||||
|
printf("Cannot read first partition descriptor\n");
|
||||||
free(map);
|
free(map);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user