From: Stefan Hajnoczi Date: Thu, 22 Aug 2013 09:29:03 +0000 (+0200) Subject: osdep: warn if open(O_DIRECT) on fails with EINVAL X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~524^2~3^2~148^2~9 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a5813077aac7865f69b7ee46a594f3705429f7cd;p=sdk%2Femulator%2Fqemu.git osdep: warn if open(O_DIRECT) on fails with EINVAL 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 --- diff --git a/util/osdep.c b/util/osdep.c index 685c8ae889..62072b4be3 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; }