vfs: load native addons from a mounted file system by pipobscure · Pull Request #65680 · nodejs/node · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doc/api/cli.md
6 changes: 6 additions & 0 deletions doc/api/vfs.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,12 @@ system, the callers are responsible for avoiding removal or
invalidation of modules in the virtual file system while they are
being loaded.

Native addons (`.node` files) stored in a mounted VFS can be `require()`d as
well. The operating system's dynamic loader cannot open a virtual path, so the
addon's bytes are read from the VFS and loaded from a private, self-cleaning
temporary image instead. Addons on the real file system are unaffected and
load directly.

## Use with Single Executable Applications

When running as a [Single Executable Application][] built with
Expand Down
13 changes: 13 additions & 0 deletions doc/node.1
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,17 @@ process.permission.has('fs.read', 'custom-require.js'); // true
process.permission.has('fs.read', 'custom-require-2.js'); // true
.Ed
.
.It Fl -allow-fs-vfs
When using the Permission Model, a virtual file system cannot be
mounted by default: \fBvfs.mount()\fR throws \fBERR_INVALID_STATE\fR unless the
user explicitly passes the \fB--allow-fs-vfs\fR flag when starting Node.js.
A mounted VFS serves paths that the file system permissions do not describe,
so mounting one is gated on its own flag rather than on \fB--allow-fs-read\fR or
\fB--allow-fs-write\fR.
.Bd -literal
$ node --experimental-vfs --permission --allow-fs-vfs app.js
.Ed
.
.It Fl -allow-fs-write
This flag configures file system write permissions using
the Permission Model.
Expand Down Expand Up @@ -1964,6 +1975,8 @@ one is included in the list below.
.It
\fB--allow-fs-read\fR
.It
\fB--allow-fs-vfs\fR
.It
\fB--allow-fs-write\fR
.It
\fB--allow-inspector\fR
Expand Down
22 changes: 22 additions & 0 deletions lib/internal/vfs/setup.js
Loading
Loading