diff options
Diffstat (limited to 'cpukit/libfs/src/dosfs/fat_file.c')
-rw-r--r-- | 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 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 */ |