fs writeFileAtomic: no-replace publish fails on exFAT/FAT32 (hard links unsupported) #3884
llrllr0123
started this conversation in
Ideas
Replies: 1 comment
|
Same hard-link publish, different volume: macOS smbfs (company share mounted as smbfs), stock New-session persist in This is the same class as exFAT No PR (CONTRIBUTING). Workaround: https://github.com/398894496-arch/TDHarness-coding mark macOS 把工作区/会话放在 smbfs 上时, |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
writeFileAtomic(packages/fs/fs-local/src/fsio.ts) publishes staged files with the no-replace primitivelink()whencreateIfAbsentsemantics are requested. On filesystems that do not support hard links — exFAT/FAT32 and some network mounts — this primitive is unsupported, so every no-replace write to such volumes fails, even when the target is absent.Reproduction
0.1.1-rc.2)createIfAbsentto that volume → guarded-create failure (FS_NOT_FOUND), even the first write to a fresh pathRoot cause
link(2)is only implemented on NTFS/APFS/ext-family. On Windows the underlyingCreateHardLinkfails and libuv maps the error toEISDIR(ERROR_DIRECTORY), which is misleading — neither operand is a directory. On Linux/macOS the equivalent failure surfaces asENOTSUP/EOPNOTSUPP/ENOSYS.writeFileAtomic.Proposed fix
Keep the guarded-create path where supported. When
link()fails with one ofEISDIR/EPERM/ENOTSUP/EOPNOTSUPP/ENOSYS/EXDEVand the publication target does not exist (lstat→ ENOENT/ENOTDIR), fall back torename()(check-then-publish). If the target exists, reportFS_NOT_OBSERVEDexactly as today.Trade-off (accepted on purpose): on exFAT the guarantee degrades from “atomic no-replace” to “check-then-publish”, which has a small TOCTOU window between the check and the rename — but then the rename itself is still atomic, and a concurrent creator can only lose in the narrow window. exFAT offers no better primitive:
open(O_EXCL)would create the target but leave it partially visible to readers, andcopyFile(COPYFILE_EXCL)is likewise non-atomic for readers.A working patch (~40 lines, single file) is available and has been running on my exFAT workspace. I can share the full diff or open a PR if external pull requests are accepted (per CONTRIBUTING.md they currently are not).
Questions for the team: is check-then-publish acceptable, or would you prefer a different primitive/approach for no-replace writes on exFAT-class volumes?
All reactions