-/* $OpenBSD: vioblk.c,v 1.5 2023/09/01 19:42:26 dv Exp $ */
+/* $OpenBSD: vioblk.c,v 1.6 2023/09/06 19:26:39 dv Exp $ */
/*
* Copyright (c) 2023 Dave Voutila <dv@openbsd.org>
goto nomem;
info->len = sz;
info->offset = sector * VIRTIO_BLK_SECTOR_SIZE;
- info->file = &dev->file;
return info;
nomem:
static const uint8_t *
-vioblk_finish_read(struct ioinfo *info)
+vioblk_finish_read(struct vioblk_dev *dev, struct ioinfo *info)
{
- struct virtio_backing *file;
+ struct virtio_backing *file = &dev->file;
- file = info->file;
if (file == NULL || file->pread == NULL) {
log_warnx("%s: XXX null?!", __func__);
return NULL;
}
if (file->pread(file->p, info->buf, info->len, info->offset) != info->len) {
- info->error = errno;
log_warn("vioblk read error");
return NULL;
}
goto nomem;
info->len = len;
info->offset = sector * VIRTIO_BLK_SECTOR_SIZE;
- info->file = &dev->file;
if (read_mem(addr, info->buf, info->len)) {
vioblk_free_info(info);
}
static int
-vioblk_finish_write(struct ioinfo *info)
+vioblk_finish_write(struct vioblk_dev *dev, struct ioinfo *info)
{
- struct virtio_backing *file;
+ struct virtio_backing *file = &dev->file;
- file = info->file;
if (file->pwrite(file->p, info->buf, info->len, info->offset) != info->len) {
log_warn("vioblk write error");
return EIO;
}
/* read the data, use current data descriptor */
- secdata = vioblk_finish_read(info);
+ secdata = vioblk_finish_read(dev, info);
if (secdata == NULL) {
vioblk_free_info(info);
log_warnx("vioblk: block read error, "
goto out;
}
- if (vioblk_finish_write(info)) {
+ if (vioblk_finish_write(dev, info)) {
log_warnx("wr vioblk: disk write "
"error");
vioblk_free_info(info);
-/* $OpenBSD: vioscsi.c,v 1.23 2023/04/01 06:39:03 jsg Exp $ */
+/* $OpenBSD: vioscsi.c,v 1.24 2023/09/06 19:26:39 dv Exp $ */
/*
* Copyright (c) 2017 Carlos Cardenas <ccardenas@openbsd.org>
goto nomem;
info->len = n_blocks * VIOSCSI_BLOCK_SIZE_CDROM;
info->offset = block * VIOSCSI_BLOCK_SIZE_CDROM;
- info->file = &dev->file;
return info;
}
static const uint8_t *
-vioscsi_finish_read(struct ioinfo *info)
+vioscsi_finish_read(struct vioscsi_dev *dev, struct ioinfo *info)
{
- struct virtio_backing *f;
+ struct virtio_backing *f = &dev->file;
- f = info->file;
if (f->pread(f->p, info->buf, info->len, info->offset) != info->len) {
- info->error = errno;
log_warn("vioscsi read error");
return NULL;
}
}
/* read block */
- read_buf = vioscsi_finish_read(info);
+ read_buf = vioscsi_finish_read(dev, info);
if (read_buf == NULL) {
log_warnx("%s: error reading position %ud",
}
/* read block */
- read_buf = vioscsi_finish_read(info);
+ read_buf = vioscsi_finish_read(dev, info);
if (read_buf == NULL) {
log_warnx("%s: error reading position %ud", __func__, read_lba);