From 2b30225a644b02d33e99dfc1669196a0e9658e62 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 2 Oct 2002 17:42:39 +0000 Subject: 2002-10-02 Jennifer Averett * src/imfs/memfile.c: Fixed case where last close of unlinked file did not remove the resources associated with that file. Reported by Till Straumann on the mailing list. --- cpukit/libfs/src/imfs/memfile.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'cpukit/libfs/src') diff --git a/cpukit/libfs/src/imfs/memfile.c b/cpukit/libfs/src/imfs/memfile.c index 711e0c0383..bb6fdcac34 100644 --- a/cpukit/libfs/src/imfs/memfile.c +++ b/cpukit/libfs/src/imfs/memfile.c @@ -73,6 +73,8 @@ ssize_t IMFS_memfile_write( /* cannot be static as used in imfs_fchmod.c */ unsigned int length ); +int memfile_check_rmnod( IMFS_jnode_t *the_jnode ); + void *memfile_alloc_block(void); void memfile_free_block( @@ -122,6 +124,7 @@ int memfile_close( if (iop->flags & LIBIO_FLAGS_APPEND) iop->offset = the_jnode->info.file.size; + memfile_check_rmnod( the_jnode ); return 0; } @@ -1108,6 +1111,12 @@ int memfile_rmnod( the_jnode->st_nlink--; IMFS_update_ctime( the_jnode ); + return memfile_check_rmnod( the_jnode ); +} + + +int memfile_check_rmnod( IMFS_jnode_t *the_jnode ){ + /* * The file cannot be open and the link must be less than 1 to free. */ @@ -1118,7 +1127,7 @@ int memfile_rmnod( * Is the rtems_filesystem_current is this node? */ - if ( rtems_filesystem_current.node_access == pathloc->node_access ) + if ( rtems_filesystem_current.node_access == the_jnode ) rtems_filesystem_current.node_access = NULL; /* @@ -1131,7 +1140,6 @@ int memfile_rmnod( } return 0; - } -- cgit v1.2.3