[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH] block: Use error codes from lower levels for error
From: |
Stefan Weil |
Subject: |
[Qemu-devel] [PATCH] block: Use error codes from lower levels for error message |
Date: |
Sun, 18 Jul 2010 21:42:30 +0200 |
"No such file or directory" is a misleading error message
when a user tries to open a file with wrong permissions.
Cc: Kevin Wolf <address@hidden>
Signed-off-by: Stefan Weil <address@hidden>
---
block.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index f837876..2f80540 100644
--- a/block.c
+++ b/block.c
@@ -330,16 +330,20 @@ BlockDriver *bdrv_find_protocol(const char *filename)
return NULL;
}
-static BlockDriver *find_image_format(const char *filename)
+static BlockDriver *find_image_format(const char *filename, int *error)
{
int ret, score, score_max;
BlockDriver *drv1, *drv;
uint8_t buf[2048];
BlockDriverState *bs;
+ *error = -ENOENT;
+
ret = bdrv_file_open(&bs, filename, 0);
- if (ret < 0)
+ if (ret < 0) {
+ *error = ret;
return NULL;
+ }
/* Return the raw BlockDriver * to scsi-generic devices or empty drives */
if (bs->sg || !bdrv_is_inserted(bs)) {
@@ -350,6 +354,7 @@ static BlockDriver *find_image_format(const char *filename)
ret = bdrv_pread(bs, 0, buf, sizeof(buf));
bdrv_delete(bs);
if (ret < 0) {
+ *error = ret;
return NULL;
}
@@ -571,12 +576,11 @@ int bdrv_open(BlockDriverState *bs, const char *filename,
int flags,
/* Find the right image format driver */
if (!drv) {
- drv = find_image_format(filename);
+ drv = find_image_format(filename, &ret);
probed = 1;
}
if (!drv) {
- ret = -ENOENT;
goto unlink_and_fail;
}
--
1.7.1
- [Qemu-devel] [PATCH] block: Use error codes from lower levels for error message,
Stefan Weil <=