qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-block] [PATCH v5 09/27] osdep: Introduce qemu_dup


From: Max Reitz
Subject: Re: [Qemu-block] [PATCH v5 09/27] osdep: Introduce qemu_dup
Date: Tue, 24 May 2016 18:52:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.1.0

On 17.05.2016 09:35, Fam Zheng wrote:
> This takes care

+of

>                 both the CLOEXEC flag and fd-path mapping for image
> locking.
> 
> Signed-off-by: Fam Zheng <address@hidden>
> ---
>  include/qemu/osdep.h | 1 +
>  util/osdep.c         | 6 ++++++
>  2 files changed, 7 insertions(+)
> 
> diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
> index 81913a7..0e51279 100644
> --- a/include/qemu/osdep.h
> +++ b/include/qemu/osdep.h
> @@ -266,6 +266,7 @@ int qemu_madvise(void *addr, size_t len, int advice);
>  int qemu_open(const char *name, int flags, ...);
>  int qemu_close(int fd);
>  int qemu_lock_fd(int fd, int64_t start, int64_t len, bool exclusive);
> +int qemu_dup(int fd);
>  int qemu_unlock_fd(int fd, int64_t start, int64_t len);
>  
>  #if defined(__HAIKU__) && defined(__i386__)
> diff --git a/util/osdep.c b/util/osdep.c
> index 9e5d7fa..966bc32 100644
> --- a/util/osdep.c
> +++ b/util/osdep.c
> @@ -267,6 +267,12 @@ int qemu_unlock_fd(int fd, int64_t start, int64_t len)
>      return qemu_lock_fcntl(fd, start, len, F_UNLCK);
>  }
>  
> +int qemu_dup(int fd)
> +{
> +    return qemu_dup_flags(fd, 0);
> +}

I don't think we have this function on Windows. Maybe you don't need
qemu_dup() on Windows, then it would make sense to wrap it in an
appropriate #ifndef.

Also, I'm not sure how useful it is to return -1 on error with errno
being set. Since this is a public function, maybe it makes more sense to
return -errno then.

Max

> +
> +
>  /*
>   * A variant of write(2) which handles partial write.
>   *
> 


Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]