From d973ba18ced6e9440131c55b0f07e97bdbbc6703 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Thu, 16 Aug 2012 12:15:18 +0100 Subject: [PATCH] osdep: Fix compilation failure on BSD systems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix compilation failure on BSD systems (which don't have O_DIRECT or O_NOATIME: osdep.c:116: error: ‘O_DIRECT’ undeclared (first use in this function) osdep.c:116: error: (Each undeclared identifier is reported only once osdep.c:116: error: for each function it appears in.) osdep.c:116: error: ‘O_NOATIME’ undeclared (first use in this function) Reviewed-by: Stefan Weil Signed-off-by: Peter Maydell Signed-off-by: Anthony Liguori --- osdep.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/osdep.c b/osdep.c index 5b78ceebef..3b25297a25 100644 --- a/osdep.c +++ b/osdep.c @@ -113,7 +113,13 @@ static int qemu_dup_flags(int fd, int flags) } /* Set/unset flags that we can with fcntl */ - setfl_flags = O_APPEND | O_ASYNC | O_DIRECT | O_NOATIME | O_NONBLOCK; + setfl_flags = O_APPEND | O_ASYNC | O_NONBLOCK; +#ifdef O_NOATIME + setfl_flags |= O_NOATIME; +#endif +#ifdef O_DIRECT + setfl_flags |= O_DIRECT; +#endif dup_flags &= ~setfl_flags; dup_flags |= (flags & setfl_flags); if (fcntl(ret, F_SETFL, dup_flags) == -1) {