@ai-ecoverse/slicc-kernel 1.15.1 → 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/README.md +12 -1
- package/dist/index.js +15 -2
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +491 -71
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +67 -11
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +469 -68
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +67 -11
- package/dist/process-worker.js.map +3 -3
- package/package.json +3 -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
|
},
|
|
@@ -640,6 +649,7 @@ var init_live_vfs_fs = __esm({
|
|
|
640
649
|
EBADF: 8,
|
|
641
650
|
EBUSY: 10,
|
|
642
651
|
EEXIST: 20,
|
|
652
|
+
EFBIG: 22,
|
|
643
653
|
EINVAL: 28,
|
|
644
654
|
EIO: 29,
|
|
645
655
|
EISDIR: 31,
|
|
@@ -649,10 +659,12 @@ var init_live_vfs_fs = __esm({
|
|
|
649
659
|
ENOMEDIUM: 148,
|
|
650
660
|
ENOSPC: 51,
|
|
651
661
|
ENOSYS: 52,
|
|
662
|
+
ENOTCONN: 53,
|
|
652
663
|
ENOTDIR: 54,
|
|
653
664
|
ENOTEMPTY: 55,
|
|
654
665
|
EPERM: 63,
|
|
655
666
|
EROFS: 69,
|
|
667
|
+
ESTALE: 72,
|
|
656
668
|
ETIMEDOUT: 73,
|
|
657
669
|
EXDEV: 75
|
|
658
670
|
};
|
|
@@ -738,7 +750,8 @@ function parseSyncFsStat(json) {
|
|
|
738
750
|
...typeof s.atimeMs === "number" ? { atimeMs: s.atimeMs } : {},
|
|
739
751
|
...typeof s.ctimeMs === "number" ? { ctimeMs: s.ctimeMs } : {},
|
|
740
752
|
...typeof s.ino === "number" ? { ino: s.ino } : {},
|
|
741
|
-
...typeof s.dev === "number" ? { dev: s.dev } : {}
|
|
753
|
+
...typeof s.dev === "number" ? { dev: s.dev } : {},
|
|
754
|
+
...s.readonly === true ? { readonly: true } : {}
|
|
742
755
|
};
|
|
743
756
|
}
|
|
744
757
|
var SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
@@ -1022,7 +1035,11 @@ var init_wasi_errno = __esm({
|
|
|
1022
1035
|
EPIPE: 64,
|
|
1023
1036
|
ESPIPE: 70,
|
|
1024
1037
|
ESRCH: 71,
|
|
1025
|
-
ETIMEDOUT: 73
|
|
1038
|
+
ETIMEDOUT: 73,
|
|
1039
|
+
EFBIG: 22,
|
|
1040
|
+
ENOSPC: 51,
|
|
1041
|
+
EROFS: 69,
|
|
1042
|
+
ENOMEDIUM: 148
|
|
1026
1043
|
};
|
|
1027
1044
|
EIO2 = 29;
|
|
1028
1045
|
}
|
|
@@ -1375,6 +1392,16 @@ function number(r) {
|
|
|
1375
1392
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
1376
1393
|
return r.kind === "json" && typeof r.json === "number" ? r.json : -wasiErrno("EIO");
|
|
1377
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
|
+
}
|
|
1378
1405
|
function drain(Fs, stream) {
|
|
1379
1406
|
const chunks = [];
|
|
1380
1407
|
const buffer = new Uint8Array(65536);
|
|
@@ -1458,7 +1485,8 @@ function createProcessKernel(deps) {
|
|
|
1458
1485
|
};
|
|
1459
1486
|
return {
|
|
1460
1487
|
spawn(file, argv, env, cwd, fds, actions) {
|
|
1461
|
-
deps.beforeSpawn
|
|
1488
|
+
const unflushed = flushed(deps.beforeSpawn);
|
|
1489
|
+
if (unflushed < 0) return unflushed;
|
|
1462
1490
|
const promote = deps.stdioPromoter?.();
|
|
1463
1491
|
const stdio = [0, 1, 2].map((n) => slot(fds[n] ?? -1, n, promote));
|
|
1464
1492
|
const inherit = deps.inherit?.(actions) ?? [];
|
|
@@ -1486,7 +1514,8 @@ function createProcessKernel(deps) {
|
|
|
1486
1514
|
return pid;
|
|
1487
1515
|
},
|
|
1488
1516
|
fork(state) {
|
|
1489
|
-
deps.beforeSpawn
|
|
1517
|
+
const unflushed = flushed(deps.beforeSpawn);
|
|
1518
|
+
if (unflushed < 0) return unflushed;
|
|
1490
1519
|
const streams = deps.describeFork();
|
|
1491
1520
|
const r = transport.call(
|
|
1492
1521
|
{ op: "proc-fork", state: { ...state, streams, cwd: Fs.cwd() } },
|
|
@@ -3053,6 +3082,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
3053
3082
|
const restartable = () => signals.restartable();
|
|
3054
3083
|
const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
|
|
3055
3084
|
trackCloseOnExec(running.FS);
|
|
3085
|
+
quietQuit(running.FS);
|
|
3056
3086
|
useMounts(running.FS, init.env, true);
|
|
3057
3087
|
useProcfs(running.FS, sys, init.pid);
|
|
3058
3088
|
if (init.fork) restoreForkedStreams(running.FS, streams, init.fork.streams ?? []);
|
|
@@ -3091,9 +3121,29 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
3091
3121
|
try {
|
|
3092
3122
|
return runMain(running, init);
|
|
3093
3123
|
} finally {
|
|
3094
|
-
|
|
3124
|
+
try {
|
|
3125
|
+
vfs.flush();
|
|
3126
|
+
} catch {
|
|
3127
|
+
}
|
|
3095
3128
|
}
|
|
3096
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
|
+
}
|
|
3097
3147
|
function hasStreams(module) {
|
|
3098
3148
|
return typeof ownValue(module, "FS")?.getStream === "function";
|
|
3099
3149
|
}
|
|
@@ -3531,6 +3581,7 @@ var init_wasi_abi = __esm({
|
|
|
3531
3581
|
ROFS: 69,
|
|
3532
3582
|
SPIPE: 70,
|
|
3533
3583
|
SRCH: 71,
|
|
3584
|
+
STALE: 72,
|
|
3534
3585
|
TIMEDOUT: 73,
|
|
3535
3586
|
XDEV: 75,
|
|
3536
3587
|
NOTCAPABLE: 76
|
|
@@ -3620,6 +3671,13 @@ function entryOf(info) {
|
|
|
3620
3671
|
append: ((info.flags ?? 0) & O_APPEND) !== 0
|
|
3621
3672
|
};
|
|
3622
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
|
+
}
|
|
3623
3681
|
function promoteRequest(fd, f, handed) {
|
|
3624
3682
|
const orphan = f.buffer.isOrphan();
|
|
3625
3683
|
const joins = !orphan && handed.has(f.buffer);
|
|
@@ -4018,8 +4076,7 @@ var init_wasi_fds = __esm({
|
|
|
4018
4076
|
return this.install({ type: "file", file: this.file(path, s, oflags, rights, fdflags) });
|
|
4019
4077
|
}
|
|
4020
4078
|
file(path, existing, oflags, rights, fdflags) {
|
|
4021
|
-
const writable = (
|
|
4022
|
-
const readable = (rights & RIGHTS.FD_READ) !== 0n || !writable;
|
|
4079
|
+
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
4023
4080
|
let buffer = this.buffers.get(path);
|
|
4024
4081
|
if (buffer) {
|
|
4025
4082
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
@@ -4032,8 +4089,7 @@ var init_wasi_fds = __esm({
|
|
|
4032
4089
|
return new LocalFile(buffer, readable, writable, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
4033
4090
|
}
|
|
4034
4091
|
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
4035
|
-
const writable = (
|
|
4036
|
-
const readable = (rights & RIGHTS.FD_READ) !== 0n || !writable;
|
|
4092
|
+
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
4037
4093
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
4038
4094
|
const flags = (writable ? readable ? O_RDWR4 : O_WRONLY3 : 0) | (append ? O_APPEND : 0);
|
|
4039
4095
|
if (!existing) this.fs.writeFile(path, new Uint8Array(0));
|
|
@@ -4446,7 +4502,7 @@ var init_wasi_host = __esm({
|
|
|
4446
4502
|
fd_datasync: (fd) => void this.sync(fd),
|
|
4447
4503
|
fd_advise: (fd) => void fds.get(fd),
|
|
4448
4504
|
fd_allocate: (fd, offset, len) => {
|
|
4449
|
-
const file = this.positional(fd);
|
|
4505
|
+
const file = this.positional(fd, "write");
|
|
4450
4506
|
const end = Number(offset + len);
|
|
4451
4507
|
if (end > file.size()) file.truncate(end);
|
|
4452
4508
|
}
|
|
@@ -4459,7 +4515,7 @@ var init_wasi_host = __esm({
|
|
|
4459
4515
|
fd_fdstat_set_flags: (fd, flags) => void fds.setFlags(fd, (flags & FDFLAGS.NONBLOCK) !== 0, (flags & FDFLAGS.APPEND) !== 0),
|
|
4460
4516
|
fd_fdstat_set_rights: (fd) => void fds.get(fd),
|
|
4461
4517
|
fd_filestat_get: (fd, out) => void this.writeFilestat(out, this.fdFilestat(fd)),
|
|
4462
|
-
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)),
|
|
4463
4519
|
fd_filestat_set_times: (fd, atim, mtim, flags) => {
|
|
4464
4520
|
const e = fds.get(fd);
|
|
4465
4521
|
if (e.type === "file") {
|