summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_link.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-23 17:57:27 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:24:15 +0100
commit1bdff036acddbbc63aa849741abba6581549f7b6 (patch)
tree8cc1f06ac93045d8a7c35da41fd926c2d9e840f1 /cpukit/libfs/src/imfs/imfs_link.c
parentIMFS: Use unprotected chain operations (diff)
downloadrtems-1bdff036acddbbc63aa849741abba6581549f7b6.tar.bz2
IMFS: Reference counting for nodes
The introduction of reference counting of nodes avoids the removal of open nodes and potential usage of freed memory.
Diffstat (limited to 'cpukit/libfs/src/imfs/imfs_link.c')
-rw-r--r--cpukit/libfs/src/imfs/imfs_link.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_link.c b/cpukit/libfs/src/imfs/imfs_link.c
index 130c529d75..2684dbe64f 100644
--- a/cpukit/libfs/src/imfs/imfs_link.c
+++ b/cpukit/libfs/src/imfs/imfs_link.c
@@ -30,12 +30,15 @@ int IMFS_link(
{
IMFS_types_union info;
IMFS_jnode_t *new_node;
+ IMFS_jnode_t *target;
+
+ target = targetloc->node_access;
+ info.hard_link.link_node = target;
/*
* Verify this node can be linked to.
*/
- info.hard_link.link_node = targetloc->node_access;
- if ( info.hard_link.link_node->st_nlink >= LINK_MAX )
+ if ( target->st_nlink >= LINK_MAX )
rtems_set_errno_and_return_minus_one( EMLINK );
/*
@@ -56,8 +59,9 @@ int IMFS_link(
/*
* Increment the link count of the node being pointed to.
*/
- info.hard_link.link_node->st_nlink++;
- IMFS_update_ctime( info.hard_link.link_node );
+ target->reference_count++;
+ target->st_nlink++;
+ IMFS_update_ctime( target );
return 0;
}