From f2d741e7b9b60c6bfc1226bae87ffb4cd19e9f27 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sat, 4 Feb 2012 16:39:30 +0100 Subject: [PATCH] ioctl: Fix test failure on native Windows. * lib/ioctl.c: Include msvc-nothrow.h. (primary_ioctl): If fd is not a valid handle, set errno to EBADF. --- ChangeLog | 6 ++++++ lib/ioctl.c | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index e7cd49737..4bbe44754 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2012-02-04 Bruno Haible + ioctl: Fix test failure on native Windows. + * lib/ioctl.c: Include msvc-nothrow.h. + (primary_ioctl): If fd is not a valid handle, set errno to EBADF. + +2012-02-04 Bruno Haible + fsync: Avoid test failure on native Windows. * lib/fsync.c (fsync) [Windows]: Don't fail if the handle is merely read-only. diff --git a/lib/ioctl.c b/lib/ioctl.c index 8701b7a7e..2e51c92d9 100644 --- a/lib/ioctl.c +++ b/lib/ioctl.c @@ -47,6 +47,8 @@ rpl_ioctl (int fd, int request, ... /* {void *,char *} arg */) # include # include "fd-hook.h" +/* Get _get_osfhandle. */ +# include "msvc-nothrow.h" static int primary_ioctl (int fd, int request, void *arg) @@ -55,7 +57,10 @@ primary_ioctl (int fd, int request, void *arg) fds non-blocking, use the gnulib 'nonblocking' module, until gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK. */ - errno = ENOSYS; + if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE) + errno = ENOSYS; + else + errno = EBADF; return -1; } -- 2.11.0