Commit Graph
45 Commits
Author SHA1 Message Date
Martin Vychodil 422c4f5925 Merge branch 'feat/fatfs_posix_rename' into 'master'
feat(fatfs): add option to make rename() replace the destination

Closes IDF-16139

See merge request espressif/esp-idf!52382
2026-09-21 20:17:02 +08:00
Tomáš RohlínekandCursor a9b052a4af feat(fatfs): gate the rename self-nesting guard behind its own option
The check that rejects moving a directory into its own subtree was tied to
CONFIG_FATFS_VFS_RENAME_REPLACES_DESTINATION, so a build that only wanted
POSIX replacement semantics got the guard as a side effect, and the default
build kept the exposure the guard exists for: f_rename() does not detect the
case and links the directory into its own tree, after which the directory is
reachable only from inside itself and the volume is corrupt. The two
behaviours are unrelated, so give the guard its own option,
CONFIG_FATFS_VFS_RENAME_REJECTS_SELF_NESTING (default n), and let either be
enabled without the other.

Resolve the destination by start cluster rather than comparing path bytes.
FatFs matches names through directory entries, so a destination spelled as an
8.3 alias, or differing only in the case of a non-ASCII character, denotes the
same directory as the source and slipped past the previous string prefix
check, which folded ASCII case only. Long file names are enabled by default,
so the aliases exist in the default configuration. The walk runs only when the
source is a directory, leaving a file rename one directory open that fails
immediately.

Fold the two conditional variants of vfs_fat_rename() into a single
implementation. The variant guarded by the replace option had lost the stat
cache invalidation the unguarded one performs, so a readdir-cached entry could
answer a later stat() for a path that had just been renamed; the invalidation
now applies to every configuration.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-16 10:41:51 +02:00
Tomáš Rohlínek 4262553c56 feat(fatfs): add option to make rename() replace the destination
POSIX rename() silently replaces the destination when it already exists,
while FatFs' f_rename() refuses with FR_EXIST. rename() on a FAT mount
therefore fails with EEXIST where the same call succeeds on other file
systems, and every caller that wants portable behaviour has to remove the
destination itself.

Add CONFIG_FATFS_VFS_RENAME_REPLACES_DESTINATION (default n, so existing
behaviour is unchanged) to emulate the POSIX semantics: when f_rename()
reports FR_EXIST, remove the destination and retry, all under the lock
already held for the rename so no other VFS caller observes the gap.

The POSIX rules on what may replace what are applied before anything is
removed, because f_unlink() deletes empty directories as readily as
files and would otherwise discard a directory to make way for a file:
renaming a file onto a directory fails with EISDIR, a directory onto a
file with ENOTDIR, and a directory onto a non-empty directory with
ENOTEMPTY. Without the option all of these keep failing with EEXIST.

Moving a directory into its own subtree is rejected with EINVAL as well.
f_rename() does not check for this and links the directory into its own
tree, losing its contents, so this is a correctness fix rather than a
matter of which error is reported.

Renaming an entry to itself needs no special handling: f_rename() reports
FR_EXIST only when the destination resolves to a different directory
entry, so a self-rename, including one written with a different spelling
of the same name, already succeeds.

The emulation cannot be atomic, nor can it honour the POSIX guarantee
that a failed rename leaves an instance of the destination in place: FAT
cannot replace a directory entry in one step, so an interruption between
removing the destination and completing the rename can leave neither
name. This is documented in the option's help text.
2026-09-15 01:59:25 +08:00
sonika.rathi 74a7a4b105 fix(fatfs): restore FF_USE_EXPAND for contiguous file API
Closes https://github.com/espressif/esp-idf/issues/19067
2026-09-14 10:50:10 +02:00
Marius Vikhammer 532b433246 fix(build_system): cleaned up esp_psram dependencies
Also moved mspi_mb functionality to esp_hw_support together with
other mspi functionality
2026-08-24 11:12:17 +08:00
Martin VychodilandCursor ac76f19285 fix(fatfs): preserve access mode in VFS F_SETFL
F_SETFL was replacing the whole flags word, so fcntl(fd, F_SETFL, O_APPEND)
made F_GETFL report O_RDONLY|O_APPEND. Keep O_ACCMODE and apply only POSIX
status flags.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-19 11:41:24 +02:00
sonika.rathi d95ca349ca fix(fatfs): move readdir-stat cache to per-DIR stream
Move cached_fileinfo and dir_path from vfs_fat_ctx_t to vfs_fat_dir_t so
each open DIR* has its own readdir→stat cache.
2026-07-09 12:52:09 +02:00
sonika.rathi 28c8a2ec0e fix(fatfs): re-enable fatfs and vfs psram/ccomp CI tests 2026-06-24 14:45:16 +02:00
sonika.rathi d3a8009684 fix(storage): mark storage pytest apps flaky in CI 2026-05-21 20:35:24 +08:00
Evgeny Torbin d0f062c018 ci: remove unused test cases 2026-03-12 12:02:10 +01:00
C.S.M f405e51784 ci(esp32s31): Add ci build test for esp32s31 2025-12-11 15:17:15 +08:00
Marek Fiala 9d35d63651 feat(cmake): Update minimum cmake version to 3.22 (whole repository) 2025-08-19 14:44:32 +02:00
Tomáš Rohlínek b1997ebab6 feat(storage/fatfs): add dynamic buffer usage test 2025-04-09 14:02:44 +02:00
Chen Jichang c34b4eb882 feat(esp32h4): enable ESP32H4 ci build 2025-03-28 14:41:28 +08:00
igor.udot daf2d31008 test: format all test scripts 2025-03-05 12:08:48 +08:00
gaoxu 5ef4f20778 feat(esp32h21): disable unsupported build test 2025-02-06 15:47:51 +08:00
sonika.rathi 459f2517a8 feat(fatfs): enable partition handling for sectors less than 128 2024-10-08 13:35:08 +02:00
wanlei 3cf069c7d8 feat(esp32c61): disable unsupported build test 2024-07-16 16:06:19 +08:00
Adam Múdry feed6b4afe ci: Increase CONFIG_FATFS_VFS_FSTAT_BLKSIZE size for auto_fsync case 2024-04-23 22:19:23 +02:00
Sonika Rathi 3d813afa01 Merge branch 'bugfix/fatfs_optimize_stat_func' into 'master'
fix(fatfs): Optimizes vfs_fat_stat function to get stat structure after readdir

