Skip to content

Commit 74a3cbe

Browse files
committed
fix _ftello_r by wrapping it
1 parent 6937cdd commit 74a3cbe

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ target_include_directories(filesystem_vfs INTERFACE
108108
${CMAKE_CURRENT_LIST_DIR}/include
109109
)
110110
target_compile_options(filesystem_vfs INTERFACE -Werror -Wall -Wextra -Wnull-dereference)
111-
target_link_libraries(filesystem_vfs INTERFACE pico_sync)
111+
target_link_libraries(filesystem_vfs INTERFACE pico_sync -Wl,--wrap=_ftello_r)
112112

113113
# Default file system library
114114
add_library(filesystem_default INTERFACE)

src/filesystem/fat.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,29 @@ static int file_stat(filesystem_t *fs, const char *path, struct stat *st) {
415415
return 0;
416416
}
417417

418+
static int file_utimes(filesystem_t *fs, const char *path, const struct timeval times[2]) {
419+
filesystem_fat_context_t *context = fs->context;
420+
char fpath[PATH_MAX];
421+
fat_path_prefix(fpath, context->id, path);
422+
423+
struct tm *mtime = localtime(&times[0].tv_sec);
424+
425+
FILINFO f = {
426+
.fdate = (WORD)(((mtime->tm_year - 80) * 512U) | mtime->tm_mon * 32U | mtime->tm_mday),
427+
.ftime = (WORD)(mtime->tm_hour * 2048U | mtime->tm_min * 32U | mtime->tm_sec / 2U)
428+
};
429+
430+
mutex_enter_blocking(&context->_mutex);
431+
FRESULT res = f_utime(fpath, &f);
432+
mutex_exit(&context->_mutex);
433+
434+
if (res != FR_OK) {
435+
return fat_error_remap(res);
436+
}
437+
438+
return 0;
439+
}
440+
418441
static int file_open(filesystem_t *fs, fs_file_t *file, const char *path, int flags) {
419442
BYTE open_mode;
420443
if (flags & O_RDWR)

0 commit comments

Comments
 (0)