提交 57e69b7d 编写于 作者: K Kevin Wolf 提交者: Aurelien Jarno

raw-posix: Better error return values for hdev_create

Now that we output an error message according to the returned error code in
qemu-img, let's return the real error codes. "Input/output error" for
everything isn't helpful.
Signed-off-by: NKevin Wolf <kwolf@redhat.com>
Reviewed-by: NChristoph Hellwig <hch@lst.de>
Signed-off-by: NAurelien Jarno <aurelien@aurel32.net>
上级 8d533561
......@@ -993,12 +993,12 @@ static int hdev_create(const char *filename, QEMUOptionParameter *options)
fd = open(filename, O_WRONLY | O_BINARY);
if (fd < 0)
return -EIO;
return -errno;
if (fstat(fd, &stat_buf) < 0)
ret = -EIO;
ret = -errno;
else if (!S_ISBLK(stat_buf.st_mode) && !S_ISCHR(stat_buf.st_mode))
ret = -EIO;
ret = -ENODEV;
else if (lseek(fd, 0, SEEK_END) < total_size * 512)
ret = -ENOSPC;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册