@ai-ecoverse/slicc-kernel 1.61.2 → 1.62.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 +20 -6
- package/dist/index.js +12 -9
- package/dist/index.js.map +2 -2
- package/dist/kernel-worker.js +691 -263
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +72 -19
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +786 -358
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +72 -19
- package/dist/process-worker.js.map +2 -2
- package/package.json +2 -2
|
@@ -575,7 +575,26 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
575
575
|
cache.mutated(paths);
|
|
576
576
|
}
|
|
577
577
|
};
|
|
578
|
+
let exact = false;
|
|
579
|
+
const threaded = () => {
|
|
580
|
+
if (blind || shared === void 0 || !bridge.identify) return;
|
|
581
|
+
exact = true;
|
|
582
|
+
bridge.identify();
|
|
583
|
+
};
|
|
584
|
+
const identified = (p, op, also) => {
|
|
585
|
+
const before = cache.generation();
|
|
586
|
+
try {
|
|
587
|
+
return op();
|
|
588
|
+
} finally {
|
|
589
|
+
const st = bridge.identified?.() ?? null;
|
|
590
|
+
if (!st) cache.mutated([]);
|
|
591
|
+
else if (cache.mutated([p, ...also], st.ino) === before + 1 + also.length && !st.isSymbolicLink) {
|
|
592
|
+
cache.put(stats, p, st);
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
};
|
|
578
596
|
const rewriting = (p, op, ...also) => {
|
|
597
|
+
if (exact) return identified(p, op, also);
|
|
579
598
|
const ino = cache.inoOf(p, () => bridge.stat(p));
|
|
580
599
|
try {
|
|
581
600
|
return op();
|
|
@@ -634,7 +653,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
634
653
|
} : {},
|
|
635
654
|
...bridge.owners ? { owners: true } : {},
|
|
636
655
|
invalidate,
|
|
637
|
-
touched
|
|
656
|
+
touched,
|
|
657
|
+
threaded
|
|
638
658
|
};
|
|
639
659
|
}
|
|
640
660
|
function pinnedIo(bridge, handle, rewriting) {
|
|
@@ -883,11 +903,15 @@ var init_wasi_files = __esm({
|
|
|
883
903
|
}
|
|
884
904
|
mutated(paths, ino = 0) {
|
|
885
905
|
this.clear();
|
|
886
|
-
if (!this.shared) return;
|
|
906
|
+
if (!this.shared) return 0;
|
|
887
907
|
const key = ino % 4294967296 | 0;
|
|
888
908
|
for (const [i, hash] of (paths.length > 0 ? paths.map(pathHash) : [0]).entries()) {
|
|
889
909
|
this.seen = this.publish(this.shared, hash, i === 0 ? key : 0);
|
|
890
910
|
}
|
|
911
|
+
return this.seen;
|
|
912
|
+
}
|
|
913
|
+
generation() {
|
|
914
|
+
return this.shared ? Atomics.load(this.shared, FS_GEN) : 0;
|
|
891
915
|
}
|
|
892
916
|
inoOf(path, look) {
|
|
893
917
|
if (!this.shared) return 0;
|
|
@@ -1307,6 +1331,7 @@ var init_wasi_fds = __esm({
|
|
|
1307
1331
|
this.cloexec.clear();
|
|
1308
1332
|
}
|
|
1309
1333
|
this.shared = ids;
|
|
1334
|
+
this.fs.threaded?.();
|
|
1310
1335
|
this.seen = Atomics.load(ids, GEN);
|
|
1311
1336
|
}
|
|
1312
1337
|
sync() {
|
|
@@ -1631,6 +1656,14 @@ var init_wasi_fds = __esm({
|
|
|
1631
1656
|
this.detach(buffer, linked);
|
|
1632
1657
|
this.buffers.delete(path);
|
|
1633
1658
|
}
|
|
1659
|
+
openedIno(fd) {
|
|
1660
|
+
try {
|
|
1661
|
+
return this.kernel.call({ op: "fd-vfs-stat", fd, identity: true }).ino;
|
|
1662
|
+
} catch (err) {
|
|
1663
|
+
this.kernel.sys.close(fd);
|
|
1664
|
+
throw err;
|
|
1665
|
+
}
|
|
1666
|
+
}
|
|
1634
1667
|
inoOf(path) {
|
|
1635
1668
|
try {
|
|
1636
1669
|
return this.fs.stat(path).ino;
|
|
@@ -1724,10 +1757,10 @@ var init_wasi_fds = __esm({
|
|
|
1724
1757
|
if (e.path !== void 0 || this.learned.has(e)) return;
|
|
1725
1758
|
this.learned.add(e);
|
|
1726
1759
|
try {
|
|
1727
|
-
const vfs = this.kernel.call({ op: "fd-vfs-stat", fd });
|
|
1760
|
+
const vfs = this.kernel.call({ op: "fd-vfs-stat", fd, identity: true });
|
|
1728
1761
|
if (vfs.orphan || vfs.path === void 0) return;
|
|
1729
1762
|
e.path = vfs.path;
|
|
1730
|
-
e.ino = this.inoOf(vfs.path);
|
|
1763
|
+
e.ino = vfs.ino ?? this.inoOf(vfs.path);
|
|
1731
1764
|
} catch {
|
|
1732
1765
|
}
|
|
1733
1766
|
}
|
|
@@ -1765,9 +1798,8 @@ var init_wasi_fds = __esm({
|
|
|
1765
1798
|
const made = !existing && this.createNew(path, oflags);
|
|
1766
1799
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
1767
1800
|
const fd = this.kernel.sys.openVfs(path, flags, 0, truncate ? { truncate } : {});
|
|
1768
|
-
const
|
|
1769
|
-
if (truncate) this.fs.touched?.(path,
|
|
1770
|
-
const ino = existing ? was : this.inoOf(path);
|
|
1801
|
+
const ino = writable2 ? this.openedIno(fd) ?? this.inoOf(path) : void 0;
|
|
1802
|
+
if (truncate) this.fs.touched?.(path, ino);
|
|
1771
1803
|
this.table.set(fd, { type: "kernel", kind: "file", nonblock: false, append, path, ino });
|
|
1772
1804
|
if (append) this.publishFlags(fd, { nonblock: false, append });
|
|
1773
1805
|
this.bump();
|
|
@@ -2660,9 +2692,9 @@ var init_wasi_host = __esm({
|
|
|
2660
2692
|
this.unnamed.add(e);
|
|
2661
2693
|
let path;
|
|
2662
2694
|
try {
|
|
2663
|
-
const st = this.
|
|
2695
|
+
const st = this.o.kernel.call({ op: "fd-vfs-stat", fd, identity: true });
|
|
2664
2696
|
path = st.orphan ? void 0 : st.path;
|
|
2665
|
-
if (path !== void 0) e.ino = this.o.fs.stat(path).ino;
|
|
2697
|
+
if (path !== void 0) e.ino = st.ino ?? this.o.fs.stat(path).ino;
|
|
2666
2698
|
} catch {
|
|
2667
2699
|
return;
|
|
2668
2700
|
}
|
|
@@ -3151,6 +3183,12 @@ function importsContext({
|
|
|
3151
3183
|
if (path === void 0) throw new WasiError("EBADF");
|
|
3152
3184
|
return path;
|
|
3153
3185
|
};
|
|
3186
|
+
const owners = fs.owners === true;
|
|
3187
|
+
const live = () => {
|
|
3188
|
+
if (!owners) return { uid: UID, gid: UID };
|
|
3189
|
+
const cred = call2({ op: "proc-cred" });
|
|
3190
|
+
return { uid: cred.euid, gid: cred.egid };
|
|
3191
|
+
};
|
|
3154
3192
|
const fds = {
|
|
3155
3193
|
open(path, o = {}) {
|
|
3156
3194
|
const abs = host.fds.resolve(3, path);
|
|
@@ -3171,7 +3209,7 @@ function importsContext({
|
|
|
3171
3209
|
const path = pathOf(fd);
|
|
3172
3210
|
if (path === void 0) {
|
|
3173
3211
|
const kind = e.type === "device" ? "device" : "stream";
|
|
3174
|
-
return { kind, mode: kind === "device" ? 8630 : 4480,
|
|
3212
|
+
return { kind, mode: kind === "device" ? 8630 : 4480, ...live(), size: 0 };
|
|
3175
3213
|
}
|
|
3176
3214
|
host.fds.flushPath(path);
|
|
3177
3215
|
const s = fs.stat(path);
|
|
@@ -3179,8 +3217,7 @@ function importsContext({
|
|
|
3179
3217
|
kind: s.isDirectory ? "dir" : "file",
|
|
3180
3218
|
path,
|
|
3181
3219
|
mode: s.mode ?? (s.isDirectory ? 16877 : 33188),
|
|
3182
|
-
uid:
|
|
3183
|
-
gid: UID,
|
|
3220
|
+
...s.uid !== void 0 && s.gid !== void 0 ? { uid: s.uid, gid: s.gid } : live(),
|
|
3184
3221
|
size: s.size,
|
|
3185
3222
|
...s.ino !== void 0 ? { ino: s.ino } : {},
|
|
3186
3223
|
...s.mtimeMs !== void 0 ? { mtimeMs: s.mtimeMs } : {}
|
|
@@ -3203,7 +3240,7 @@ function importsContext({
|
|
|
3203
3240
|
call2({ op: "unlock", path: requirePath(fd) });
|
|
3204
3241
|
}
|
|
3205
3242
|
};
|
|
3206
|
-
|
|
3243
|
+
const ctx = {
|
|
3207
3244
|
memory,
|
|
3208
3245
|
instance,
|
|
3209
3246
|
tid,
|
|
@@ -3242,6 +3279,11 @@ function importsContext({
|
|
|
3242
3279
|
},
|
|
3243
3280
|
errno: (err) => wasiErrnoOf(code(err))
|
|
3244
3281
|
};
|
|
3282
|
+
if (!owners) return ctx;
|
|
3283
|
+
return Object.defineProperties(ctx, {
|
|
3284
|
+
uid: { get: () => live().uid, enumerable: true },
|
|
3285
|
+
gid: { get: () => live().gid, enumerable: true }
|
|
3286
|
+
});
|
|
3245
3287
|
}
|
|
3246
3288
|
function processes(host, call2, inThread) {
|
|
3247
3289
|
const close = (fd) => void call2({ op: "fd-close", fd });
|
|
@@ -4517,7 +4559,10 @@ function errnoError(code2, path) {
|
|
|
4517
4559
|
}
|
|
4518
4560
|
function createSyncFsSabBridge(transport, opts = {}) {
|
|
4519
4561
|
const timeoutMs = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
4562
|
+
let identity = {};
|
|
4563
|
+
let last = null;
|
|
4520
4564
|
function run(req, path, transfer) {
|
|
4565
|
+
last = null;
|
|
4521
4566
|
const result = transport.call(req, timeoutMs, `sync-sab bridge, '${path}'`, transfer);
|
|
4522
4567
|
if (!result.ok) throw errnoError(result.errno, path);
|
|
4523
4568
|
return result;
|
|
@@ -4532,20 +4577,24 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4532
4577
|
if (r.ok && r.kind === "json") return r.json;
|
|
4533
4578
|
throw errnoError("EIO", path);
|
|
4534
4579
|
}
|
|
4580
|
+
const changing = (req, path, transfer) => {
|
|
4581
|
+
const r = run({ ...req, ...identity }, path, transfer);
|
|
4582
|
+
if (r.ok && r.kind === "json") last = parseSyncFsStat(r.json);
|
|
4583
|
+
};
|
|
4535
4584
|
const io = (id) => ({
|
|
4536
4585
|
readFile: (path) => bytes({ op: "read", path, ...id }, path),
|
|
4537
4586
|
writeFile: (path, data, open) => {
|
|
4538
|
-
|
|
4587
|
+
changing({ op: "write", path, body: data, ...open ? { mode: 1 } : {}, ...id }, path);
|
|
4539
4588
|
},
|
|
4540
4589
|
pread: (path, offset, length, version) => bytes({ op: "pread", path, offset, length, ...version ? { version } : {}, ...id }, path),
|
|
4541
4590
|
pwrite: (path, offset, body, transfer) => {
|
|
4542
4591
|
const whole = body.byteOffset === 0 && body.byteLength === body.buffer.byteLength;
|
|
4543
4592
|
const owned = transfer && whole && body.buffer instanceof ArrayBuffer;
|
|
4544
4593
|
const transferred = owned ? [body.buffer] : [];
|
|
4545
|
-
|
|
4594
|
+
changing({ op: "pwrite", path, offset, body, ...id }, path, transferred);
|
|
4546
4595
|
},
|
|
4547
4596
|
truncate: (path, length) => {
|
|
4548
|
-
|
|
4597
|
+
changing({ op: "truncate", path, length, ...id }, path);
|
|
4549
4598
|
}
|
|
4550
4599
|
});
|
|
4551
4600
|
return {
|
|
@@ -4617,11 +4666,15 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4617
4666
|
return target;
|
|
4618
4667
|
},
|
|
4619
4668
|
chmod: (path, mode) => {
|
|
4620
|
-
|
|
4669
|
+
changing({ op: "chmod", path, mode }, path);
|
|
4621
4670
|
},
|
|
4622
4671
|
utimes: (path, atimeMs, mtimeMs) => {
|
|
4623
|
-
|
|
4672
|
+
changing({ op: "utimes", path, atimeMs, mtimeMs }, path);
|
|
4673
|
+
},
|
|
4674
|
+
identify: () => {
|
|
4675
|
+
identity = { identity: true };
|
|
4624
4676
|
},
|
|
4677
|
+
identified: () => last,
|
|
4625
4678
|
lutimes: (path, atimeMs, mtimeMs) => {
|
|
4626
4679
|
run({ op: "lutimes", path, atimeMs, mtimeMs }, path);
|
|
4627
4680
|
},
|
|
@@ -4630,7 +4683,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
4630
4683
|
},
|
|
4631
4684
|
chown: (path, uid, gid, follow2) => {
|
|
4632
4685
|
const ids = { ...uid !== void 0 ? { uid } : {}, ...gid !== void 0 ? { gid } : {} };
|
|
4633
|
-
|
|
4686
|
+
changing({ op: follow2 ? "chown" : "lchown", path, ...ids }, path);
|
|
4634
4687
|
},
|
|
4635
4688
|
...opts.owners ? { owners: true } : {},
|
|
4636
4689
|
hold: (path, held, open, handle) => {
|