arnavsharma990 opened a new issue, #20037: URL: https://github.com/apache/nuttx/issues/20037
### Description Hi NuttX community, I'm looking into the TODO in `fs/fat/fs_fat32.c` regarding `rmdir()`/`unlink()` behavior when a file or directory is still open: > "Need to defer deleting cluster chain if the file is open." I've been investigating the current FAT implementation and prototyped a small fix using a `pending-delete` state on `struct fat_file_s` and the existing `fs_head` open-file list. However, I ran into an identity/lifetime question. Using `ff_startcluster` to determine whether an open handle belongs to the unlinked file does not seem safe because: - an empty file has `ff_startcluster == 0` and can acquire a cluster later when written; - cluster numbers can be reused; - `ff_dirsector` / `ff_dirindex` represent the directory entry location, but directory entries can be moved by rename and reused after unlink; - `fat_dup()` currently creates another `fat_file_s` rather than sharing a canonical underlying file object. So I'm wondering what the intended design is here. Would the preferred approach be to introduce some small FAT-local per-file identity/lifetime state (for example, a canonical `fat_file_s` with a reference count and pending-delete state), or is there an existing FAT/VFS mechanism that should be used for associating open handles with the underlying file across unlink/rename? I would appreciate any guidance on the intended approach before I open a PR. Thanks! ### Verification - [x] I have verified before submitting the report. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