See merge request espressif/esp-idf!28609
2024-04-23 17:24:03 +08:00
Sonika Rathi e17da6f9f9 fix(fatfs): Optimizes vfs_fat_stat function to get stat structure after readdir
Closes https://github.com/espressif/esp-idf/issues/10220
2024-04-22 09:07:15 +02:00
Tomáš Rohlínek ede737763c feat(storage/fatfs): update deprecated syntax for tests 2024-04-17 10:37:31 +02:00
Tomáš Rohlínek b5d78549a5 feat(storage/fatfs): add tests for dynamic buffers 2024-04-17 10:37:31 +02:00
Jiang Jiang Jian a75bacf781 Merge branch 'fix/wl_fatfs_format' into 'master'
fix(storage/fatfs): fix double mouting of spiflash

Closes IDF-9677

See merge request espressif/esp-idf!30162
2024-04-17 10:48:39 +08:00
Jakob Hasse bf2bbbde16 ci: Added missing generic tag to psram tests 2024-04-16 09:17:41 +02:00
Tomáš Rohlínek 615a9c6742 feat(storage/example): enable host test for flash wl fatfs 2024-04-12 10:26:25 +02:00
Tomáš Rohlínek 7c3b9bde0e feat(storage/fatfs): add testcase with erased spi partition 2024-04-12 10:26:25 +02:00
Kevin (Lao Kaiyao) 432864e917 Merge branch 'ci/enable_c5_mp_ci_jobs' into 'master'
ci(esp32c5mp): enable esp32c5 build on CI

See merge request espressif/esp-idf!29895
2024-04-08 12:16:16 +08:00
laokaiyao 65b1fd33d3 ci(esp32c5mp): disable the unsupported tests 2024-04-07 12:13:29 +08:00
Chen Yudong 7d13f8210f ci: fix pytest generic env markers 2024-04-03 18:10:43 +08:00
Adam Múdry b76123af06 Merge branch 'feature/fatfs_expand_files_api' into 'master'
feat(fatfs): Allow expanding files with seeking and truncating functions

Closes IDFGH-12035

See merge request espressif/esp-idf!28945
2024-03-04 20:56:44 +08:00
Adam Múdry 35e312c48e feat(fatfs): Allow expanding files with seeking and truncating functions
Closes https://github.com/espressif/esp-idf/issues/13100
2024-02-29 01:01:32 +01:00
Adam Múdry 8d3e79971e feat(fatfs): Add f_expand function as esp_vfs_fat_create_contiguous_file
Add esp_vfs_fat_test_contiguous_file to test it
2024-02-22 16:05:28 +01:00
sonika.rathi f7e4b9a132 fix(storage): cleanup storage examples/test_apps sdkconfigs 2024-02-12 10:57:46 +01:00
Adam Múdry 376ea7e4ed feat(fatfs): VFS FATFS add format functions with config argument 2024-01-29 15:09:50 +08:00
Tomáš Rohlínek 092f5aff29 feat(storage): Update build test rules for storage related components 2024-01-02 13:10:59 +01:00
Adam MúdryandTony Stuart 25714837cf fix(storage): FATFS WL function formatting wrong partition
Closes https://github.com/espressif/esp-idf/issues/12542

Co-authored-by: Tony Stuart <anthonyfstuart@gmail.com>
2023-11-23 13:54:00 +01:00
Tomáš Rohlínek 525776f748 feat(vfs/fatfs): Add option for automatic immediate fsync 2023-10-02 07:06:05 +02:00
Armando 7dbd3f6909 feat(ci): Enable p4 example, test_apps and unit tests CI build 2023-08-24 12:51:19 +08:00
Adam Múdry fa16ed3898 CI: sdcard tests fail fix 2023-05-10 16:48:03 +02:00
Sonika Rathi b31b68fc68 bugfix: fix for fatfs "open("xx",O_CREAT|O_WRONLY,0666)" call failure
fatfs 'open' with only O_CREAT flag fails to creat new file

Closes https://github.com/espressif/esp-idf/issues/1817
2023-04-18 09:57:44 +05:30
Armando 4150bfb403 fatfs: added an API to format FAT on spiflash 2023-02-16 12:19:35 +08:00
Cao Sen Miao 94120b82c2 esp32h2: add build test 2023-01-17 10:29:04 +08:00
Song Ruo Jing 2557e24a28 ci: Enable esp32c6 example, test_apps, and unit tests CI build stage 2022-11-01 11:23:21 +08:00
Ivan Grokhotkov ac830e04ac fatfs: migrate unit tests to component test app, re-enable test for C2 2022-10-04 17:39:38 +02:00