summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src
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 /cpukit/libcsupport/src
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 'cpukit/libcsupport/src')
-rw-r--r--cpukit/libcsupport/src/chdir.c15
-rw-r--r--cpukit/libcsupport/src/chmod.c13
-rw-r--r--cpukit/libcsupport/src/chown.c17
-rw-r--r--cpukit/libcsupport/src/link.c37
-rw-r--r--cpukit/libcsupport/src/mknod.c11
-rw-r--r--cpukit/libcsupport/src/mount.c35
-rw-r--r--cpukit/libcsupport/src/open.c18
-rw-r--r--cpukit/libcsupport/src/readlink.c28
-rw-r--r--cpukit/libcsupport/src/rmdir.c22
-rw-r--r--cpukit/libcsupport/src/stat.c12
-rw-r--r--cpukit/libcsupport/src/symlink.c7
-rw-r--r--cpukit/libcsupport/src/unlink.c24
-rw-r--r--cpukit/libcsupport/src/unmount.c24
-rw-r--r--cpukit/libcsupport/src/utime.c12
14 files changed, 211 insertions, 64 deletions
diff --git a/cpukit/libcsupport/src/chdir.c b/cpukit/libcsupport/src/chdir.c
index 4acbc8cfe0..4b3c313f7b 100644
--- a/cpukit/libcsupport/src/chdir.c
+++ b/cpukit/libcsupport/src/chdir.c
@@ -38,12 +38,21 @@ int chdir(
* Verify you can change directory into this node.
*/
- if ( !loc.ops->node_type )
+ if ( !loc.ops->node_type ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY )
+ if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTDIR );
-
+ }
+
+ if ( rtems_filesystem_current.ops->freenod )
+ (*rtems_filesystem_current.ops->freenod)( &rtems_filesystem_current );
+
rtems_filesystem_current = loc;
return 0;
diff --git a/cpukit/libcsupport/src/chmod.c b/cpukit/libcsupport/src/chmod.c
index fa57d50691..acfc142ad0 100644
--- a/cpukit/libcsupport/src/chmod.c
+++ b/cpukit/libcsupport/src/chmod.c
@@ -28,13 +28,22 @@ int chmod(
{
int status;
rtems_filesystem_location_info_t loc;
+ int result;
status = rtems_filesystem_evaluate_path( path, 0, &loc, TRUE );
if ( status != 0 )
return -1;
- if ( !loc.handlers->fchmod )
+ if ( !loc.handlers->fchmod ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*loc.handlers->fchmod)( &loc, mode );
+ result = (*loc.handlers->fchmod)( &loc, mode );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
diff --git a/cpukit/libcsupport/src/chown.c b/cpukit/libcsupport/src/chown.c
index 189096dcd1..cc579b40a5 100644
--- a/cpukit/libcsupport/src/chown.c
+++ b/cpukit/libcsupport/src/chown.c
@@ -26,13 +26,22 @@ int chown(
gid_t group
)
{
- rtems_filesystem_location_info_t temp_loc;
+ rtems_filesystem_location_info_t loc;
+ int result;
- if ( rtems_filesystem_evaluate_path( path, 0x00, &temp_loc, TRUE ) )
+ if ( rtems_filesystem_evaluate_path( path, 0x00, &loc, TRUE ) )
return -1;
- if ( !temp_loc.ops->chown )
+ if ( !loc.ops->chown ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*temp_loc.ops->chown)( &temp_loc, owner, group );
+ result = (*loc.ops->chown)( &loc, owner, group );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
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;
}
/*
diff --git a/cpukit/libcsupport/src/mknod.c b/cpukit/libcsupport/src/mknod.c
index 97f6cb0884..48444f8549 100644
--- a/cpukit/libcsupport/src/mknod.c
+++ b/cpukit/libcsupport/src/mknod.c
@@ -52,8 +52,15 @@ int mknod(
if ( result != 0 )
return -1;
- if ( !temp_loc.ops->mknod )
+ if ( !temp_loc.ops->mknod ) {
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*temp_loc.ops->mknod)( name_start, mode, dev, &temp_loc );
+ result = (*temp_loc.ops->mknod)( name_start, mode, dev, &temp_loc );
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
+
+ return result;
}
diff --git a/cpukit/libcsupport/src/mount.c b/cpukit/libcsupport/src/mount.c
index ed15881494..7feca2e468 100644
--- a/cpukit/libcsupport/src/mount.c
+++ b/cpukit/libcsupport/src/mount.c
@@ -88,13 +88,12 @@ int init_fs_mount_table( void );
int mount(
rtems_filesystem_mount_table_entry_t **mt_entry,
rtems_filesystem_operations_table *fs_ops,
- rtems_filesystem_options_t fsoptions,
+ rtems_filesystem_options_t options,
char *device,
char *mount_point
)
{
- rtems_filesystem_location_info_t temp_loc;
- rtems_filesystem_options_t options;
+ rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry;
/* XXX add code to check for required operations */
@@ -112,8 +111,8 @@ int mount(
* Are the file system options valid?
*/
- if ( fsoptions != RTEMS_FILESYSTEM_READ_ONLY &&
- fsoptions != RTEMS_FILESYSTEM_READ_WRITE ) {
+ if ( options != RTEMS_FILESYSTEM_READ_ONLY &&
+ options != RTEMS_FILESYSTEM_READ_WRITE ) {
errno = EINVAL;
return -1;
}
@@ -145,7 +144,7 @@ int mount(
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
- &temp_loc ,
+ &loc,
TRUE ) == -1 )
goto cleanup_and_bail;
@@ -153,7 +152,7 @@ int mount(
* Test to see if it is a directory
*/
- if ( temp_loc.ops->node_type( &temp_loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
+ if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
errno = ENOTDIR;
goto cleanup_and_bail;
}
@@ -162,7 +161,7 @@ int mount(
* You can only mount one file system onto a single mount point.
*/
- if ( search_mt_for_mount_point( &temp_loc ) == FOUND ) {
+ if ( search_mt_for_mount_point( &loc ) == FOUND ) {
errno = EBUSY;
goto cleanup_and_bail;
}
@@ -172,22 +171,22 @@ int mount(
* into the allocated mount entry
*/
- temp_mt_entry->mt_point_node.node_access = temp_loc.node_access;
- temp_mt_entry->mt_point_node.handlers = temp_loc.handlers;
- temp_mt_entry->mt_point_node.ops = temp_loc.ops;
- temp_mt_entry->mt_point_node.mt_entry = temp_loc.mt_entry;
+ temp_mt_entry->mt_point_node.node_access = loc.node_access;
+ temp_mt_entry->mt_point_node.handlers = loc.handlers;
+ temp_mt_entry->mt_point_node.ops = loc.ops;
+ temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
/*
* This link to the parent is only done when we are dealing with system
* below the base file system
*/
- if ( !temp_loc.ops->mount ){
+ if ( !loc.ops->mount ){
errno = ENOTSUP;
goto cleanup_and_bail;
}
- if ( temp_loc.ops->mount( temp_mt_entry ) ) {
+ if ( loc.ops->mount( temp_mt_entry ) ) {
goto cleanup_and_bail;
}
}
@@ -224,11 +223,19 @@ int mount(
Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node );
*mt_entry = temp_mt_entry;
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
return 0;
cleanup_and_bail:
free( temp_mt_entry );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
return -1;
}
diff --git a/cpukit/libcsupport/src/open.c b/cpukit/libcsupport/src/open.c
index 7efa18e829..1bd6ea5ec6 100644
--- a/cpukit/libcsupport/src/open.c
+++ b/cpukit/libcsupport/src/open.c
@@ -62,7 +62,7 @@ int open(
int rc;
rtems_libio_t *iop = 0;
int status;
- rtems_filesystem_location_info_t temp_loc;
+ rtems_filesystem_location_info_t loc;
int eval_flags;
@@ -104,7 +104,7 @@ int open(
*/
status = rtems_filesystem_evaluate_path(
- pathname, eval_flags, &temp_loc, TRUE );
+ pathname, eval_flags, &loc, TRUE );
if ( status == -1 ) {
if ( errno != ENOENT ) {
@@ -126,7 +126,7 @@ int open(
}
/* Sanity check to see if the file name exists after the mknod() */
- status = rtems_filesystem_evaluate_path( pathname, 0x0, &temp_loc, TRUE );
+ status = rtems_filesystem_evaluate_path( pathname, 0x0, &loc, TRUE );
if ( status != 0 ) { /* The file did not exist */
rc = EACCES;
goto done;
@@ -139,15 +139,15 @@ int open(
}
/*
- * Fill in the file control block based on the temp_loc structure
+ * Fill in the file control block based on the loc structure
* returned by successful path evaluation.
*/
iop->offset = 0;
- iop->handlers = temp_loc.handlers;
- iop->file_info = temp_loc.node_access;
+ iop->handlers = loc.handlers;
+ iop->file_info = loc.node_access;
iop->flags |= rtems_libio_fcntl_flags( flags );
- iop->pathinfo = temp_loc;
+ iop->pathinfo = loc;
if ( !iop->handlers->open ) {
rc = ENOTSUP;
@@ -178,6 +178,10 @@ done:
rtems_libio_free( iop );
set_errno_and_return_minus_one( rc );
}
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
return iop - rtems_libio_iops;
}
diff --git a/cpukit/libcsupport/src/readlink.c b/cpukit/libcsupport/src/readlink.c
index 22de51e88f..2f7423f69e 100644
--- a/cpukit/libcsupport/src/readlink.c
+++ b/cpukit/libcsupport/src/readlink.c
@@ -23,21 +23,35 @@ int readlink(
rtems_filesystem_location_info_t loc;
int result;
+ if (!buf)
+ set_errno_and_return_minus_one( EFAULT );
+
result = rtems_filesystem_evaluate_path( pathname, 0, &loc, FALSE );
if ( result != 0 )
return -1;
- if (!buf)
- set_errno_and_return_minus_one( EFAULT );
-
- if ( !loc.ops->node_type )
+ if ( !loc.ops->node_type ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_SYM_LINK )
+ if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_SYM_LINK ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( EINVAL );
+ }
- if ( !loc.ops->readlink )
+ if ( !loc.ops->readlink ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*loc.ops->readlink)( &loc, buf, bufsize );
+ result = (*loc.ops->readlink)( &loc, buf, bufsize );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
diff --git a/cpukit/libcsupport/src/rmdir.c b/cpukit/libcsupport/src/rmdir.c
index 6c0331087f..9e951adb18 100644
--- a/cpukit/libcsupport/src/rmdir.c
+++ b/cpukit/libcsupport/src/rmdir.c
@@ -39,18 +39,32 @@ int rmdir(
* Verify you can remove this node as a directory.
*/
- if ( !loc.ops->node_type )
+ if ( !loc.ops->node_type ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY )
+ if ( (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTDIR );
+ }
/*
* Use the filesystems rmnod to remove the node.
*/
- if ( !loc.ops->rmnod )
+ if ( !loc.ops->rmnod ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*loc.ops->rmnod)( &loc );
+ result = (*loc.ops->rmnod)( &loc );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
diff --git a/cpukit/libcsupport/src/stat.c b/cpukit/libcsupport/src/stat.c
index db28d0eedc..ff1d0db618 100644
--- a/cpukit/libcsupport/src/stat.c
+++ b/cpukit/libcsupport/src/stat.c
@@ -58,8 +58,11 @@ int _STAT_NAME(
if ( status != 0 )
return -1;
- if ( !loc.handlers->fstat )
+ if ( !loc.handlers->fstat ){
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
/*
* Zero out the stat structure so the various support
@@ -68,7 +71,12 @@ int _STAT_NAME(
memset( buf, 0, sizeof(struct stat) );
- return (*loc.handlers->fstat)( &loc, buf );
+ status = (*loc.handlers->fstat)( &loc, buf );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return status;
}
#endif
diff --git a/cpukit/libcsupport/src/symlink.c b/cpukit/libcsupport/src/symlink.c
index ca9673f51b..b5c6013b07 100644
--- a/cpukit/libcsupport/src/symlink.c
+++ b/cpukit/libcsupport/src/symlink.c
@@ -29,6 +29,11 @@ int symlink(
if ( result != 0 )
return -1;
- return (*loc.ops->symlink)( &loc, actualpath, name_start);
+ result = (*loc.ops->symlink)( &loc, actualpath, name_start);
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
diff --git a/cpukit/libcsupport/src/unlink.c b/cpukit/libcsupport/src/unlink.c
index f3d6606bc9..b4374e53c9 100644
--- a/cpukit/libcsupport/src/unlink.c
+++ b/cpukit/libcsupport/src/unlink.c
@@ -31,16 +31,30 @@ int unlink(
if ( result != 0 )
return -1;
- if ( !loc.ops->node_type )
+ if ( !loc.ops->node_type ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- if ( (*loc.ops->node_type)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY )
+ if ( (*loc.ops->node_type)( &loc ) == RTEMS_FILESYSTEM_DIRECTORY ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( EISDIR );
-
- if ( !loc.ops->unlink )
+ }
+
+ if ( !loc.ops->unlink ) {
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
set_errno_and_return_minus_one( ENOTSUP );
+ }
- return (*loc.ops->unlink)( &loc );
+ result = (*loc.ops->unlink)( &loc );
+
+ if ( loc.ops->freenod )
+ (*loc.ops->freenod)( &loc );
+
+ return result;
}
/*
diff --git a/cpukit/libcsupport/src/unmount.c b/cpukit/libcsupport/src/unmount.c
index f50e63ff42..b32d9b0caa 100644
--- a/cpukit/libcsupport/src/unmount.c
+++ b/cpukit/libcsupport/src/unmount.c
@@ -83,8 +83,11 @@ int unmount(
* we are attempting to unmount ?
*/
- if ( rtems_filesystem_current.mt_entry == temp_loc.mt_entry )
+ if ( rtems_filesystem_current.mt_entry == temp_loc.mt_entry ) {
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
set_errno_and_return_minus_one( EBUSY );
+ }
/*
* Run the file descriptor table to determine if there are any file
@@ -92,8 +95,11 @@ int unmount(
* file system that we are trying to unmount
*/
- if ( rtems_libio_is_open_files_in_fs( temp_loc.mt_entry ) == 1 )
+ if ( rtems_libio_is_open_files_in_fs( temp_loc.mt_entry ) == 1 ) {
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
set_errno_and_return_minus_one( EBUSY );
+ }
/*
* Allow the file system being mounted on to do its cleanup.
@@ -103,15 +109,21 @@ int unmount(
* XXX I will step off in space when evaluating past the end of the node.
*/
- if ( ( temp_mt_entry.mt_point_node.ops->unmount )( temp_loc.mt_entry ) != 0 )
- return -1;
+ if ((temp_mt_entry.mt_point_node.ops->unmount )( temp_loc.mt_entry ) != 0 ) {
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
+ return -1;
+ }
/*
* Run the unmount function for the subordinate file system.
*/
- if ( ( temp_mt_entry.mt_fs_root.ops->fsunmount_me )( temp_loc.mt_entry ) != 0 )
+ if ((temp_mt_entry.mt_fs_root.ops->fsunmount_me )( temp_loc.mt_entry ) != 0){
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
return -1;
+ }
/*
* Allow the file system to clean up.
@@ -130,6 +142,8 @@ int unmount(
*/
free( temp_loc.mt_entry );
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
return result;
diff --git a/cpukit/libcsupport/src/utime.c b/cpukit/libcsupport/src/utime.c
index f1a12ee1b2..ccc92d044e 100644
--- a/cpukit/libcsupport/src/utime.c
+++ b/cpukit/libcsupport/src/utime.c
@@ -24,12 +24,18 @@ int utime(
)
{
rtems_filesystem_location_info_t temp_loc;
+ int result;
+
+ if ( !temp_loc.ops->utime )
+ set_errno_and_return_minus_one( ENOTSUP );
if ( rtems_filesystem_evaluate_path( path, 0x00, &temp_loc, TRUE ) )
return -1;
- if ( !temp_loc.ops->utime )
- set_errno_and_return_minus_one( ENOTSUP );
+ result = (*temp_loc.ops->utime)( &temp_loc, times->actime, times->modtime );
+
+ if ( temp_loc.ops->freenod )
+ (*temp_loc.ops->freenod)( &temp_loc );
- return (*temp_loc.ops->utime)( &temp_loc, times->actime, times->modtime );
+ return result;
}