You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Motivation for the change, related issues
This PR introduces dynamic mounting of symlinked directories into
PHP-wasm.
Before this PR, users had to mount symlinked directories into PHP-wasm
for them to work. This behavior isn't expected by users as alternative
solutions like Apache or Nginx don't require mounting and symlinks will
"just" work.
In the Node version of PHP-wasm, users can mount directories from their
OS filesystem into PHP-wasm.
This is done using Emscripten's `mount` function, which adds the mounted
directory as a Node to Emscripten's filesystem.
If the directory in the OS filesystem has a symlink, Emscripten will
follow it within its filesystem, and if the path doesn't exist inside
Emscripten's filesystem, Emscripten will throw an error.
In practice, this means that if a user has a directory `/A` on their OS
that links to `/B`, Emscripten will only be able to follow `/A/B` if
`/B` is also mounted into Emscripten.
## Implementation details
To implement dynamic symlink mounting, this PR overrides
`FS.filesystems.NODEFS.node_ops.readlink` inside Emscripten, which is
used to obtain the string value stored in a symlink.
The modified `readlink` function mounts the link path into Emscripten if
the path doesn't exist in Emscripten's filesystem and if it exists in
the OS filesystem. Afterwards, it returns the absolute path to the
linked path.
Dynamic symlink mounting will be only enabled if
`emscriptenOptions.allowSymlinkMounting` is set to `true` in
`loadNodeRuntime` options.
## Testing Instructions (or ideally a Blueprint)
- CI
0 commit comments