summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-13 10:42:21 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2017-09-15 10:27:12 +0200
commitd4c54416b73bd1a067e8270543d30146f55eea91 (patch)
treeb8d0e5926b3e2398c8518f1d292e7b792036dc59
parent3cffd66d763ec83de382e2cb03c04e2eba0ac5e9 (diff)
downloadrtems-d4c54416b73bd1a067e8270543d30146f55eea91.tar.bz2
libio: Add rtems_libio_iop_is_append()
Update #3132.
-rw-r--r--cpukit/libcsupport/include/rtems/libio.h10
-rw-r--r--cpukit/libfs/src/dosfs/msdos_file.c2
-rw-r--r--cpukit/libfs/src/imfs/imfs_memfile.c2
-rw-r--r--cpukit/libfs/src/jffs2/src/fs-rtems.c6
-rw-r--r--cpukit/libfs/src/nfsclient/src/nfs.c2
-rw-r--r--cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c2
6 files changed, 17 insertions, 7 deletions
diff --git a/cpukit/libcsupport/include/rtems/libio.h b/cpukit/libcsupport/include/rtems/libio.h
index 72a787eebc..2a67496800 100644
--- a/cpukit/libcsupport/include/rtems/libio.h
+++ b/cpukit/libcsupport/include/rtems/libio.h
@@ -1410,6 +1410,16 @@ static inline bool rtems_libio_iop_is_writeable( const rtems_libio_t *iop )
}
/**
+ * @brief Returns true if this is an append iop, otherwise returns false.
+ *
+ * @param[in] iop The iop.
+ */
+static inline bool rtems_libio_iop_is_append( const rtems_libio_t *iop )
+{
+ return ( rtems_libio_iop_flags( iop ) & LIBIO_FLAGS_APPEND ) != 0;
+}
+
+/**
* @name External I/O Handlers
*/
/**@{**/
diff --git a/cpukit/libfs/src/dosfs/msdos_file.c b/cpukit/libfs/src/dosfs/msdos_file.c
index ada943d854..d150a1ff22 100644
--- a/cpukit/libfs/src/dosfs/msdos_file.c
+++ b/cpukit/libfs/src/dosfs/msdos_file.c
@@ -91,7 +91,7 @@ msdos_file_write(rtems_libio_t *iop,const void *buffer, size_t count)
if (sc != RTEMS_SUCCESSFUL)
rtems_set_errno_and_return_minus_one(EIO);
- if ((iop->flags & LIBIO_FLAGS_APPEND) != 0)
+ if (rtems_libio_iop_is_append(iop))
iop->offset = fat_fd->fat_file_size;
ret = fat_file_write(&fs_info->fat, fat_fd, iop->offset, count,
diff --git a/cpukit/libfs/src/imfs/imfs_memfile.c b/cpukit/libfs/src/imfs/imfs_memfile.c
index 2227bba6af..9e3474bc86 100644
--- a/cpukit/libfs/src/imfs/imfs_memfile.c
+++ b/cpukit/libfs/src/imfs/imfs_memfile.c
@@ -87,7 +87,7 @@ static ssize_t memfile_write(
IMFS_memfile_t *memfile = IMFS_iop_to_memfile( iop );
ssize_t status;
- if ((iop->flags & LIBIO_FLAGS_APPEND) != 0)
+ if (rtems_libio_iop_is_append(iop))
iop->offset = memfile->File.size;
status = IMFS_memfile_write( memfile, iop->offset, buffer, count );
diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c
index 5e702ce5ec..262bec9b27 100644
--- a/cpukit/libfs/src/jffs2/src/fs-rtems.c
+++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c
@@ -672,10 +672,10 @@ static ssize_t rtems_jffs2_file_write(rtems_libio_t *iop, const void *buf, size_
rtems_jffs2_do_lock(inode->i_sb);
- if ((iop->flags & LIBIO_FLAGS_APPEND) == 0) {
- pos = iop->offset;
- } else {
+ if (rtems_libio_iop_is_append(iop)) {
pos = inode->i_size;
+ } else {
+ pos = iop->offset;
}
if (pos > inode->i_size) {
diff --git a/cpukit/libfs/src/nfsclient/src/nfs.c b/cpukit/libfs/src/nfsclient/src/nfs.c
index 87fef54ac0..ca4226465a 100644
--- a/cpukit/libfs/src/nfsclient/src/nfs.c
+++ b/cpukit/libfs/src/nfsclient/src/nfs.c
@@ -2566,7 +2566,7 @@ Nfs nfs = node->nfs;
SERP_ARGS(node).writearg.beginoffset = UINT32_C(0xdeadbeef);
- if ( LIBIO_FLAGS_APPEND & iop->flags ) {
+ if (rtems_libio_iop_is_append(iop)) {
if ( updateAttr(node, 0) ) {
return -1;
}
diff --git a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
index 99782db72b..69e5df2a97 100644
--- a/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
+++ b/cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
@@ -208,7 +208,7 @@ rtems_rfs_rtems_file_write (rtems_libio_t* iop,
rtems_rfs_file_set_bpos (file, pos);
}
- else if (pos < file_size && (iop->flags & LIBIO_FLAGS_APPEND) != 0)
+ else if (pos < file_size && rtems_libio_iop_is_append(iop))
{
pos = file_size;
rc = rtems_rfs_file_seek (file, pos, &pos);