[virtio] Virtio read/write block return 0 on success instead of number of bytes transferred
This commit is contained in:
@@ -316,7 +316,12 @@ static ssize_t virtio_bdev_read_block(struct bdev *bdev, void *buf, bnum_t block
|
||||
|
||||
LTRACEF("dev %p, buf %p, block 0x%x, count %u\n", bdev, buf, block, count);
|
||||
|
||||
return virtio_block_read_write(dev->dev, buf, (off_t)block * dev->bdev.block_size, count * dev->bdev.block_size, false);
|
||||
if (virtio_block_read_write(dev->dev, buf, (off_t)block * dev->bdev.block_size,
|
||||
count * dev->bdev.block_size, false) == 0) {
|
||||
return count * dev->bdev.block_size;
|
||||
} else {
|
||||
return ERR_IO;
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t virtio_bdev_write_block(struct bdev *bdev, const void *buf, bnum_t block, uint count)
|
||||
@@ -325,6 +330,11 @@ static ssize_t virtio_bdev_write_block(struct bdev *bdev, const void *buf, bnum_
|
||||
|
||||
LTRACEF("dev %p, buf %p, block 0x%x, count %u\n", bdev, buf, block, count);
|
||||
|
||||
return virtio_block_read_write(dev->dev, (void *)buf, (off_t)block * dev->bdev.block_size, count * dev->bdev.block_size, true);
|
||||
if (virtio_block_read_write(dev->dev, (void *)buf, (off_t)block * dev->bdev.block_size,
|
||||
count * dev->bdev.block_size, true) == 0) {
|
||||
return count * dev->bdev.block_size;
|
||||
} else {
|
||||
return ERR_IO;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ static ssize_t bio_default_read(struct bdev *dev, void *_buf, off_t offset, size
|
||||
uint8_t *buf = (uint8_t *)_buf;
|
||||
ssize_t bytes_read = 0;
|
||||
bnum_t block;
|
||||
int err = 0;
|
||||
ssize_t err = 0;
|
||||
STACKBUF_DMA_ALIGN(temp, dev->block_size); // temporary buffer for partial block transfers
|
||||
|
||||
/* find the starting block */
|
||||
@@ -145,7 +145,7 @@ static ssize_t bio_default_write(struct bdev *dev, const void *_buf, off_t offse
|
||||
const uint8_t *buf = (const uint8_t *)_buf;
|
||||
ssize_t bytes_written = 0;
|
||||
bnum_t block;
|
||||
int err = 0;
|
||||
ssize_t err = 0;
|
||||
STACKBUF_DMA_ALIGN(temp, dev->block_size); // temporary buffer for partial block transfers
|
||||
|
||||
/* find the starting block */
|
||||
|
||||
Reference in New Issue
Block a user