summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-13 10:36:11 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-15 10:27:12 +0200
commit3cffd66d763ec83de382e2cb03c04e2eba0ac5e9 (patch)
tree19bacd70e9f1667422a6a0fa184dee468d690cd7
parenta937a5a5347cf945fe7eff17eccd97cc849a5349 (diff)
downloadrtems-3cffd66d763ec83de382e2cb03c04e2eba0ac5e9.tar.bz2
libio: Add rtems_libio_iop_is_writeable()
Update #3132.
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h10
-rw-r--r--cpukit/libfs/src/imfs/imfs_linfile.c2
-rw-r--r--cpukit/libnetworking/lib/ftpfs.c4
3 files changed, 13 insertions, 3 deletions
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 7d85fb7af3..72a787eebc 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1400,6 +1400,16 @@ static inline bool rtems_libio_iop_is_readable( const rtems_libio_t *iop )
}
/**
+ * @brief Returns true if this is a writeable iop, otherwise returns false.
+ *
+ * @param[in] iop The iop.
+ */
+static inline bool rtems_libio_iop_is_writeable( const rtems_libio_t *iop )
+{
+ return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_WRITE ) != 0;
+}
+
+/**
* @name External I/O Handlers
*/
/**@{**/
diff --git a/cpukit/libfs/src/imfs/imfs_linfile.c b/cpukit/libfs/src/imfs/imfs_linfile.c
index 80a77c3ef8..a27ba99ede 100644
--- a/cpukit/libfs/src/imfs/imfs_linfile.c
+++ b/cpukit/libfs/src/imfs/imfs_linfile.c
@@ -56,7 +56,7 @@ static int IMFS_linfile_open(
/*
* Perform 'copy on write' for linear files
*/
- if ((iop->flags & LIBIO_FLAGS_WRITE) != 0) {
+ if (rtems_libio_iop_is_writeable(iop)) {
uint32_t count = file->File.size;
const unsigned char *buffer = file->Linearfile.direct;
diff --git a/cpukit/libnetworking/lib/ftpfs.c b/cpukit/libnetworking/lib/ftpfs.c
index deccddfa89..1e0f180fd0 100644
--- a/cpukit/libnetworking/lib/ftpfs.c
+++ b/cpukit/libnetworking/lib/ftpfs.c
@@ -1032,11 +1032,11 @@ static int rtems_ftpfs_open(
bool verbose = me->verbose;
const struct timeval *timeout = &me->timeout;
- e->write = (iop->flags & LIBIO_FLAGS_WRITE) != 0;
+ e->write = rtems_libio_iop_is_writeable(iop);
/* Check for either read-only or write-only flags */
if (
- (iop->flags & LIBIO_FLAGS_WRITE) != 0
+ rtems_libio_iop_is_writeable(iop)
&& rtems_libio_iop_is_readable(iop)
) {
eno = ENOTSUP;