Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ target_include_directories(filesystem_vfs INTERFACE
${CMAKE_CURRENT_LIST_DIR}/include
)
target_compile_options(filesystem_vfs INTERFACE -Werror -Wall -Wextra -Wnull-dereference)
target_link_libraries(filesystem_vfs INTERFACE pico_sync)
target_link_libraries(filesystem_vfs INTERFACE pico_sync -Wl,--wrap=_ftello_r)

# Default file system library
add_library(filesystem_default INTERFACE)
Expand Down
3 changes: 1 addition & 2 deletions include/filesystem/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ extern "C" {
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
#include <limits.h>
#include "blockdevice/blockdevice.h"

#define PATH_MAX 256

enum {
FILESYSTEM_TYPE_FAT,
FILESYSTEM_TYPE_LITTLEFS,
Expand Down
10 changes: 10 additions & 0 deletions src/filesystem/fat.c
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,22 @@ static int file_stat(filesystem_t *fs, const char *path, struct stat *st) {
if (res != FR_OK) {
return fat_error_remap(res);
}

struct tm mtime = {0};
mtime.tm_year = (f.fdate >> 9) + 80;
mtime.tm_mon = ((f.fdate >> 5) & 0b1111) - 1;
mtime.tm_mday = f.fdate & 0b11111;
mtime.tm_hour = f.ftime >> 11;
mtime.tm_min = (f.ftime >> 5) & 0b111111;
mtime.tm_sec = (f.ftime & 0b11111) << 1;

st->st_size = f.fsize;
st->st_mode = 0;
st->st_mode |= (f.fattrib & AM_DIR) ? S_IFDIR : S_IFREG;
st->st_mode |= (f.fattrib & AM_RDO) ?
(S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH) :
(S_IRWXU | S_IRWXG | S_IRWXO);
st->st_mtime = mktime(&mtime);
return 0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/filesystem/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ off_t _lseek(int fildes, off_t offset, int whence) {
return _error_remap(pos);
}

off_t _ftello_r(struct _reent *ptr, register FILE *fp) {
off_t __wrap__ftello_r(struct _reent *ptr, register FILE *fp) {
(void)ptr;
int fildes = fp->_file;
auto_init_recursive_mutex(_mutex);
Expand Down