[rtems commit] dosfs: Always release the buffers
Sebastian Huber
sebh at rtems.org
Wed Jan 30 16:03:40 UTC 2013
Module: rtems
Branch: master
Commit: eefeefdd0ec31e90e7805b38c5d0fcafc0edd8f3
Changeset: http://git.rtems.org/rtems/commit/?id=eefeefdd0ec31e90e7805b38c5d0fcafc0edd8f3
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Wed Jan 30 10:31:40 2013 +0100
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.
---
cpukit/libfs/src/dosfs/fat_file.c | 45 +++++++++++++++++++------------------
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 3e2d609..7f05447 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
*/
More information about the vc
mailing list