summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2013-01-30 10:31:40 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2013-01-30 17:08:04 +0100
commiteefeefdd0ec31e90e7805b38c5d0fcafc0edd8f3 (patch)
tree1b49f32e9ce57f7b7011c7a221b0dfd2a4089ee4 /cpukit/libfs
parentftpd: Check the root and current directory change (diff)
downloadrtems-eefeefdd0ec31e90e7805b38c5d0fcafc0edd8f3.tar.bz2
dosfs: Always release the buffers
Release the buffers also if this is not the last reference to the file object since otherwise we may hold modified data indefinitely.
Diffstat (limited to 'cpukit/libfs')
-rw-r--r--cpukit/libfs/src/dosfs/fat_file.c45
1 files changed, 23 insertions, 22 deletions
diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c
index 3e2d60967c..7f05447187 100644
--- a/cpukit/libfs/src/dosfs/fat_file.c
+++ b/cpukit/libfs/src/dosfs/fat_file.c
@@ -191,45 +191,46 @@ fat_file_close(
)
{
int rc = RC_OK;
- uint32_t key = 0;
/*
* if links_num field of fat-file descriptor is greater than 1
- * decrement the count of links and return
+ * decrement only the count of links
*/
if (fat_fd->links_num > 1)
{
fat_fd->links_num--;
- return rc;
}
-
- key = fat_construct_key(fs_info, &fat_fd->dir_pos.sname);
-
- if (fat_fd->flags & FAT_FILE_REMOVED)
+ else
{
- rc = fat_file_truncate(fs_info, fat_fd, 0);
- if ( rc != RC_OK )
- return rc;
+ uint32_t key = fat_construct_key(fs_info, &fat_fd->dir_pos.sname);
- _hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd);
+ if (fat_fd->flags & FAT_FILE_REMOVED)
+ {
+ rc = fat_file_truncate(fs_info, fat_fd, 0);
+ if (rc == RC_OK)
+ {
+ _hash_delete(fs_info->rhash, key, fat_fd->ino, fat_fd);
- if ( fat_ino_is_unique(fs_info, fat_fd->ino) )
- fat_free_unique_ino(fs_info, fat_fd->ino);
+ if (fat_ino_is_unique(fs_info, fat_fd->ino))
+ fat_free_unique_ino(fs_info, fat_fd->ino);
- free(fat_fd);
- }
- else
- {
- if (fat_ino_is_unique(fs_info, fat_fd->ino))
- {
- fat_fd->links_num = 0;
+ free(fat_fd);
+ }
}
else
{
- _hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
- free(fat_fd);
+ if (fat_ino_is_unique(fs_info, fat_fd->ino))
+ {
+ fat_fd->links_num = 0;
+ }
+ else
+ {
+ _hash_delete(fs_info->vhash, key, fat_fd->ino, fat_fd);
+ free(fat_fd);
+ }
}
}
+
/*
* flush any modified "cached" buffer back to disk
*/