From 5b78cd6bc981eff94840301fa87f134f1abbcb77 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 7 Mar 2006 21:02:00 +0000 Subject: 2006-03-07 Till Strauman PR 886/filesystem * src/libio.c: fcntl(fd,F_GETFL) fails to set O_NONBLOCK if the descriptor is in non-blocking mode. --- cpukit/libcsupport/ChangeLog | 6 ++++++ cpukit/libcsupport/src/libio.c | 27 ++++++++++++++++----------- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/cpukit/libcsupport/ChangeLog b/cpukit/libcsupport/ChangeLog index 7b75feb111..92bd4689f7 100644 --- a/cpukit/libcsupport/ChangeLog +++ b/cpukit/libcsupport/ChangeLog @@ -1,3 +1,9 @@ +2006-03-07 Till Strauman + + PR 886/filesystem + * src/libio.c: fcntl(fd,F_GETFL) fails to set O_NONBLOCK if the + descriptor is in non-blocking mode. + 2005-08-31 Ralf Corsepius PR 819/filesystem diff --git a/cpukit/libcsupport/src/libio.c b/cpukit/libcsupport/src/libio.c index bc868dd51a..d7c7cf1f55 100644 --- a/cpukit/libcsupport/src/libio.c +++ b/cpukit/libcsupport/src/libio.c @@ -26,16 +26,19 @@ #include #include -#if ! defined(O_NDELAY) -# if defined(solaris2) -# define O_NDELAY O_NONBLOCK -# elif defined(__CYGWIN__) -# define O_NDELAY _FNBIO -# elif defined(RTEMS_NEWLIB) -# define O_NDELAY _FNBIO -# endif -#endif - +/* define this to alias O_NDELAY to O_NONBLOCK, i.e., + * O_NDELAY is accepted on input but fcntl(F_GETFL) returns + * O_NONBLOCK. This is because rtems has no distinction + * between the two (but some systems have). + * Note that accepting this alias creates a problem: + * an application trying to clear the non-blocking flag + * using a + * + * fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) & ~O_NDELAY); + * + * does (silently) ignore the operation. + */ +#undef ACCEPT_O_NDELAY_ALIAS #include #include /* strcmp */ @@ -114,7 +117,9 @@ rtems_assoc_t access_modes_assoc[] = { }; rtems_assoc_t status_flags_assoc[] = { +#ifdef ACCEPT_O_NDELAY_ALIAS { "NO DELAY", LIBIO_FLAGS_NO_DELAY, O_NDELAY }, +#endif { "NONBLOCK", LIBIO_FLAGS_NO_DELAY, O_NONBLOCK }, { "APPEND", LIBIO_FLAGS_APPEND, O_APPEND }, { "CREATE", LIBIO_FLAGS_CREATE, O_CREAT }, @@ -166,7 +171,7 @@ unsigned32 rtems_libio_to_fcntl_flags( } if ( (flags & LIBIO_FLAGS_NO_DELAY) == LIBIO_FLAGS_NO_DELAY ) { - fcntl_flags |= O_NDELAY; + fcntl_flags |= O_NONBLOCK; } if ( (flags & LIBIO_FLAGS_APPEND) == LIBIO_FLAGS_APPEND ) { -- cgit v1.2.3