summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/fat_file.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-20 09:33:34 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-10-23 10:21:25 +0200
commita7eaaae85b9b536b4d77c86e39c138d7c4f8f8fc (patch)
treee345db37897c534dd4885276695f8a7492af1a4d /cpukit/libfs/src/dosfs/fat_file.c
parentbsp/stm32f4: Add header files (diff)
downloadrtems-a7eaaae85b9b536b4d77c86e39c138d7c4f8f8fc.tar.bz2
dosfs: Support ctime and mtime
Implement ctime and mtime updates according to POSIX. The ctime is mapped to the FAT create time and date. The mtime is mapped to the FAT last modified time and date. For the atime use the mtime for simplicity.
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);