data is map->device->data and not map->device, read_sector() and write_sector() need an offset in block and not in bytes whereas size is in bytes

This commit is contained in:
Laurent Vivier 2007-10-10 16:41:31 +00:00
parent ffe511becc
commit 22d6bc63a9
6 changed files with 12 additions and 11 deletions

View File

@ -13,7 +13,7 @@ int map_block0_write(map_t *map)
{
int ret;
ret = map->device->write_sector(map->device, 0,
ret = map->device->write_sector(map->device->data, 0,
&map->drivers, sizeof(map->drivers));
return ret;

View File

@ -17,6 +17,7 @@ map_t* map_open(device_io_t *device)
{
map_t *map;
int ret;
int blocksize = device->get_blocksize(device);
ASSERT_DD(printf("INTERNAL ERROR: Bad Block 0 size structure\n");
return NULL;)
@ -29,7 +30,7 @@ map_t* map_open(device_io_t *device)
map->device = device;
ret = device->read_sector(map->device, 0,
ret = device->read_sector(map->device->data, 0,
&map->drivers, sizeof(map->drivers));
if (ret == -1)
{
@ -37,7 +38,7 @@ map_t* map_open(device_io_t *device)
return NULL;
}
ret = device->read_sector(map->device, sizeof(map->drivers),
ret = device->read_sector(map->device->data, sizeof(map->drivers) / blocksize,
&map->partition, sizeof(map->partition));
if (ret == -1)
{

View File

@ -19,10 +19,9 @@ int map_partition_read(map_t* map, off_t offset, size_t size, char* sector)
if (!map_partition_is_valid(map))
return -1;
offset += read_long((u_int32_t*)&map->partition.PyPartStart)
* FLOPPY_SECTOR_SIZE;
offset += read_long((u_int32_t*)&map->partition.PyPartStart);
ret = map->device->read_sector(map->device, offset, sector, size);
ret = map->device->read_sector(map->device->data, offset, sector, size);
return ret;
}

View File

@ -19,10 +19,9 @@ int map_partition_write(map_t* map, off_t offset, size_t size, char* sector)
if (!map_partition_is_valid(map))
return -1;
offset += read_long((u_int32_t*)&map->partition.PyPartStart)
* FLOPPY_SECTOR_SIZE;
offset += read_long((u_int32_t*)&map->partition.PyPartStart);
ret = map->device->write_sector(map->device, offset, sector, size);
ret = map->device->write_sector(map->device->data, offset, sector, size);
return ret;
}

View File

@ -13,6 +13,7 @@ int map_read(map_t *map, int part)
{
off_t offset;
int ret;
int blocksize = map->device->get_blocksize(map->device);
if (map->current == part)
return part;
@ -22,7 +23,7 @@ int map_read(map_t *map, int part)
offset = part * sizeof(struct Partition) + sizeof(struct DriverDescriptor);
ret = map->device->read_sector(map->device, offset, &map->partition,
ret = map->device->read_sector(map->device->data, offset / blocksize, &map->partition,
sizeof(struct Partition));
if (ret == -1)
return -1;

View File

@ -13,6 +13,7 @@ int map_write(map_t *map, int part)
{
off_t offset;
int ret;
int blocksize = map->device->get_blocksize(map->device);
if (part > map->partition.MapBlkCnt)
return -1;
@ -20,7 +21,7 @@ int map_write(map_t *map, int part)
offset = part * sizeof(struct Partition) +
sizeof(struct DriverDescriptor);
ret = map->device->write_sector(map->device, offset, &map->partition,
ret = map->device->write_sector(map->device->data, offset / blocksize, &map->partition,
sizeof(struct Partition));
if (ret != -1)
return -1;