Skip to content

[BUG] FF_Close() does not update xModifiedTime with current system time when file is modified (ffconfigTIME_SUPPORT=1) #81

@35001215

Description

@35001215

Target

  • TI MCU platform (e.g., AM64x/AM243x series)
  • ffconfigTIME_SUPPORT = 1
  • FF_GetSystemTime() implemented and verified to return correct system time

Summary

When appending or modifying a file, FF_Close() does not update xOriginalEntry.xModifiedTime (or xDirEntry.xModifiedTime) with the current system time, even though ffconfigTIME_SUPPORT = 1 and
FF_GetSystemTime() is correctly implemented.

As a result, the FAT directory entry's “last modified timestamp” does not change on file close unless the modified time was manually updated earlier in the write path.

This behavior seems unintended, because FF_PutEntry() simply writes the existing xModifiedTime value into the directory entry without refreshing it.

Reproduction steps

  1. Open a file in append or write mode:
    FF_FILE *fp = ff_fopen("/file.txt", "a");
    

Proposed Fix

The root cause is that neither FF_Close() nor FF_PutEntry() updates xOriginalEntry.xModifiedTime (or pxDirEntry->xModifiedTime) to the current system time before storing the directory entry.

To ensure correct FAT "last modified timestamp" behavior, the modified time must be refreshed immediately before the directory entry is written back.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions