summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2003-06-10 17:32:00 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2003-06-10 17:32:00 +0000
commit54411933a5af5b2f0c66c37dcdc77ca163c6997c (patch)
tree1051585fc9772c9b0c13939a727e00ffec1e4260 /cpukit/libfs
parent79ce8b2fd5235128c694536873984730721af1cd (diff)
downloadrtems-54411933a5af5b2f0c66c37dcdc77ca163c6997c.tar.bz2
2003-06-10 Phil Torre <ptorre@zetron.com>
PR 411/filesystem * src/imfs/imfs_unlink.c: Fix bug where renaming a memfile and then unlinking it causes a memory leak.
Diffstat (limited to '')
-rw-r--r--cpukit/libfs/ChangeLog6
-rw-r--r--cpukit/libfs/src/imfs/Makefile.am4
-rw-r--r--cpukit/libfs/src/imfs/imfs_unlink.c16
3 files changed, 19 insertions, 7 deletions
diff --git a/cpukit/libfs/ChangeLog b/cpukit/libfs/ChangeLog
index 97ca7eb8b0..0bebaf2447 100644
--- a/cpukit/libfs/ChangeLog
+++ b/cpukit/libfs/ChangeLog
@@ -1,3 +1,9 @@
+2003-06-10 Phil Torre <ptorre@zetron.com>
+
+ PR 411/filesystem
+ * src/imfs/imfs_unlink.c: Fix bug where renaming a memfile and
+ then unlinking it causes a memory leak.
+
2003-03-25 Thomas Doerfler <Thomas.Doerfler@imd-systems.de>
PR 367/filesystem
diff --git a/cpukit/libfs/src/imfs/Makefile.am b/cpukit/libfs/src/imfs/Makefile.am
index 64d026fdf8..0f7e631eaf 100644
--- a/cpukit/libfs/src/imfs/Makefile.am
+++ b/cpukit/libfs/src/imfs/Makefile.am
@@ -11,7 +11,9 @@ IMFS_C_FILES = imfs_chown.c imfs_config.c imfs_creat.c imfs_directory.c \
imfs_getchild.c memfile.c linearfile.c deviceio.c imfs_handlers_device.c \
imfs_handlers_directory.c imfs_handlers_link.c imfs_handlers_memfile.c \
imfs_debug.c imfs_rmnod.c imfs_symlink.c imfs_readlink.c imfs_fdatasync.c \
- imfs_fcntl.c ioman.c miniimfs_init.c imfs_load_tar.c
+ imfs_fcntl.c ioman.c miniimfs_init.c
+
+# imfs_load_tar.c
UNIX_C_FILES = imfs_unixstub.c
diff --git a/cpukit/libfs/src/imfs/imfs_unlink.c b/cpukit/libfs/src/imfs/imfs_unlink.c
index 9e0861b53a..af89045dc0 100644
--- a/cpukit/libfs/src/imfs/imfs_unlink.c
+++ b/cpukit/libfs/src/imfs/imfs_unlink.c
@@ -58,12 +58,16 @@ int IMFS_unlink(
* to remove the node that is a link and the node itself.
*/
- node->info.hard_link.link_node->st_nlink --;
- IMFS_update_ctime( node->info.hard_link.link_node );
- if ( node->info.hard_link.link_node->st_nlink < 1) {
- result = (*the_link.handlers->rmnod_h)( &the_link );
- if ( result != 0 )
- return -1;
+ if ( node->info.hard_link.link_node->st_nlink == 1)
+ {
+ result = (*the_link.handlers->rmnod_h)( &the_link );
+ if ( result != 0 )
+ return -1;
+ }
+ else
+ {
+ node->info.hard_link.link_node->st_nlink --;
+ IMFS_update_ctime( node->info.hard_link.link_node );
}
}