XDRV_READ reading in sectors
This commit is contained in:
@@ -66,7 +66,7 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
mountpoint->udata = tarfs;
|
||||
|
||||
struct device* back_device = mountpoint->back_device;
|
||||
size_t total_size;
|
||||
size_t total_size, sector_size;
|
||||
int ret;
|
||||
|
||||
spin_lock (&back_device->lock);
|
||||
@@ -78,6 +78,14 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = back_device->ops[XDRV_GET_SECTOR_SIZE](back_device, proc, rctx, §or_size, NULL, NULL,
|
||||
NULL);
|
||||
if (ret < 0) {
|
||||
spin_unlock (&back_device->lock);
|
||||
free (mountpoint->udata);
|
||||
return ret;
|
||||
}
|
||||
|
||||
uint8_t* buffer = malloc (total_size);
|
||||
|
||||
if (buffer == NULL) {
|
||||
@@ -86,8 +94,11 @@ int tarfs_mount (struct vfs_mountpoint* mountpoint, struct proc* proc,
|
||||
return ret;
|
||||
}
|
||||
|
||||
size_t pos = 0;
|
||||
ret = back_device->ops[XDRV_READ](back_device, proc, rctx, &pos, &total_size, buffer, NULL);
|
||||
size_t off = 0;
|
||||
for (size_t sector = 0; sector < total_size / sector_size; sector++) {
|
||||
uint8_t* dest = (uint8_t*)((uintptr_t)buffer + (sector * sector_size));
|
||||
ret = back_device->ops[XDRV_READ](back_device, proc, rctx, §or, &off, §or_size, dest);
|
||||
}
|
||||
|
||||
spin_unlock (&back_device->lock);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user