summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/fat_file.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libfs/src/dosfs/fat_file.c')
-rw-r--r--cpukit/libfs/src/dosfs/fat_file.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/cpukit/libfs/src/dosfs/fat_file.c b/cpukit/libfs/src/dosfs/fat_file.c
index 2899f1b414..1f20926884 100644
--- a/cpukit/libfs/src/dosfs/fat_file.c
+++ b/cpukit/libfs/src/dosfs/fat_file.c
@@ -165,6 +165,38 @@ fat_file_reopen(fat_file_fd_t *fat_fd)
return RC_OK;
}
+int
+fat_file_update(fat_fs_info_t *fs_info, fat_file_fd_t *fat_fd)
+{
+ int ret_rc = RC_OK;
+
+ /*
+ * if fat-file descriptor is not marked as "removed", synchronize
+ * size, first cluster number, write time and date fields of the file
+ */
+ if (!FAT_FILE_IS_REMOVED(fat_fd))
+ {
+ int rc;
+
+ if (fat_fd->fat_file_type == FAT_FILE)
+ {
+ rc = fat_file_write_first_cluster_num(fs_info, fat_fd);
+ if (rc != RC_OK)
+ ret_rc = rc;
+
+ rc = fat_file_write_file_size(fs_info, fat_fd);
+ if (rc != RC_OK)
+ ret_rc = rc;
+ }
+
+ rc = fat_file_write_time_and_date(fs_info, fat_fd);
+ if (rc != RC_OK)
+ ret_rc = rc;
+ }
+
+ return ret_rc;
+}
+
/* fat_file_close --
* Close fat-file. If count of links to fat-file
* descriptor is greater than 1 (i.e. somebody esle holds pointer
@@ -204,6 +236,8 @@ fat_file_close(
{
uint32_t key = fat_construct_key(fs_info, &fat_fd->dir_pos.sname);
+ fat_file_update(fs_info, fat_fd);
+
if (fat_fd->flags & FAT_FILE_REMOVED)
{
rc = fat_file_truncate(fs_info, fat_fd, 0);