Received: from eggs.gnu.org ([2001:4830:134:3::10]:46957) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b2ZYF-0000kQ-Kq for qemu-devel@nongnu.org; Tue, 17 May 2016 03:36:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b2ZY9-0003uU-Rb for qemu-devel@nongnu.org; Tue, 17 May 2016 03:36:22 -0400 From: Fam Zheng Date: Tue, 17 May 2016 15:35:18 +0800 Message-Id: <1463470536-8981-10-git-send-email-famz@redhat.com> In-Reply-To: <1463470536-8981-1-git-send-email-famz@redhat.com> References: <1463470536-8981-1-git-send-email-famz@redhat.com> Subject: [Qemu-devel] [PATCH v5 09/27] osdep: Introduce qemu_dup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Max Reitz , Jeff Cody , Markus Armbruster , Eric Blake , John Snow , qemu-block@nongnu.org, berrange@redhat.com, pbonzini@redhat.com, den@openvz.org, stefanha@redhat.com This takes care both the CLOEXEC flag and fd-path mapping for image locking. Signed-off-by: Fam Zheng --- 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); +} + + /* * A variant of write(2) which handles partial write. * -- 2.8.2