Patchwork raw-posix: Better error return values for hdev_create

login
register
mail settings
Submitter Kevin Wolf
Date March 12, 2010, 12:52 p.m.
Message ID <1268398351-8113-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/47671/
State New
Headers show

Comments

Kevin Wolf - March 12, 2010, 12:52 p.m.
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: Kevin Wolf <kwolf@redhat.com>
---
 block/raw-posix.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)
Christoph Hellwig - March 12, 2010, 2:01 p.m.
On Fri, Mar 12, 2010 at 01:52:31PM +0100, Kevin Wolf wrote:
> 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: Kevin Wolf <kwolf@redhat.com>

Looks good,


Reviewed-by: Christoph Hellwig <hch@lst.de>
Aurelien Jarno - March 27, 2010, 12:34 p.m.
On Fri, Mar 12, 2010 at 01:52:31PM +0100, Kevin Wolf wrote:
> 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: Kevin Wolf <kwolf@redhat.com>

Thanks, applied.

> ---
>  block/raw-posix.c |    6 +++---
>  1 files changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/block/raw-posix.c b/block/raw-posix.c
> index 716c15c..f07d730 100644
> --- a/block/raw-posix.c
> +++ b/block/raw-posix.c
> @@ -1009,12 +1009,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;
>  
> -- 
> 1.6.6.1
> 
> 
> 
>

Patch

diff --git a/block/raw-posix.c b/block/raw-posix.c
index 716c15c..f07d730 100644
--- a/block/raw-posix.c
+++ b/block/raw-posix.c
@@ -1009,12 +1009,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;