diff --git a/usr.sbin/bhyveload/bhyveload.c b/usr.sbin/bhyveload/bhyveload.c index 1b3be71745da..db7d995f2466 100644 --- a/usr.sbin/bhyveload/bhyveload.c +++ b/usr.sbin/bhyveload/bhyveload.c @@ -300,11 +300,11 @@ cb_stat(void *arg, void *h, struct stat *sbp) static int cb_diskread(void *arg, int unit, uint64_t from, void *to, size_t size, - size_t *resid) + size_t *resid) { ssize_t n; - if (unit < 0 || unit >= ndisks ) + if (unit < 0 || unit >= ndisks) return (EIO); n = pread(disk_fd[unit], to, size, from); if (n < 0) @@ -313,6 +313,21 @@ cb_diskread(void *arg, int unit, uint64_t from, void *to, size_t size, return (0); } +static int +cb_diskwrite(void *arg, int unit, uint64_t offset, void *src, size_t size, + size_t *resid) +{ + ssize_t n; + + if (unit < 0 || unit >= ndisks) + return (EIO); + n = pwrite(disk_fd[unit], src, size, offset); + if (n < 0) + return (errno); + *resid = size - n; + return (0); +} + static int cb_diskioctl(void *arg, int unit, u_long cmd, void *data) { @@ -611,6 +626,7 @@ static struct loader_callbacks cb = { .stat = cb_stat, .diskread = cb_diskread, + .diskwrite = cb_diskwrite, .diskioctl = cb_diskioctl, .copyin = cb_copyin,