From d61b0a5abfb00abf91ef281a89cb3984b5eef737 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 7 May 2012 16:15:57 +0200 Subject: Filesystem: PR1871: Fix O_APPEND --- cpukit/libfs/src/imfs/memfile.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'cpukit/libfs/src/imfs/memfile.c') diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index 64679df037..d836172884 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -92,7 +92,7 @@ int memfile_open( /* * Perform 'copy on write' for linear files */ - if ((iop->flags & (LIBIO_FLAGS_WRITE | LIBIO_FLAGS_APPEND)) + if ((iop->flags & LIBIO_FLAGS_WRITE) && (IMFS_type( the_jnode ) == IMFS_LINEAR_FILE)) { uint32_t count = the_jnode->info.linearfile.size; const unsigned char *buffer = the_jnode->info.linearfile.direct; @@ -106,8 +106,6 @@ int memfile_open( && (IMFS_memfile_write(the_jnode, 0, buffer, count) == -1)) return -1; } - if (iop->flags & LIBIO_FLAGS_APPEND) - iop->offset = the_jnode->info.file.size; return 0; } @@ -146,6 +144,9 @@ ssize_t memfile_write( the_jnode = iop->pathinfo.node_access; + if ((iop->flags & LIBIO_FLAGS_APPEND) != 0) + iop->offset = the_jnode->info.file.size; + status = IMFS_memfile_write( the_jnode, iop->offset, buffer, count ); return status; -- cgit v1.2.3