diff --git a/block-raw-posix.c b/block-raw-posix.c index 2fbb714d01ba278e92344810fc349d80271acd65..d17af0b34e23f3d3899addce2e5c0afdf3fdf74f 100644 --- a/block-raw-posix.c +++ b/block-raw-posix.c @@ -252,7 +252,7 @@ static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset, ret = fd_open(bs); if (ret < 0) - return ret; + return -errno; if (offset >= 0 && lseek(s->fd, offset, SEEK_SET) == (off_t)-1) { ++(s->lseek_err_cnt); @@ -262,7 +262,7 @@ static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset, s->fd, bs->filename, offset, buf, count, bs->total_sectors, errno, strerror(errno)); } - return -1; + return -EIO; } s->lseek_err_cnt = 0; @@ -277,7 +277,7 @@ static int raw_pwrite_aligned(BlockDriverState *bs, int64_t offset, label__raw_write__success: - return ret; + return (ret < 0) ? -errno : ret; }