[PATCH 11/18] libio: Add rtems_libio_iop_flags()

Sebastian Huber sebastian.huber at embedded-brains.de
Wed Sep 13 13:39:44 UTC 2017


Update #3082.
---
 cpukit/libcsupport/include/rtems/libio.h   |  5 +++++
 cpukit/libcsupport/src/fcntl.c             | 10 +++++-----
 cpukit/libfs/src/pipe/fifo.c               |  2 +-
 cpukit/libnetworking/rtems/rtems_syscall.c |  2 +-
 4 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 99d1565bef..96d0c29d1e 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1374,6 +1374,11 @@ typedef struct {
 
 /** @} */
 
+static inline uint32_t rtems_libio_iop_flags( const rtems_libio_t *iop )
+{
+  return iop->flags;
+}
+
 /**
  * @name External I/O Handlers
  */
diff --git a/cpukit/libcsupport/src/fcntl.c b/cpukit/libcsupport/src/fcntl.c
index 7dc2c8110f..8e509ea269 100644
--- a/cpukit/libcsupport/src/fcntl.c
+++ b/cpukit/libcsupport/src/fcntl.c
@@ -30,7 +30,7 @@ static int duplicate_iop( rtems_libio_t *iop )
   int            oflag;
   rtems_libio_t *diop;
 
-  oflag = rtems_libio_to_fcntl_flags( iop->flags );
+  oflag = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
   diop = rtems_libio_allocate( rtems_libio_fcntl_flags( oflag ) );
 
   if (diop != NULL) {
@@ -68,12 +68,12 @@ static int duplicate2_iop( rtems_libio_t *iop, int fd2 )
   {
     int oflag;
 
-    if ((iop2->flags & LIBIO_FLAGS_OPEN) != 0) {
+    if ((rtems_libio_iop_flags( iop2 ) & LIBIO_FLAGS_OPEN) != 0) {
       rv = (*iop2->pathinfo.handlers->close_h)( iop2 );
     }
 
     if (rv == 0) {
-      oflag = rtems_libio_to_fcntl_flags( iop->flags );
+      oflag = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
       rtems_libio_iop_flags_set( iop2, rtems_libio_fcntl_flags( oflag ) );
 
       rtems_filesystem_instance_lock( &iop->pathinfo );
@@ -131,7 +131,7 @@ static int vfcntl(
       break;
 
     case F_GETFD:        /* get f_flags */
-      ret = ((iop->flags & LIBIO_FLAGS_CLOSE_ON_EXEC) != 0);
+      ret = ((rtems_libio_iop_flags(iop) & LIBIO_FLAGS_CLOSE_ON_EXEC) != 0);
       break;
 
     case F_SETFD:        /* set f_flags */
@@ -150,7 +150,7 @@ static int vfcntl(
       break;
 
     case F_GETFL:        /* more flags (cloexec) */
-      ret = rtems_libio_to_fcntl_flags( iop->flags );
+      ret = rtems_libio_to_fcntl_flags( rtems_libio_iop_flags( iop ) );
       break;
 
     case F_SETFL:
diff --git a/cpukit/libfs/src/pipe/fifo.c b/cpukit/libfs/src/pipe/fifo.c
index 15fb0d58eb..78e02efc27 100644
--- a/cpukit/libfs/src/pipe/fifo.c
+++ b/cpukit/libfs/src/pipe/fifo.c
@@ -31,7 +31,7 @@
 
 #include "pipe.h"
 
-#define LIBIO_ACCMODE(_iop) ((_iop)->flags & LIBIO_FLAGS_READ_WRITE)
+#define LIBIO_ACCMODE(_iop) (rtems_libio_iop_flags(_iop) & LIBIO_FLAGS_READ_WRITE)
 #define LIBIO_NODELAY(_iop) ((_iop)->flags & LIBIO_FLAGS_NO_DELAY)
 
 static rtems_id pipe_semaphore = RTEMS_ID_NONE;
diff --git a/cpukit/libnetworking/rtems/rtems_syscall.c b/cpukit/libnetworking/rtems/rtems_syscall.c
index dc4ee7a63c..df2a8a4bbb 100644
--- a/cpukit/libnetworking/rtems/rtems_syscall.c
+++ b/cpukit/libnetworking/rtems/rtems_syscall.c
@@ -52,7 +52,7 @@ rtems_bsdnet_fdToSocket (int fd)
   iop = rtems_libio_iop(fd);
 
   /* same as rtems_libio_check_is_open(iop) but different return */
-  if ((iop->flags & LIBIO_FLAGS_OPEN) == 0) {
+  if ((rtems_libio_iop_flags(iop) & LIBIO_FLAGS_OPEN) == 0) {
     errno = EBADF;
     return NULL;
   }
-- 
2.12.3




More information about the devel mailing list