From d71fcabaa6bc42e82d83060da49abff2b41ee272 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Tue, 12 Oct 1999 18:44:40 +0000 Subject: Added call to freenod to let each filesystem free its own internal node used to manage file access. --- cpukit/libcsupport/src/link.c | 37 ++++++++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 5 deletions(-) (limited to 'cpukit/libcsupport/src/link.c') diff --git a/cpukit/libcsupport/src/link.c b/cpukit/libcsupport/src/link.c index c6a9f606e0..38ce78d87a 100644 --- a/cpukit/libcsupport/src/link.c +++ b/cpukit/libcsupport/src/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; } /* -- cgit v1.2.3