@ai-ecoverse/slicc-kernel 1.72.0 → 1.73.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -7
- package/dist/index.js +13 -3
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +142 -37
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +117 -78
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +137 -36
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +117 -78
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -2650,36 +2650,57 @@ function pathOpensLinks(Fs) {
|
|
|
2650
2650
|
if (!mayOpen || !isLink) return;
|
|
2651
2651
|
fs.mayOpen = (node, flags) => flags & O_PATH && isLink.call(fs, node.mode) ? 0 : mayOpen.call(fs, node, flags);
|
|
2652
2652
|
}
|
|
2653
|
+
function importKey(namespace, name2, glue) {
|
|
2654
|
+
const own = glue?.[name2];
|
|
2655
|
+
if (typeof own === "function") {
|
|
2656
|
+
const found = Object.keys(namespace).find((k) => namespace[k] === own);
|
|
2657
|
+
if (found !== void 0) return found;
|
|
2658
|
+
}
|
|
2659
|
+
const literal = LITERALS[name2];
|
|
2660
|
+
return typeof namespace[literal] === "function" ? literal : void 0;
|
|
2661
|
+
}
|
|
2662
|
+
function wrapImport(imports, name2, glue, wrap2) {
|
|
2663
|
+
let wrapped = false;
|
|
2664
|
+
for (const ns of namespaces(imports)) {
|
|
2665
|
+
const key = importKey(ns, name2, glue);
|
|
2666
|
+
if (key === void 0) continue;
|
|
2667
|
+
ns[key] = wrap2(ns[key]);
|
|
2668
|
+
wrapped = true;
|
|
2669
|
+
}
|
|
2670
|
+
if (!wrapped && typeof glue?.[name2] === "function") {
|
|
2671
|
+
throw new Error(`slicc-kernel cannot find the glue's ${LITERALS[name2]} among its imports`);
|
|
2672
|
+
}
|
|
2673
|
+
}
|
|
2653
2674
|
function kernelUmask(imports, deps) {
|
|
2654
2675
|
let umask = deps.initial & 511;
|
|
2655
|
-
|
|
2656
|
-
|
|
2657
|
-
const
|
|
2658
|
-
if (
|
|
2659
|
-
|
|
2660
|
-
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2676
|
+
const { glue } = deps;
|
|
2677
|
+
wrapImport(imports, "openat", glue, (openat) => (dirfd, path, flags, varargs) => {
|
|
2678
|
+
const memory = deps.memory();
|
|
2679
|
+
if (flags & O_CREAT2 && varargs && memory) new Int32Array(memory.buffer)[varargs >> 2] &= ~umask;
|
|
2680
|
+
return openat(dirfd, path, flags, varargs);
|
|
2681
|
+
});
|
|
2682
|
+
wrapImport(
|
|
2683
|
+
imports,
|
|
2684
|
+
"mkdirat",
|
|
2685
|
+
glue,
|
|
2686
|
+
(mkdirat) => (dirfd, path, mode) => mkdirat(dirfd, path, mode & ~umask)
|
|
2687
|
+
);
|
|
2688
|
+
wrapImport(
|
|
2689
|
+
imports,
|
|
2690
|
+
"mknodat",
|
|
2691
|
+
glue,
|
|
2692
|
+
(mknodat) => (dirfd, path, mode, dev) => mknodat(dirfd, path, mode & ~umask, dev)
|
|
2693
|
+
);
|
|
2694
|
+
wrapImport(imports, "umask", glue, (own) => {
|
|
2695
|
+
own(umask);
|
|
2696
|
+
return (mask) => {
|
|
2697
|
+
const old = umask;
|
|
2698
|
+
umask = mask & 511;
|
|
2673
2699
|
own(umask);
|
|
2674
|
-
|
|
2675
|
-
|
|
2676
|
-
|
|
2677
|
-
|
|
2678
|
-
deps.set(umask);
|
|
2679
|
-
return old;
|
|
2680
|
-
};
|
|
2681
|
-
}
|
|
2682
|
-
}
|
|
2700
|
+
deps.set(umask);
|
|
2701
|
+
return old;
|
|
2702
|
+
};
|
|
2703
|
+
});
|
|
2683
2704
|
}
|
|
2684
2705
|
function touching(times, memory) {
|
|
2685
2706
|
if (times === 0) return true;
|
|
@@ -2698,13 +2719,11 @@ function touch(Fs, on, run) {
|
|
|
2698
2719
|
}
|
|
2699
2720
|
}
|
|
2700
2721
|
function noFollowUtimes(imports, fs, glue, memory = () => void 0) {
|
|
2701
|
-
|
|
2702
|
-
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
if (key === void 0 || typeof utimensat !== "function") continue;
|
|
2707
|
-
namespace[key] = (dirfd, path, times, flags) => {
|
|
2722
|
+
wrapImport(
|
|
2723
|
+
imports,
|
|
2724
|
+
"utimensat",
|
|
2725
|
+
{ utimensat: glue },
|
|
2726
|
+
(utimensat) => (dirfd, path, times, flags) => {
|
|
2708
2727
|
const Fs = fs();
|
|
2709
2728
|
const on = touching(times, memory());
|
|
2710
2729
|
const { utime, lookupPath, ErrnoError } = Fs ?? {};
|
|
@@ -2721,8 +2740,8 @@ function noFollowUtimes(imports, fs, glue, memory = () => void 0) {
|
|
|
2721
2740
|
} finally {
|
|
2722
2741
|
Fs.utime = utime;
|
|
2723
2742
|
}
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2743
|
+
}
|
|
2744
|
+
);
|
|
2726
2745
|
}
|
|
2727
2746
|
function errnoOf(err) {
|
|
2728
2747
|
const { errno: errno2, code: code2 } = err ?? {};
|
|
@@ -3077,22 +3096,18 @@ function kernelChecks(Fs, memory, call2) {
|
|
|
3077
3096
|
bridge.access(liveNodePath(node), call2.amode, kind, (call2.flags & AT_SYMLINK_NOFOLLOW) !== 0);
|
|
3078
3097
|
return 0;
|
|
3079
3098
|
}
|
|
3080
|
-
function kernelAccess(imports, fs, memory) {
|
|
3081
|
-
|
|
3082
|
-
const
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
return -errnoOf(err);
|
|
3093
|
-
}
|
|
3094
|
-
};
|
|
3095
|
-
}
|
|
3099
|
+
function kernelAccess(imports, fs, memory, glue) {
|
|
3100
|
+
wrapImport(imports, "faccessat", glue, (own) => (dirfd, path, amode, flags) => {
|
|
3101
|
+
const rc = own(dirfd, path, amode, flags);
|
|
3102
|
+
const Fs = fs();
|
|
3103
|
+
const heap = memory();
|
|
3104
|
+
if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
|
|
3105
|
+
try {
|
|
3106
|
+
return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
|
|
3107
|
+
} catch (err) {
|
|
3108
|
+
return -errnoOf(err);
|
|
3109
|
+
}
|
|
3110
|
+
});
|
|
3096
3111
|
}
|
|
3097
3112
|
function linuxDevices(Fs) {
|
|
3098
3113
|
const { chmod } = Fs;
|
|
@@ -3104,7 +3119,7 @@ function linuxDevices(Fs) {
|
|
|
3104
3119
|
}
|
|
3105
3120
|
}
|
|
3106
3121
|
}
|
|
3107
|
-
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, DEVICE_MODES;
|
|
3122
|
+
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, DEVICE_MODES;
|
|
3108
3123
|
var init_process_fds = __esm({
|
|
3109
3124
|
"src/process/process-fds.ts"() {
|
|
3110
3125
|
"use strict";
|
|
@@ -3133,6 +3148,16 @@ var init_process_fds = __esm({
|
|
|
3133
3148
|
AT_SYMLINK_NOFOLLOW = 256;
|
|
3134
3149
|
EMSCRIPTEN_EPERM = 63;
|
|
3135
3150
|
O_PATH = 2097152;
|
|
3151
|
+
LITERALS = {
|
|
3152
|
+
openat: "__syscall_openat",
|
|
3153
|
+
mkdirat: "__syscall_mkdirat",
|
|
3154
|
+
mknodat: "__syscall_mknodat",
|
|
3155
|
+
umask: "__syscall_umask",
|
|
3156
|
+
faccessat: "__syscall_faccessat",
|
|
3157
|
+
utimensat: "__syscall_utimensat",
|
|
3158
|
+
getppid: "slicc_getppid_js",
|
|
3159
|
+
resizeHeap: "emscripten_resize_heap"
|
|
3160
|
+
};
|
|
3136
3161
|
UTIME_NOW = 1073741823;
|
|
3137
3162
|
UTIME_OMIT = 1073741822;
|
|
3138
3163
|
PROT_WRITE = 2;
|
|
@@ -4528,9 +4553,8 @@ function identify(transport, init) {
|
|
|
4528
4553
|
const id = r.ok && r.kind === "json" ? r.json : null;
|
|
4529
4554
|
return id ?? { pid: init.pid, ppid: init.ppid ?? 1 };
|
|
4530
4555
|
}
|
|
4531
|
-
function liveParent(imports, parent) {
|
|
4532
|
-
|
|
4533
|
-
if (env && typeof env.slicc_getppid_js === "function") env.slicc_getppid_js = parent;
|
|
4556
|
+
function liveParent(imports, parent, glue) {
|
|
4557
|
+
wrapImport(imports, "getppid", glue, () => parent);
|
|
4534
4558
|
}
|
|
4535
4559
|
function signalMasks(m) {
|
|
4536
4560
|
const mask = m.sliccSigMask;
|
|
@@ -4538,15 +4562,12 @@ function signalMasks(m) {
|
|
|
4538
4562
|
if (!mask || caught === -1) return null;
|
|
4539
4563
|
return { caught, ignored: mask(1), restart: mask(2) };
|
|
4540
4564
|
}
|
|
4541
|
-
function reportGrowth(imports, publish) {
|
|
4542
|
-
|
|
4543
|
-
const resize = env?.emscripten_resize_heap;
|
|
4544
|
-
if (!env || typeof resize !== "function") return;
|
|
4545
|
-
env.emscripten_resize_heap = (...args) => {
|
|
4565
|
+
function reportGrowth(imports, publish, glue) {
|
|
4566
|
+
wrapImport(imports, "resizeHeap", glue, (resize) => (...args) => {
|
|
4546
4567
|
const grown = resize(...args);
|
|
4547
4568
|
publish();
|
|
4548
4569
|
return grown;
|
|
4549
|
-
};
|
|
4570
|
+
});
|
|
4550
4571
|
}
|
|
4551
4572
|
function callerOwner(Fs, init) {
|
|
4552
4573
|
return init.owners ? {} : { owner: ownByCaller(Fs, init.cred, credAbi(init.program.glue)) };
|
|
@@ -4554,6 +4575,25 @@ function callerOwner(Fs, init) {
|
|
|
4554
4575
|
function utimensatOf(module) {
|
|
4555
4576
|
return ownValue(module, "sliccSyscalls")?.utimensat;
|
|
4556
4577
|
}
|
|
4578
|
+
function kernelWrappers(imports, module, deps) {
|
|
4579
|
+
const { init, transport, sys, memory } = deps;
|
|
4580
|
+
const kernelGlue = ownValue(module, "sliccKernelImports");
|
|
4581
|
+
liveParent(imports, deps.ppid, kernelGlue);
|
|
4582
|
+
kernelUmask(imports, {
|
|
4583
|
+
glue: kernelGlue,
|
|
4584
|
+
initial: init.umask ?? 18,
|
|
4585
|
+
memory,
|
|
4586
|
+
set: (mask) => void transport.call({ op: "proc-umask", mask }, Number.POSITIVE_INFINITY, "umask")
|
|
4587
|
+
});
|
|
4588
|
+
const fsOf = () => ownValue(module, "FS");
|
|
4589
|
+
noFollowUtimes(imports, fsOf, kernelGlue?.utimensat ?? utimensatOf(module), memory);
|
|
4590
|
+
kernelAccess(imports, fsOf, memory, kernelGlue);
|
|
4591
|
+
const glue = ownValue(module, "sliccFdImports");
|
|
4592
|
+
syncFsync(imports, fsOf, glue);
|
|
4593
|
+
positionalIo(imports, { glue, fs: fsOf, sys, memory });
|
|
4594
|
+
const grown = () => publishMemory(init.sab, memory()?.buffer.byteLength ?? 0);
|
|
4595
|
+
reportGrowth(imports, grown, kernelGlue);
|
|
4596
|
+
}
|
|
4557
4597
|
async function runWasmProcess(init, port2, deps = {}) {
|
|
4558
4598
|
const signals = new SignalGate(
|
|
4559
4599
|
createSyncSabTransport(init.sab, port2, {
|
|
@@ -4615,24 +4655,13 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
4615
4655
|
}
|
|
4616
4656
|
}
|
|
4617
4657
|
});
|
|
4618
|
-
|
|
4619
|
-
|
|
4620
|
-
|
|
4621
|
-
memory: () => memory,
|
|
4622
|
-
set: (mask) => void transport.call({ op: "proc-umask", mask }, Number.POSITIVE_INFINITY, "umask")
|
|
4623
|
-
});
|
|
4624
|
-
const fsOf = () => ownValue(module, "FS");
|
|
4625
|
-
noFollowUtimes(imports, fsOf, utimensatOf(module), () => memory);
|
|
4626
|
-
kernelAccess(imports, fsOf, () => memory);
|
|
4627
|
-
const glue = ownValue(module, "sliccFdImports");
|
|
4628
|
-
syncFsync(imports, () => ownValue(module, "FS"), glue);
|
|
4629
|
-
positionalIo(imports, {
|
|
4630
|
-
glue,
|
|
4631
|
-
fs: () => ownValue(module, "FS"),
|
|
4658
|
+
kernelWrappers(imports, module, {
|
|
4659
|
+
init,
|
|
4660
|
+
transport,
|
|
4632
4661
|
sys,
|
|
4633
|
-
memory: () => memory
|
|
4662
|
+
memory: () => memory,
|
|
4663
|
+
ppid: () => identify(transport, init).ppid
|
|
4634
4664
|
});
|
|
4635
|
-
reportGrowth(imports, () => publishMemory(init.sab, memory?.buffer.byteLength ?? 0));
|
|
4636
4665
|
return WebAssembly.instantiate(init.program.module, imports);
|
|
4637
4666
|
}).then((instance) => {
|
|
4638
4667
|
memory = wasmMemory(instance, imports);
|
|
@@ -4814,6 +4843,16 @@ var init_process_runtime = __esm({
|
|
|
4814
4843
|
" ioctl: typeof ___syscall_ioctl === 'function' ? ___syscall_ioctl : undefined,",
|
|
4815
4844
|
" setitimer: typeof __setitimer_js === 'function' ? __setitimer_js : undefined,",
|
|
4816
4845
|
"};",
|
|
4846
|
+
"Module.sliccKernelImports ??= {",
|
|
4847
|
+
" openat: typeof ___syscall_openat === 'function' ? ___syscall_openat : undefined,",
|
|
4848
|
+
" mkdirat: typeof ___syscall_mkdirat === 'function' ? ___syscall_mkdirat : undefined,",
|
|
4849
|
+
" mknodat: typeof ___syscall_mknodat === 'function' ? ___syscall_mknodat : undefined,",
|
|
4850
|
+
" umask: typeof ___syscall_umask === 'function' ? ___syscall_umask : undefined,",
|
|
4851
|
+
" faccessat: typeof ___syscall_faccessat === 'function' ? ___syscall_faccessat : undefined,",
|
|
4852
|
+
" utimensat: typeof ___syscall_utimensat === 'function' ? ___syscall_utimensat : undefined,",
|
|
4853
|
+
" getppid: typeof _slicc_getppid_js === 'function' ? _slicc_getppid_js : undefined,",
|
|
4854
|
+
" resizeHeap: typeof _emscripten_resize_heap === 'function' ? _emscripten_resize_heap : undefined,",
|
|
4855
|
+
"};",
|
|
4817
4856
|
"Module.sliccFdImports ??= {",
|
|
4818
4857
|
" fd_sync: typeof _fd_sync === 'function' ? _fd_sync : undefined,",
|
|
4819
4858
|
" fd_pread: typeof _fd_pread === 'function' ? _fd_pread : undefined,",
|