@ai-ecoverse/slicc-kernel 1.73.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 +5 -4
- package/dist/kernel-worker.js +63 -21
- 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 +63 -21
- 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
|
@@ -8046,36 +8046,57 @@ function pathOpensLinks(Fs) {
|
|
|
8046
8046
|
if (!mayOpen || !isLink) return;
|
|
8047
8047
|
fs.mayOpen = (node, flags) => flags & O_PATH && isLink.call(fs, node.mode) ? 0 : mayOpen.call(fs, node, flags);
|
|
8048
8048
|
}
|
|
8049
|
+
function importKey(namespace, name2, glue) {
|
|
8050
|
+
const own = glue?.[name2];
|
|
8051
|
+
if (typeof own === "function") {
|
|
8052
|
+
const found = Object.keys(namespace).find((k) => namespace[k] === own);
|
|
8053
|
+
if (found !== void 0) return found;
|
|
8054
|
+
}
|
|
8055
|
+
const literal = LITERALS[name2];
|
|
8056
|
+
return typeof namespace[literal] === "function" ? literal : void 0;
|
|
8057
|
+
}
|
|
8058
|
+
function wrapImport(imports, name2, glue, wrap2) {
|
|
8059
|
+
let wrapped = false;
|
|
8060
|
+
for (const ns of namespaces(imports)) {
|
|
8061
|
+
const key = importKey(ns, name2, glue);
|
|
8062
|
+
if (key === void 0) continue;
|
|
8063
|
+
ns[key] = wrap2(ns[key]);
|
|
8064
|
+
wrapped = true;
|
|
8065
|
+
}
|
|
8066
|
+
if (!wrapped && typeof glue?.[name2] === "function") {
|
|
8067
|
+
throw new Error(`slicc-kernel cannot find the glue's ${LITERALS[name2]} among its imports`);
|
|
8068
|
+
}
|
|
8069
|
+
}
|
|
8049
8070
|
function kernelUmask(imports, deps) {
|
|
8050
8071
|
let umask = deps.initial & 511;
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
const
|
|
8054
|
-
if (
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8068
|
-
|
|
8072
|
+
const { glue } = deps;
|
|
8073
|
+
wrapImport(imports, "openat", glue, (openat) => (dirfd, path, flags, varargs) => {
|
|
8074
|
+
const memory = deps.memory();
|
|
8075
|
+
if (flags & O_CREAT2 && varargs && memory) new Int32Array(memory.buffer)[varargs >> 2] &= ~umask;
|
|
8076
|
+
return openat(dirfd, path, flags, varargs);
|
|
8077
|
+
});
|
|
8078
|
+
wrapImport(
|
|
8079
|
+
imports,
|
|
8080
|
+
"mkdirat",
|
|
8081
|
+
glue,
|
|
8082
|
+
(mkdirat) => (dirfd, path, mode) => mkdirat(dirfd, path, mode & ~umask)
|
|
8083
|
+
);
|
|
8084
|
+
wrapImport(
|
|
8085
|
+
imports,
|
|
8086
|
+
"mknodat",
|
|
8087
|
+
glue,
|
|
8088
|
+
(mknodat) => (dirfd, path, mode, dev) => mknodat(dirfd, path, mode & ~umask, dev)
|
|
8089
|
+
);
|
|
8090
|
+
wrapImport(imports, "umask", glue, (own) => {
|
|
8091
|
+
own(umask);
|
|
8092
|
+
return (mask) => {
|
|
8093
|
+
const old = umask;
|
|
8094
|
+
umask = mask & 511;
|
|
8069
8095
|
own(umask);
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
deps.set(umask);
|
|
8075
|
-
return old;
|
|
8076
|
-
};
|
|
8077
|
-
}
|
|
8078
|
-
}
|
|
8096
|
+
deps.set(umask);
|
|
8097
|
+
return old;
|
|
8098
|
+
};
|
|
8099
|
+
});
|
|
8079
8100
|
}
|
|
8080
8101
|
function touching(times, memory) {
|
|
8081
8102
|
if (times === 0) return true;
|
|
@@ -8094,13 +8115,11 @@ function touch(Fs, on, run) {
|
|
|
8094
8115
|
}
|
|
8095
8116
|
}
|
|
8096
8117
|
function noFollowUtimes(imports, fs, glue, memory = () => void 0) {
|
|
8097
|
-
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8101
|
-
|
|
8102
|
-
if (key === void 0 || typeof utimensat !== "function") continue;
|
|
8103
|
-
namespace[key] = (dirfd, path, times, flags) => {
|
|
8118
|
+
wrapImport(
|
|
8119
|
+
imports,
|
|
8120
|
+
"utimensat",
|
|
8121
|
+
{ utimensat: glue },
|
|
8122
|
+
(utimensat) => (dirfd, path, times, flags) => {
|
|
8104
8123
|
const Fs = fs();
|
|
8105
8124
|
const on = touching(times, memory());
|
|
8106
8125
|
const { utime, lookupPath, ErrnoError } = Fs ?? {};
|
|
@@ -8117,8 +8136,8 @@ function noFollowUtimes(imports, fs, glue, memory = () => void 0) {
|
|
|
8117
8136
|
} finally {
|
|
8118
8137
|
Fs.utime = utime;
|
|
8119
8138
|
}
|
|
8120
|
-
}
|
|
8121
|
-
|
|
8139
|
+
}
|
|
8140
|
+
);
|
|
8122
8141
|
}
|
|
8123
8142
|
function errnoOf(err) {
|
|
8124
8143
|
const { errno: errno2, code: code2 } = err ?? {};
|
|
@@ -8470,22 +8489,18 @@ function kernelChecks(Fs, memory, call2) {
|
|
|
8470
8489
|
bridge.access(liveNodePath(node), call2.amode, kind, (call2.flags & AT_SYMLINK_NOFOLLOW2) !== 0);
|
|
8471
8490
|
return 0;
|
|
8472
8491
|
}
|
|
8473
|
-
function kernelAccess(imports, fs, memory) {
|
|
8474
|
-
|
|
8475
|
-
const
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
return -errnoOf(err);
|
|
8486
|
-
}
|
|
8487
|
-
};
|
|
8488
|
-
}
|
|
8492
|
+
function kernelAccess(imports, fs, memory, glue) {
|
|
8493
|
+
wrapImport(imports, "faccessat", glue, (own) => (dirfd, path, amode, flags) => {
|
|
8494
|
+
const rc = own(dirfd, path, amode, flags);
|
|
8495
|
+
const Fs = fs();
|
|
8496
|
+
const heap = memory();
|
|
8497
|
+
if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
|
|
8498
|
+
try {
|
|
8499
|
+
return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
|
|
8500
|
+
} catch (err) {
|
|
8501
|
+
return -errnoOf(err);
|
|
8502
|
+
}
|
|
8503
|
+
});
|
|
8489
8504
|
}
|
|
8490
8505
|
function linuxDevices(Fs) {
|
|
8491
8506
|
const { chmod } = Fs;
|
|
@@ -8497,7 +8512,7 @@ function linuxDevices(Fs) {
|
|
|
8497
8512
|
}
|
|
8498
8513
|
}
|
|
8499
8514
|
}
|
|
8500
|
-
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, DEVICE_MODES;
|
|
8515
|
+
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, DEVICE_MODES;
|
|
8501
8516
|
var init_process_fds = __esm({
|
|
8502
8517
|
"src/process/process-fds.ts"() {
|
|
8503
8518
|
"use strict";
|
|
@@ -8526,6 +8541,16 @@ var init_process_fds = __esm({
|
|
|
8526
8541
|
AT_SYMLINK_NOFOLLOW2 = 256;
|
|
8527
8542
|
EMSCRIPTEN_EPERM = 63;
|
|
8528
8543
|
O_PATH = 2097152;
|
|
8544
|
+
LITERALS = {
|
|
8545
|
+
openat: "__syscall_openat",
|
|
8546
|
+
mkdirat: "__syscall_mkdirat",
|
|
8547
|
+
mknodat: "__syscall_mknodat",
|
|
8548
|
+
umask: "__syscall_umask",
|
|
8549
|
+
faccessat: "__syscall_faccessat",
|
|
8550
|
+
utimensat: "__syscall_utimensat",
|
|
8551
|
+
getppid: "slicc_getppid_js",
|
|
8552
|
+
resizeHeap: "emscripten_resize_heap"
|
|
8553
|
+
};
|
|
8529
8554
|
UTIME_NOW = 1073741823;
|
|
8530
8555
|
UTIME_OMIT = 1073741822;
|
|
8531
8556
|
PROT_WRITE = 2;
|
|
@@ -9902,9 +9927,8 @@ function identify(transport, init) {
|
|
|
9902
9927
|
const id = r.ok && r.kind === "json" ? r.json : null;
|
|
9903
9928
|
return id ?? { pid: init.pid, ppid: init.ppid ?? 1 };
|
|
9904
9929
|
}
|
|
9905
|
-
function liveParent(imports, parent) {
|
|
9906
|
-
|
|
9907
|
-
if (env && typeof env.slicc_getppid_js === "function") env.slicc_getppid_js = parent;
|
|
9930
|
+
function liveParent(imports, parent, glue) {
|
|
9931
|
+
wrapImport(imports, "getppid", glue, () => parent);
|
|
9908
9932
|
}
|
|
9909
9933
|
function signalMasks(m) {
|
|
9910
9934
|
const mask = m.sliccSigMask;
|
|
@@ -9912,15 +9936,12 @@ function signalMasks(m) {
|
|
|
9912
9936
|
if (!mask || caught === -1) return null;
|
|
9913
9937
|
return { caught, ignored: mask(1), restart: mask(2) };
|
|
9914
9938
|
}
|
|
9915
|
-
function reportGrowth(imports, publish) {
|
|
9916
|
-
|
|
9917
|
-
const resize = env?.emscripten_resize_heap;
|
|
9918
|
-
if (!env || typeof resize !== "function") return;
|
|
9919
|
-
env.emscripten_resize_heap = (...args) => {
|
|
9939
|
+
function reportGrowth(imports, publish, glue) {
|
|
9940
|
+
wrapImport(imports, "resizeHeap", glue, (resize) => (...args) => {
|
|
9920
9941
|
const grown = resize(...args);
|
|
9921
9942
|
publish();
|
|
9922
9943
|
return grown;
|
|
9923
|
-
};
|
|
9944
|
+
});
|
|
9924
9945
|
}
|
|
9925
9946
|
function callerOwner(Fs, init) {
|
|
9926
9947
|
return init.owners ? {} : { owner: ownByCaller(Fs, init.cred, credAbi(init.program.glue)) };
|
|
@@ -9928,6 +9949,25 @@ function callerOwner(Fs, init) {
|
|
|
9928
9949
|
function utimensatOf(module) {
|
|
9929
9950
|
return ownValue(module, "sliccSyscalls")?.utimensat;
|
|
9930
9951
|
}
|
|
9952
|
+
function kernelWrappers(imports, module, deps) {
|
|
9953
|
+
const { init, transport, sys, memory } = deps;
|
|
9954
|
+
const kernelGlue = ownValue(module, "sliccKernelImports");
|
|
9955
|
+
liveParent(imports, deps.ppid, kernelGlue);
|
|
9956
|
+
kernelUmask(imports, {
|
|
9957
|
+
glue: kernelGlue,
|
|
9958
|
+
initial: init.umask ?? 18,
|
|
9959
|
+
memory,
|
|
9960
|
+
set: (mask) => void transport.call({ op: "proc-umask", mask }, Number.POSITIVE_INFINITY, "umask")
|
|
9961
|
+
});
|
|
9962
|
+
const fsOf = () => ownValue(module, "FS");
|
|
9963
|
+
noFollowUtimes(imports, fsOf, kernelGlue?.utimensat ?? utimensatOf(module), memory);
|
|
9964
|
+
kernelAccess(imports, fsOf, memory, kernelGlue);
|
|
9965
|
+
const glue = ownValue(module, "sliccFdImports");
|
|
9966
|
+
syncFsync(imports, fsOf, glue);
|
|
9967
|
+
positionalIo(imports, { glue, fs: fsOf, sys, memory });
|
|
9968
|
+
const grown = () => publishMemory(init.sab, memory()?.buffer.byteLength ?? 0);
|
|
9969
|
+
reportGrowth(imports, grown, kernelGlue);
|
|
9970
|
+
}
|
|
9931
9971
|
async function runWasmProcess(init, port3, deps = {}) {
|
|
9932
9972
|
const signals = new SignalGate(
|
|
9933
9973
|
createSyncSabTransport(init.sab, port3, {
|
|
@@ -9989,24 +10029,13 @@ async function runWasmProcess(init, port3, deps = {}) {
|
|
|
9989
10029
|
}
|
|
9990
10030
|
}
|
|
9991
10031
|
});
|
|
9992
|
-
|
|
9993
|
-
|
|
9994
|
-
|
|
9995
|
-
memory: () => memory,
|
|
9996
|
-
set: (mask) => void transport.call({ op: "proc-umask", mask }, Number.POSITIVE_INFINITY, "umask")
|
|
9997
|
-
});
|
|
9998
|
-
const fsOf = () => ownValue(module, "FS");
|
|
9999
|
-
noFollowUtimes(imports, fsOf, utimensatOf(module), () => memory);
|
|
10000
|
-
kernelAccess(imports, fsOf, () => memory);
|
|
10001
|
-
const glue = ownValue(module, "sliccFdImports");
|
|
10002
|
-
syncFsync(imports, () => ownValue(module, "FS"), glue);
|
|
10003
|
-
positionalIo(imports, {
|
|
10004
|
-
glue,
|
|
10005
|
-
fs: () => ownValue(module, "FS"),
|
|
10032
|
+
kernelWrappers(imports, module, {
|
|
10033
|
+
init,
|
|
10034
|
+
transport,
|
|
10006
10035
|
sys,
|
|
10007
|
-
memory: () => memory
|
|
10036
|
+
memory: () => memory,
|
|
10037
|
+
ppid: () => identify(transport, init).ppid
|
|
10008
10038
|
});
|
|
10009
|
-
reportGrowth(imports, () => publishMemory(init.sab, memory?.buffer.byteLength ?? 0));
|
|
10010
10039
|
return WebAssembly.instantiate(init.program.module, imports);
|
|
10011
10040
|
}).then((instance) => {
|
|
10012
10041
|
memory = wasmMemory(instance, imports);
|
|
@@ -10188,6 +10217,16 @@ var init_process_runtime = __esm({
|
|
|
10188
10217
|
" ioctl: typeof ___syscall_ioctl === 'function' ? ___syscall_ioctl : undefined,",
|
|
10189
10218
|
" setitimer: typeof __setitimer_js === 'function' ? __setitimer_js : undefined,",
|
|
10190
10219
|
"};",
|
|
10220
|
+
"Module.sliccKernelImports ??= {",
|
|
10221
|
+
" openat: typeof ___syscall_openat === 'function' ? ___syscall_openat : undefined,",
|
|
10222
|
+
" mkdirat: typeof ___syscall_mkdirat === 'function' ? ___syscall_mkdirat : undefined,",
|
|
10223
|
+
" mknodat: typeof ___syscall_mknodat === 'function' ? ___syscall_mknodat : undefined,",
|
|
10224
|
+
" umask: typeof ___syscall_umask === 'function' ? ___syscall_umask : undefined,",
|
|
10225
|
+
" faccessat: typeof ___syscall_faccessat === 'function' ? ___syscall_faccessat : undefined,",
|
|
10226
|
+
" utimensat: typeof ___syscall_utimensat === 'function' ? ___syscall_utimensat : undefined,",
|
|
10227
|
+
" getppid: typeof _slicc_getppid_js === 'function' ? _slicc_getppid_js : undefined,",
|
|
10228
|
+
" resizeHeap: typeof _emscripten_resize_heap === 'function' ? _emscripten_resize_heap : undefined,",
|
|
10229
|
+
"};",
|
|
10191
10230
|
"Module.sliccFdImports ??= {",
|
|
10192
10231
|
" fd_sync: typeof _fd_sync === 'function' ? _fd_sync : undefined,",
|
|
10193
10232
|
" fd_pread: typeof _fd_pread === 'function' ? _fd_pread : undefined,",
|