After trying out a few approaches, here is what I think is the simplest viable way to print a user-friendly warning if opening a file O_DIRECT fails with EINVAL. This happens on Linux tmpfs.
We don't really know why we got EINVAL but if O_DIRECT was used it's a good clue that the file system does not support O_DIRECT. Stefan Hajnoczi (2): libcacard: link against qemu-error.o for error_report() osdep: warn if open(O_DIRECT) on fails with EINVAL libcacard/Makefile | 3 ++- util/osdep.c | 7 +++++++ 2 files changed, 9 insertions(+), 1 deletion(-) -- 1.8.3.1