@ai-ecoverse/slicc-kernel 1.16.0 → 1.16.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/dist/kernel-worker.js +31 -9
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +63 -11
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +31 -9
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +63 -11
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -2
|
@@ -211,6 +211,7 @@ function createHelpers(Fs, ops) {
|
|
|
211
211
|
}
|
|
212
212
|
function truncate(node, size) {
|
|
213
213
|
const s = node.live;
|
|
214
|
+
if (!s.orphan && statOf(node).readonly) throw new Fs.ErrnoError(ERRNO_BY_CODE.EROFS);
|
|
214
215
|
if (s.openCount > 0) {
|
|
215
216
|
if (size > 0) ensureLoaded(node);
|
|
216
217
|
else s.loaded = true;
|
|
@@ -399,6 +400,14 @@ function createStreamOps(h) {
|
|
|
399
400
|
return {
|
|
400
401
|
open(stream) {
|
|
401
402
|
if (!Fs.isFile(stream.node.mode)) return;
|
|
403
|
+
if ((stream.flags & 3) !== 0) {
|
|
404
|
+
try {
|
|
405
|
+
if (statOf(stream.node).readonly) throw new Fs.ErrnoError(ERRNO_BY_CODE.EROFS);
|
|
406
|
+
} catch (err) {
|
|
407
|
+
if (stream.fd !== void 0) Fs.closeStream?.(stream.fd);
|
|
408
|
+
throw err;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
402
411
|
stream.node.live.openCount++;
|
|
403
412
|
held(stream, 1);
|
|
404
413
|
},
|
|
@@ -741,7 +750,8 @@ function parseSyncFsStat(json) {
|
|
|
741
750
|
...typeof s.atimeMs === "number" ? { atimeMs: s.atimeMs } : {},
|
|
742
751
|
...typeof s.ctimeMs === "number" ? { ctimeMs: s.ctimeMs } : {},
|
|
743
752
|
...typeof s.ino === "number" ? { ino: s.ino } : {},
|
|
744
|
-
...typeof s.dev === "number" ? { dev: s.dev } : {}
|
|
753
|
+
...typeof s.dev === "number" ? { dev: s.dev } : {},
|
|
754
|
+
...s.readonly === true ? { readonly: true } : {}
|
|
745
755
|
};
|
|
746
756
|
}
|
|
747
757
|
var SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
@@ -1025,7 +1035,11 @@ var init_wasi_errno = __esm({
|
|
|
1025
1035
|
EPIPE: 64,
|
|
1026
1036
|
ESPIPE: 70,
|
|
1027
1037
|
ESRCH: 71,
|
|
1028
|
-
ETIMEDOUT: 73
|
|
1038
|
+
ETIMEDOUT: 73,
|
|
1039
|
+
EFBIG: 22,
|
|
1040
|
+
ENOSPC: 51,
|
|
1041
|
+
EROFS: 69,
|
|
1042
|
+
ENOMEDIUM: 148
|
|
1029
1043
|
};
|
|
1030
1044
|
EIO2 = 29;
|
|
1031
1045
|
}
|
|
@@ -1378,6 +1392,16 @@ function number(r) {
|
|
|
1378
1392
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
1379
1393
|
return r.kind === "json" && typeof r.json === "number" ? r.json : -wasiErrno("EIO");
|
|
1380
1394
|
}
|
|
1395
|
+
function flushed(beforeSpawn) {
|
|
1396
|
+
try {
|
|
1397
|
+
beforeSpawn();
|
|
1398
|
+
return 0;
|
|
1399
|
+
} catch (err) {
|
|
1400
|
+
const errno2 = err?.errno;
|
|
1401
|
+
if (typeof errno2 !== "number") throw err;
|
|
1402
|
+
return -errno2;
|
|
1403
|
+
}
|
|
1404
|
+
}
|
|
1381
1405
|
function drain(Fs, stream) {
|
|
1382
1406
|
const chunks = [];
|
|
1383
1407
|
const buffer = new Uint8Array(65536);
|
|
@@ -1461,7 +1485,8 @@ function createProcessKernel(deps) {
|
|
|
1461
1485
|
};
|
|
1462
1486
|
return {
|
|
1463
1487
|
spawn(file, argv, env, cwd, fds, actions) {
|
|
1464
|
-
deps.beforeSpawn
|
|
1488
|
+
const unflushed = flushed(deps.beforeSpawn);
|
|
1489
|
+
if (unflushed < 0) return unflushed;
|
|
1465
1490
|
const promote = deps.stdioPromoter?.();
|
|
1466
1491
|
const stdio = [0, 1, 2].map((n) => slot(fds[n] ?? -1, n, promote));
|
|
1467
1492
|
const inherit = deps.inherit?.(actions) ?? [];
|
|
@@ -1489,7 +1514,8 @@ function createProcessKernel(deps) {
|
|
|
1489
1514
|
return pid;
|
|
1490
1515
|
},
|
|
1491
1516
|
fork(state) {
|
|
1492
|
-
deps.beforeSpawn
|
|
1517
|
+
const unflushed = flushed(deps.beforeSpawn);
|
|
1518
|
+
if (unflushed < 0) return unflushed;
|
|
1493
1519
|
const streams = deps.describeFork();
|
|
1494
1520
|
const r = transport.call(
|
|
1495
1521
|
{ op: "proc-fork", state: { ...state, streams, cwd: Fs.cwd() } },
|
|
@@ -3056,6 +3082,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
3056
3082
|
const restartable = () => signals.restartable();
|
|
3057
3083
|
const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
|
|
3058
3084
|
trackCloseOnExec(running.FS);
|
|
3085
|
+
quietQuit(running.FS);
|
|
3059
3086
|
useMounts(running.FS, init.env, true);
|
|
3060
3087
|
useProcfs(running.FS, sys, init.pid);
|
|
3061
3088
|
if (init.fork) restoreForkedStreams(running.FS, streams, init.fork.streams ?? []);
|
|
@@ -3094,9 +3121,29 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
3094
3121
|
try {
|
|
3095
3122
|
return runMain(running, init);
|
|
3096
3123
|
} finally {
|
|
3097
|
-
|
|
3124
|
+
try {
|
|
3125
|
+
vfs.flush();
|
|
3126
|
+
} catch {
|
|
3127
|
+
}
|
|
3098
3128
|
}
|
|
3099
3129
|
}
|
|
3130
|
+
function quietQuit(Fs) {
|
|
3131
|
+
const { quit, close } = Fs;
|
|
3132
|
+
if (!quit) return;
|
|
3133
|
+
Fs.quit = () => {
|
|
3134
|
+
Fs.close = (stream) => {
|
|
3135
|
+
try {
|
|
3136
|
+
close.call(Fs, stream);
|
|
3137
|
+
} catch {
|
|
3138
|
+
}
|
|
3139
|
+
};
|
|
3140
|
+
try {
|
|
3141
|
+
quit.call(Fs);
|
|
3142
|
+
} finally {
|
|
3143
|
+
Fs.close = close;
|
|
3144
|
+
}
|
|
3145
|
+
};
|
|
3146
|
+
}
|
|
3100
3147
|
function hasStreams(module) {
|
|
3101
3148
|
return typeof ownValue(module, "FS")?.getStream === "function";
|
|
3102
3149
|
}
|
|
@@ -3624,6 +3671,13 @@ function entryOf(info) {
|
|
|
3624
3671
|
append: ((info.flags ?? 0) & O_APPEND) !== 0
|
|
3625
3672
|
};
|
|
3626
3673
|
}
|
|
3674
|
+
function openAccess(existing, oflags, rights) {
|
|
3675
|
+
const readonly = existing?.readonly === true;
|
|
3676
|
+
const mutating = readonly ? OFLAGS.TRUNC : OFLAGS.CREAT | OFLAGS.TRUNC;
|
|
3677
|
+
const writable = (rights & RIGHTS.FD_WRITE) !== 0n || (oflags & mutating) !== 0;
|
|
3678
|
+
if (writable && readonly) throw new WasiError("EROFS");
|
|
3679
|
+
return { readable: (rights & RIGHTS.FD_READ) !== 0n || !writable, writable };
|
|
3680
|
+
}
|
|
3627
3681
|
function promoteRequest(fd, f, handed) {
|
|
3628
3682
|
const orphan = f.buffer.isOrphan();
|
|
3629
3683
|
const joins = !orphan && handed.has(f.buffer);
|
|
@@ -4022,8 +4076,7 @@ var init_wasi_fds = __esm({
|
|
|
4022
4076
|
return this.install({ type: "file", file: this.file(path, s, oflags, rights, fdflags) });
|
|
4023
4077
|
}
|
|
4024
4078
|
file(path, existing, oflags, rights, fdflags) {
|
|
4025
|
-
const writable = (
|
|
4026
|
-
const readable = (rights & RIGHTS.FD_READ) !== 0n || !writable;
|
|
4079
|
+
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
4027
4080
|
let buffer = this.buffers.get(path);
|
|
4028
4081
|
if (buffer) {
|
|
4029
4082
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
@@ -4036,8 +4089,7 @@ var init_wasi_fds = __esm({
|
|
|
4036
4089
|
return new LocalFile(buffer, readable, writable, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
4037
4090
|
}
|
|
4038
4091
|
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
4039
|
-
const writable = (
|
|
4040
|
-
const readable = (rights & RIGHTS.FD_READ) !== 0n || !writable;
|
|
4092
|
+
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
4041
4093
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
4042
4094
|
const flags = (writable ? readable ? O_RDWR4 : O_WRONLY3 : 0) | (append ? O_APPEND : 0);
|
|
4043
4095
|
if (!existing) this.fs.writeFile(path, new Uint8Array(0));
|
|
@@ -4450,7 +4502,7 @@ var init_wasi_host = __esm({
|
|
|
4450
4502
|
fd_datasync: (fd) => void this.sync(fd),
|
|
4451
4503
|
fd_advise: (fd) => void fds.get(fd),
|
|
4452
4504
|
fd_allocate: (fd, offset, len) => {
|
|
4453
|
-
const file = this.positional(fd);
|
|
4505
|
+
const file = this.positional(fd, "write");
|
|
4454
4506
|
const end = Number(offset + len);
|
|
4455
4507
|
if (end > file.size()) file.truncate(end);
|
|
4456
4508
|
}
|
|
@@ -4463,7 +4515,7 @@ var init_wasi_host = __esm({
|
|
|
4463
4515
|
fd_fdstat_set_flags: (fd, flags) => void fds.setFlags(fd, (flags & FDFLAGS.NONBLOCK) !== 0, (flags & FDFLAGS.APPEND) !== 0),
|
|
4464
4516
|
fd_fdstat_set_rights: (fd) => void fds.get(fd),
|
|
4465
4517
|
fd_filestat_get: (fd, out) => void this.writeFilestat(out, this.fdFilestat(fd)),
|
|
4466
|
-
fd_filestat_set_size: (fd, size) => void this.positional(fd).truncate(Number(size)),
|
|
4518
|
+
fd_filestat_set_size: (fd, size) => void this.positional(fd, "write").truncate(Number(size)),
|
|
4467
4519
|
fd_filestat_set_times: (fd, atim, mtim, flags) => {
|
|
4468
4520
|
const e = fds.get(fd);
|
|
4469
4521
|
if (e.type === "file") {
|