diff options
author | Eric Norum <WENorum@lbl.gov> | 2005-02-08 17:12:54 +0000 |
---|---|---|
committer | Eric Norum <WENorum@lbl.gov> | 2005-02-08 17:12:54 +0000 |
commit | 624867bc09632b9c98235073f9a1b4f130233c47 (patch) | |
tree | 3f2c55aaa075ed371dcc4059d6f673d801240d2a /cpukit/libfs/src/imfs/memfile.c | |
parent | 2005-02-08 Ralf Corsepius <ralf.corsepius@rtems.org> (diff) | |
download | rtems-624867bc09632b9c98235073f9a1b4f130233c47.tar.bz2 |
Add copy-on-write semantics to rtems_tarfs_load().
Diffstat (limited to 'cpukit/libfs/src/imfs/memfile.c')
-rw-r--r-- | cpukit/libfs/src/imfs/memfile.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index 1a68531c38..4b4dc8ccce 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -99,6 +99,23 @@ int memfile_open( the_jnode = iop->file_info; + /* + * Perform 'copy on write' for linear files + */ + if ((iop->flags & (LIBIO_FLAGS_WRITE | LIBIO_FLAGS_APPEND)) + && (the_jnode->type == IMFS_LINEAR_FILE)) { + uint32_t count = the_jnode->info.linearfile.size; + const unsigned char *buffer = the_jnode->info.linearfile.direct; + + the_jnode->type = IMFS_MEMORY_FILE; + the_jnode->info.file.size = 0; + the_jnode->info.file.indirect = 0; + the_jnode->info.file.doubly_indirect = 0; + the_jnode->info.file.triply_indirect = 0; + if ((count != 0) + && (IMFS_memfile_write(the_jnode, 0, buffer, count) == -1)) + return -1; + } if (iop->flags & LIBIO_FLAGS_APPEND) iop->offset = the_jnode->info.file.size; |