@@ -695,6 +695,38 @@ myVfs.symlinkSync('/etc/passwd', '/passwd-link');
695695// myVfs.readFileSync('/passwd-link'); // Throws ENOENT
696696```
697697
698+ ### Symlinks in overlay mode
699+
700+ In overlay mode (` { overlay: true } ` ), VFS and real file system symlinks remain
701+ completely independent:
702+
703+ * ** VFS symlinks** can only target other VFS paths. A VFS symlink cannot point
704+ to a real file system file, even if that file exists at the same logical path.
705+ * ** Real file system symlinks** can only target other real file system paths.
706+ A real symlink cannot point to a VFS file.
707+ * ** No cross-layer resolution** occurs. When following a symlink, the resolution
708+ stays entirely within either the VFS layer or the real file system layer.
709+
710+ ``` cjs
711+ const vfs = require (' node:vfs' );
712+ const fs = require (' node:fs' );
713+
714+ const myVfs = vfs .create ({ overlay: true });
715+ myVfs .mkdirSync (' /data' );
716+ myVfs .writeFileSync (' /data/config.json' , ' {"source": "vfs"}' );
717+ myVfs .symlinkSync (' /data/config.json' , ' /data/link' );
718+ myVfs .mount (' /app' );
719+
720+ // VFS symlink resolves within VFS
721+ fs .readFileSync (' /app/data/link' , ' utf8' ); // '{"source": "vfs"}'
722+
723+ // If /app/data/real-link is a real FS symlink pointing to /app/data/config.json,
724+ // it will NOT resolve to the VFS file - it looks for a real file at that path
725+ ```
726+
727+ This design ensures predictable behavior: symlinks always resolve within their
728+ own layer, preventing unexpected interactions between virtual and real files.
729+
698730## Worker threads
699731
700732VFS instances are ** not shared across worker threads** . Each worker thread has
0 commit comments