mirror of
https://github.com/vivier/EMILE.git
synced 2025-04-06 21:37:06 +00:00
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:
parent
ffe511becc
commit
22d6bc63a9
@ -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;
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user