summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJennifer Averett <Jennifer.Averett@OARcorp.com>2002-12-26 15:48:48 +0000
committerJennifer Averett <Jennifer.Averett@OARcorp.com>2002-12-26 15:48:48 +0000
commit4257974362ed8e6890dc72dd15a6613cd6c7a33b (patch)
tree958a00a0b1e5a1ea460a2bceb5ec4eb023e23b27
parentb4e2f7931a16701a4066fdd111830736a0440161 (diff)
downloadrtems-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.c20
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;
}
-