Received: from eggs.gnu.org ([2001:4830:134:3::10]:60002) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN4iu-00039u-JD for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VN4in-0005BV-Dr for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:44117) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VN4in-0005BP-6C for qemu-devel@nongnu.org; Fri, 20 Sep 2013 13:42:25 -0400 From: Stefan Hajnoczi Date: Fri, 20 Sep 2013 19:42:02 +0200 Message-Id: <1379698931-946-3-git-send-email-stefanha@redhat.com> In-Reply-To: <1379698931-946-1-git-send-email-stefanha@redhat.com> References: <1379698931-946-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 02/11] osdep: warn if open(O_DIRECT) on fails with EINVAL List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , Anthony Liguori Print a warning when opening a file O_DIRECT fails with EINVAL. This saves users a lot of time trying to figure out the EINVAL error, which is typical when attempting to open a file O_DIRECT on Linux tmpfs. Reported-by: Deepak C Shetty Signed-off-by: Stefan Hajnoczi Reviewed-by: Eric Blake --- util/osdep.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/util/osdep.c b/util/osdep.c index 685c8ae..62072b4 100644 --- a/util/osdep.c +++ b/util/osdep.c @@ -207,6 +207,13 @@ int qemu_open(const char *name, int flags, ...) } #endif +#ifdef O_DIRECT + if (ret == -1 && errno == EINVAL && (flags & O_DIRECT)) { + error_report("file system may not support O_DIRECT"); + errno = EINVAL; /* in case it was clobbered */ + } +#endif /* O_DIRECT */ + return ret; } -- 1.8.3.1