summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
authorxools <[email protected]>2017-04-16 16:13:15 -0700
committerxools <[email protected]>2017-04-16 16:13:15 -0700
commit5b50c7e41b9b8299c9f7b42cf7281083173937f2 (patch)
tree205050c6155ee6344972e9bc86354c52d21b49db /components
parente979b8a8b948747797eb3f340d1a4d505518ac5d (diff)
fix fattime different from elmfat definition
Diffstat (limited to 'components')
-rw-r--r--components/dfs/filesystems/elmfat/dfs_elm.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/components/dfs/filesystems/elmfat/dfs_elm.c b/components/dfs/filesystems/elmfat/dfs_elm.c
index 4fa9f3c84b..a73125e810 100644
--- a/components/dfs/filesystems/elmfat/dfs_elm.c
+++ b/components/dfs/filesystems/elmfat/dfs_elm.c
@@ -897,9 +897,33 @@ DRESULT disk_ioctl(BYTE drv, BYTE ctrl, void *buff)
return RES_OK;
}
-rt_time_t get_fattime(void)
+DWORD get_fattime(void)
{
- return time(RT_NULL);
+ time_t now;
+ struct tm *p_tm;
+ struct tm tm_now;
+ DWORD fat_time;
+
+ /* get current time */
+ now = time(RT_NULL);
+
+ /* lock scheduler. */
+ rt_enter_critical();
+ /* converts calendar time time into local time. */
+ p_tm = localtime(&now);
+ /* copy the statically located variable */
+ memcpy(&tm_now, p_tm, sizeof(struct tm));
+ /* unlock scheduler. */
+ rt_exit_critical();
+
+ fat_time = (DWORD)(tm_now.tm_year - 80) << 25 |
+ (DWORD)(tm_now.tm_mon + 1) << 21 |
+ (DWORD)tm_now.tm_mday << 16 |
+ (DWORD)tm_now.tm_hour << 11 |
+ (DWORD)tm_now.tm_min << 5 |
+ (DWORD)tm_now.tm_sec / 2 ;
+
+ return fat_time;
}
#if _FS_REENTRANT