diff options
author | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2002-12-26 15:48:48 +0000 |
---|---|---|
committer | Jennifer Averett <Jennifer.Averett@OARcorp.com> | 2002-12-26 15:48:48 +0000 |
commit | 4257974362ed8e6890dc72dd15a6613cd6c7a33b (patch) | |
tree | 958a00a0b1e5a1ea460a2bceb5ec4eb023e23b27 | |
parent | 2002-12-14 Ralf Corsepius <corsepiu@faw.uni-ulm.de> (diff) | |
download | rtems-4257974362ed8e6890dc72dd15a6613cd6c7a33b.tar.bz2 |
2002-12-26 Till Straumann <strauman@slac.stanford.edu
* src/fchdir.c - PR302 fix violation of FS node object copy semantics
-rw-r--r-- | cpukit/libcsupport/src/fchdir.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/cpukit/libcsupport/src/fchdir.c b/cpukit/libcsupport/src/fchdir.c index 7c984bc892..58fd04dcdb 100644 --- a/cpukit/libcsupport/src/fchdir.c +++ b/cpukit/libcsupport/src/fchdir.c @@ -29,6 +29,7 @@ int fchdir( ) { rtems_libio_t *iop; + rtems_filesystem_location_info_t loc, saved; rtems_libio_check_fd( fd ); iop = rtems_libio_iop( fd ); @@ -57,7 +58,6 @@ int fchdir( rtems_set_errno_and_return_minus_one( ENOTDIR ); } - rtems_filesystem_freenode( &rtems_filesystem_current ); /* * FIXME : I feel there should be another call to @@ -65,10 +65,26 @@ int fchdir( * this node which we are making here. I can * see the freenode interface but do not see * allocnode node interface. It maybe node_type. + * + * FIXED: T.Straumann: it is evaluate_path() + * but note the race condition. Threads who + * share their rtems_filesystem_current better + * be synchronized! */ + saved = rtems_filesystem_current; rtems_filesystem_current = iop->pathinfo; + /* clone the current node */ + if (rtems_filesystem_evaluate_path(".", 0, &loc, 0)) { + /* cloning failed; restore original and bail out */ + rtems_filesystem_current = saved; + return -1; + } + /* release the old one */ + rtems_filesystem_freenode( &saved ); + + rtems_filesystem_current = loc; + return 0; } - |