libio: Add rtems_libio_iop_is_readable()

Update #3132.
This commit is contained in:
Sebastian Huber
2017-09-13 10:35:45 +02:00
parent bbcdc302cd
commit a937a5a534
3 changed files with 13 additions and 3 deletions

View File

@@ -255,7 +255,7 @@ rtems_device_driver console_open(
} }
} }
if ( (args->iop->flags&LIBIO_FLAGS_READ) && if (rtems_libio_iop_is_readable(args->iop) &&
cptr->pDeviceFlow && cptr->pDeviceFlow &&
cptr->pDeviceFlow->deviceStartRemoteTx) { cptr->pDeviceFlow->deviceStartRemoteTx) {
cptr->pDeviceFlow->deviceStartRemoteTx(minor); cptr->pDeviceFlow->deviceStartRemoteTx(minor);
@@ -288,7 +288,7 @@ rtems_device_driver console_close(
* Stop only if it's the last one opened. * Stop only if it's the last one opened.
*/ */
if ( (current_tty->refcount == 1) ) { if ( (current_tty->refcount == 1) ) {
if ( (args->iop->flags&LIBIO_FLAGS_READ) && if (rtems_libio_iop_is_readable(args->iop) &&
cptr->pDeviceFlow && cptr->pDeviceFlow &&
cptr->pDeviceFlow->deviceStopRemoteTx) { cptr->pDeviceFlow->deviceStopRemoteTx) {
cptr->pDeviceFlow->deviceStopRemoteTx(minor); cptr->pDeviceFlow->deviceStopRemoteTx(minor);

View File

@@ -1389,6 +1389,16 @@ static inline bool rtems_libio_iop_is_no_delay( const rtems_libio_t *iop )
return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_NO_DELAY ) != 0; return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_NO_DELAY ) != 0;
} }
/**
* @brief Returns true if this is a readable iop, otherwise returns false.
*
* @param[in] iop The iop.
*/
static inline bool rtems_libio_iop_is_readable( const rtems_libio_t *iop )
{
return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_READ ) != 0;
}
/** /**
* @name External I/O Handlers * @name External I/O Handlers
*/ */

View File

@@ -1037,7 +1037,7 @@ static int rtems_ftpfs_open(
/* Check for either read-only or write-only flags */ /* Check for either read-only or write-only flags */
if ( if (
(iop->flags & LIBIO_FLAGS_WRITE) != 0 (iop->flags & LIBIO_FLAGS_WRITE) != 0
&& (iop->flags & LIBIO_FLAGS_READ) != 0 && rtems_libio_iop_is_readable(iop)
) { ) {
eno = ENOTSUP; eno = ENOTSUP;
} }