Commit ee36353
authored
vfs: load native addons from a mounted file system
A native addon inside a virtual file system could not be require()d:
dlopen() and LoadLibrary() open a shared object by path, and a VFS path
has no inode for them to open.
Read the addon's bytes from the VFS and load them from a private,
self-cleaning image instead, using the smallest on-disk footprint each
platform allows: on Linux an anonymous memfd loaded through
/proc/self/fd, so the bytes never reach the file system; on other POSIX
platforms a file in a 0700 mkdtemp() directory, unlinked right after
loading, with the mapping keeping it alive; on Windows a temp file
opened FILE_FLAG_DELETE_ON_CLOSE whose handle is held until exit.
This is internal. process.dlopen() keeps its documented
(module, filename[, flags]) signature and ignores anything further; the
bytes are passed to a dlopenBinary() reachable only through the
process_methods binding, which the VFS hook calls for VFS paths. Addons
on the real file system are untouched and load directly.
Signed-off-by: Philipp Dunkel <pip@pipobscure.com>
PR-URL: #65680
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Paolo Insogna <paolo@cowtech.it>
Reviewed-By: James M Snell <jasnell@gmail.com>1 parent dd0f203 commit ee36353
12 files changed
Lines changed: 627 additions & 6 deletions
File tree
- doc
- api
- lib/internal/vfs
- src
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
271 | 291 | | |
272 | 292 | | |
273 | 293 | | |
| |||
4021 | 4041 | | |
4022 | 4042 | | |
4023 | 4043 | | |
| 4044 | + | |
4024 | 4045 | | |
4025 | 4046 | | |
4026 | 4047 | | |
| |||
4741 | 4762 | | |
4742 | 4763 | | |
4743 | 4764 | | |
| 4765 | + | |
4744 | 4766 | | |
4745 | 4767 | | |
4746 | 4768 | | |
| |||
4773 | 4795 | | |
4774 | 4796 | | |
4775 | 4797 | | |
| 4798 | + | |
4776 | 4799 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
419 | 419 | | |
420 | 420 | | |
421 | 421 | | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
422 | 428 | | |
423 | 429 | | |
424 | 430 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
166 | 166 | | |
167 | 167 | | |
168 | 168 | | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
169 | 180 | | |
170 | 181 | | |
171 | 182 | | |
| |||
2018 | 2029 | | |
2019 | 2030 | | |
2020 | 2031 | | |
| 2032 | + | |
| 2033 | + | |
2021 | 2034 | | |
2022 | 2035 | | |
2023 | 2036 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
917 | 937 | | |
918 | 938 | | |
919 | 939 | | |
| |||
922 | 942 | | |
923 | 943 | | |
924 | 944 | | |
| 945 | + | |
925 | 946 | | |
926 | 947 | | |
927 | 948 | | |
| |||
939 | 960 | | |
940 | 961 | | |
941 | 962 | | |
| 963 | + | |
942 | 964 | | |
943 | 965 | | |
944 | 966 | | |
| |||
0 commit comments