summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libc/link.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-10-12 18:44:40 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-10-12 18:44:40 +0000
commitd71fcabaa6bc42e82d83060da49abff2b41ee272 (patch)
tree0fe667b13aa15cbab7baaed510a894fa1cb9dd78 /c/src/lib/libc/link.c
parentChanged bcopy to strncpy to stick to ANSI/ISO routines. (diff)
downloadrtems-d71fcabaa6bc42e82d83060da49abff2b41ee272.tar.bz2
Added call to freenod to let each filesystem free its own internal
node used to manage file access.
Diffstat (limited to 'c/src/lib/libc/link.c')
-rw-r--r--c/src/lib/libc/link.c37
1 files changed, 32 insertions, 5 deletions
diff --git a/c/src/lib/libc/link.c b/c/src/lib/libc/link.c
index c6a9f606e0..38ce78d87a 100644
--- a/c/src/lib/libc/link.c
+++ b/c/src/lib/libc/link.c
@@ -32,6 +32,7 @@ int link(
/*
* Get the node we are linking to.
*/
+
result = rtems_filesystem_evaluate_path( existing, 0, &existing_loc, TRUE );
if ( result != 0 )
return -1;
@@ -42,21 +43,47 @@ int link(
rtems_filesystem_get_start_loc( new, &i, &parent_loc );
result = (*parent_loc.ops->evalformake)( &new[i], &parent_loc, &name_start );
- if ( result != 0 )
- set_errno_and_return_minus_one( result );
+ if ( result != 0 ) {
+ if ( existing_loc.ops->freenod )
+ (*existing_loc.ops->freenod)( &parent_loc );
+ set_errno_and_return_minus_one( result );
+ }
/*
* Check to see if the caller is trying to link across file system
* boundaries.
*/
- if ( parent_loc.mt_entry != existing_loc.mt_entry )
+ if ( parent_loc.mt_entry != existing_loc.mt_entry ) {
+ if ( existing_loc.ops->freenod )
+ (*existing_loc.ops->freenod)( &existing_loc );
+
+ if ( parent_loc.ops->freenod )
+ (*parent_loc.ops->freenod)( &parent_loc );
+
set_errno_and_return_minus_one( EXDEV );
+ }
+
+ if ( !parent_loc.ops->link ) {
+
+ if ( existing_loc.ops->freenod )
+ (*existing_loc.ops->freenod)( &existing_loc );
+
+ if ( parent_loc.ops->freenod )
+ (*parent_loc.ops->freenod)( &parent_loc );
- if ( !parent_loc.ops->link )
set_errno_and_return_minus_one( ENOTSUP );
+ }
+
+ result = (*parent_loc.ops->link)( &existing_loc, &parent_loc, name_start );
+
+ if ( existing_loc.ops->freenod )
+ (*existing_loc.ops->freenod)( &existing_loc );
+
+ if ( parent_loc.ops->freenod )
+ (*parent_loc.ops->freenod)( &parent_loc );
- return (*parent_loc.ops->link)( &existing_loc, &parent_loc, name_start );
+ return result;
}
/*