@ai-ecoverse/slicc-kernel 1.97.0 → 1.97.2
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 -2
- package/dist/kernel-worker.js +215 -19
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +222 -68
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +219 -23
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +233 -79
- package/dist/process-worker.js.map +4 -4
- package/package.json +4 -5
package/dist/process-worker.js
CHANGED
|
@@ -1232,8 +1232,8 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1232
1232
|
access: (path, mode, kind = "access", nofollow) => {
|
|
1233
1233
|
run({ op: "access", path, mode, arg2: kind, ...nofollow ? { nofollow } : {} }, path);
|
|
1234
1234
|
},
|
|
1235
|
-
hold: (path,
|
|
1236
|
-
const mode = (
|
|
1235
|
+
hold: (path, held2, open, handle, want = 0) => {
|
|
1236
|
+
const mode = (held2 ? 1 : 0) | (open ? 2 : 0);
|
|
1237
1237
|
if (mode === 3) return json2({ op: "hold", path, mode: mode | want }, path);
|
|
1238
1238
|
run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
|
|
1239
1239
|
return void 0;
|
|
@@ -1783,7 +1783,7 @@ function appendThrough(h, stream, bytes) {
|
|
|
1783
1783
|
}
|
|
1784
1784
|
function createStreamOps(h) {
|
|
1785
1785
|
const { Fs, statOf, ensureLoaded, ensureCapacity, flushNode, bridgeOf, rangedOf } = h;
|
|
1786
|
-
const
|
|
1786
|
+
const held2 = (stream, change) => {
|
|
1787
1787
|
const s = stream.node.live;
|
|
1788
1788
|
if ((stream.flags & 3) === 0 || s.orphan) return;
|
|
1789
1789
|
const before = s.writers ?? 0;
|
|
@@ -1864,12 +1864,12 @@ function createStreamOps(h) {
|
|
|
1864
1864
|
if (stream.fd !== void 0) Fs.closeStream?.(stream.fd);
|
|
1865
1865
|
throw err;
|
|
1866
1866
|
}
|
|
1867
|
-
|
|
1867
|
+
held2(stream, 1);
|
|
1868
1868
|
},
|
|
1869
1869
|
dup(stream) {
|
|
1870
1870
|
if (!Fs.isFile(stream.node.mode)) return;
|
|
1871
1871
|
stream.node.live.openCount++;
|
|
1872
|
-
|
|
1872
|
+
held2(stream, 1);
|
|
1873
1873
|
},
|
|
1874
1874
|
close(stream) {
|
|
1875
1875
|
const node = stream.node;
|
|
@@ -1877,7 +1877,7 @@ function createStreamOps(h) {
|
|
|
1877
1877
|
const s = node.live;
|
|
1878
1878
|
s.openCount = Math.max(0, s.openCount - 1);
|
|
1879
1879
|
if (s.openCount > 0) {
|
|
1880
|
-
|
|
1880
|
+
held2(stream, -1);
|
|
1881
1881
|
return;
|
|
1882
1882
|
}
|
|
1883
1883
|
try {
|
|
@@ -1888,7 +1888,7 @@ function createStreamOps(h) {
|
|
|
1888
1888
|
s.ranges = false;
|
|
1889
1889
|
s.len = 0;
|
|
1890
1890
|
s.loaded = false;
|
|
1891
|
-
|
|
1891
|
+
held2(stream, -1);
|
|
1892
1892
|
opened2(node, false);
|
|
1893
1893
|
}
|
|
1894
1894
|
},
|
|
@@ -2076,6 +2076,7 @@ function liveRoot(Fs, bridge) {
|
|
|
2076
2076
|
invalidateLiveVfs(Fs, plugin);
|
|
2077
2077
|
guardRenames(Fs);
|
|
2078
2078
|
guardKeptNodes(Fs, plugin.handled);
|
|
2079
|
+
guardStaleNodes(Fs, plugin);
|
|
2079
2080
|
guardStatfs(Fs);
|
|
2080
2081
|
const memfs = root.memfs ?? root.node_ops;
|
|
2081
2082
|
const live = plugin.node_ops;
|
|
@@ -2143,7 +2144,7 @@ function guardKeptNodes(Fs, handled) {
|
|
|
2143
2144
|
const lookupPath = Fs.lookupPath.bind(Fs);
|
|
2144
2145
|
Fs.open = (path, flags, mode) => {
|
|
2145
2146
|
const name2 = path.slice(path.lastIndexOf("/") + 1);
|
|
2146
|
-
if (![...handled].some((
|
|
2147
|
+
if (![...handled].some((held2) => held2.name === name2)) return open(path, flags, mode);
|
|
2147
2148
|
let node;
|
|
2148
2149
|
try {
|
|
2149
2150
|
node = lookupPath(path, { follow: true }).node;
|
|
@@ -2154,6 +2155,33 @@ function guardKeptNodes(Fs, handled) {
|
|
|
2154
2155
|
return open(path, flags, mode);
|
|
2155
2156
|
};
|
|
2156
2157
|
}
|
|
2158
|
+
function outdated(node, view, before) {
|
|
2159
|
+
const s = node.live;
|
|
2160
|
+
if (s.named === void 0) {
|
|
2161
|
+
s.named = before;
|
|
2162
|
+
return false;
|
|
2163
|
+
}
|
|
2164
|
+
if (s.named === before) return false;
|
|
2165
|
+
const { now, changed: changed2 } = view.changedSince(s.named, liveNodePath(node));
|
|
2166
|
+
s.named = now;
|
|
2167
|
+
return changed2 && s.openCount === 0 && !s.dirty && node !== node.mount.root && !node.mounted;
|
|
2168
|
+
}
|
|
2169
|
+
function guardStaleNodes(Fs, plugin) {
|
|
2170
|
+
const lookupNode = Fs.lookupNode?.bind(Fs);
|
|
2171
|
+
const forget = Fs.hashRemoveNode?.bind(Fs);
|
|
2172
|
+
if (!lookupNode || !forget || Fs.sliccStale) return;
|
|
2173
|
+
Fs.sliccStale = true;
|
|
2174
|
+
Fs.lookupNode = (parent, name2) => {
|
|
2175
|
+
const view = parent.live ? parent.mount.opts.bridge.changes : void 0;
|
|
2176
|
+
const before = view?.now() ?? 0;
|
|
2177
|
+
const node = lookupNode(parent, name2);
|
|
2178
|
+
if (!view || !ownedBy(plugin, node) || !outdated(node, view, before)) return node;
|
|
2179
|
+
forget(node);
|
|
2180
|
+
const fresh = lookupNode(parent, name2);
|
|
2181
|
+
if (fresh.live) fresh.live.named = before;
|
|
2182
|
+
return fresh;
|
|
2183
|
+
};
|
|
2184
|
+
}
|
|
2157
2185
|
function guardRenames(Fs) {
|
|
2158
2186
|
const rename = Fs.rename?.bind(Fs);
|
|
2159
2187
|
if (!rename || Fs.sliccRename) return;
|
|
@@ -2246,8 +2274,8 @@ function linkLive(Fs, from, to, follow2) {
|
|
|
2246
2274
|
try {
|
|
2247
2275
|
bridge.link(path, base === "/" ? `/${name2}` : `${base}/${name2}`);
|
|
2248
2276
|
} catch (err) {
|
|
2249
|
-
const
|
|
2250
|
-
if (
|
|
2277
|
+
const refused2 = toErrno(Fs, err);
|
|
2278
|
+
if (refused2.errno !== wasiErrno("EPERM") || linkable(bridge, path)) throw refused2;
|
|
2251
2279
|
throw new Fs.ErrnoError(wasiErrno("EMLINK"));
|
|
2252
2280
|
}
|
|
2253
2281
|
source.live.stat = void 0;
|
|
@@ -2377,6 +2405,118 @@ var init_dev_removal = __esm({
|
|
|
2377
2405
|
}
|
|
2378
2406
|
});
|
|
2379
2407
|
|
|
2408
|
+
// src/process/process-locks.ts
|
|
2409
|
+
function lockTarget(stream) {
|
|
2410
|
+
if (stream.sliccKernelFile && stream.sliccKernelFd !== void 0) {
|
|
2411
|
+
return { fd: stream.sliccKernelFd };
|
|
2412
|
+
}
|
|
2413
|
+
const node = stream.node;
|
|
2414
|
+
return node.live && node.mount ? { path: liveNodePath(node) } : void 0;
|
|
2415
|
+
}
|
|
2416
|
+
function errnoOf(err) {
|
|
2417
|
+
const code2 = err?.code;
|
|
2418
|
+
if (typeof code2 === "string") return wasiErrno(code2);
|
|
2419
|
+
const errno2 = err?.errno;
|
|
2420
|
+
return typeof errno2 === "number" ? errno2 : wasiErrno("EIO");
|
|
2421
|
+
}
|
|
2422
|
+
function sizeOf(Fs, stream) {
|
|
2423
|
+
const st = Fs.fstat?.(stream.fd);
|
|
2424
|
+
return st?.size ?? 0;
|
|
2425
|
+
}
|
|
2426
|
+
function kindOf(type) {
|
|
2427
|
+
if (type === F_RDLCK) return "read";
|
|
2428
|
+
if (type === F_WRLCK) return "write";
|
|
2429
|
+
return type === F_UNLCK ? "unlock" : void 0;
|
|
2430
|
+
}
|
|
2431
|
+
function readFlock(view, at, base) {
|
|
2432
|
+
const kind = kindOf(view.getInt16(at, true));
|
|
2433
|
+
if (kind === void 0) return void 0;
|
|
2434
|
+
const start2 = base(view.getInt16(at + 2, true)) + Number(view.getBigInt64(at + 8, true));
|
|
2435
|
+
return { kind, start: start2, len: Number(view.getBigInt64(at + 16, true)) };
|
|
2436
|
+
}
|
|
2437
|
+
function writeHolder(view, at, found) {
|
|
2438
|
+
if (!found) {
|
|
2439
|
+
view.setInt16(at, F_UNLCK, true);
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
view.setInt16(at, found.kind === "read" ? F_RDLCK : F_WRLCK, true);
|
|
2443
|
+
view.setInt16(at + 2, 0, true);
|
|
2444
|
+
view.setBigInt64(at + 8, BigInt(found.start), true);
|
|
2445
|
+
view.setBigInt64(at + 16, BigInt(found.len), true);
|
|
2446
|
+
view.setInt32(at + 24, found.pid, true);
|
|
2447
|
+
}
|
|
2448
|
+
function refused(kind, flags) {
|
|
2449
|
+
const access = flags & O_ACCMODE2;
|
|
2450
|
+
return kind === "write" && access === O_RDONLY || kind === "read" && access === O_WRONLY;
|
|
2451
|
+
}
|
|
2452
|
+
function baseOf(Fs, stream) {
|
|
2453
|
+
return (whence) => whence === SEEK_CUR2 ? stream.position : whence === SEEK_END2 ? sizeOf(Fs, stream) : 0;
|
|
2454
|
+
}
|
|
2455
|
+
function recordLock(fcntl, deps) {
|
|
2456
|
+
return (fd, cmd, varargs) => {
|
|
2457
|
+
if (cmd !== F_GETLK && cmd !== F_SETLK && cmd !== F_SETLKW) return fcntl(fd, cmd, varargs);
|
|
2458
|
+
const Fs = deps.fs();
|
|
2459
|
+
const buffer = deps.memory();
|
|
2460
|
+
const stream = Fs?.getStream(fd);
|
|
2461
|
+
const target = stream ? lockTarget(stream) : void 0;
|
|
2462
|
+
if (!Fs || !buffer || !stream || !target) return fcntl(fd, cmd, varargs);
|
|
2463
|
+
const view = new DataView(buffer);
|
|
2464
|
+
const at = view.getUint32(varargs, true);
|
|
2465
|
+
const lock = readFlock(view, at, baseOf(Fs, stream));
|
|
2466
|
+
if (!lock || cmd === F_GETLK && lock.kind === "unlock") return -wasiErrno("EINVAL");
|
|
2467
|
+
try {
|
|
2468
|
+
if (cmd === F_GETLK) {
|
|
2469
|
+
writeHolder(
|
|
2470
|
+
view,
|
|
2471
|
+
at,
|
|
2472
|
+
deps.kernel.getLock(target, lock.kind, lock.start, lock.len)
|
|
2473
|
+
);
|
|
2474
|
+
return 0;
|
|
2475
|
+
}
|
|
2476
|
+
if (refused(lock.kind, stream.flags)) return -wasiErrno("EBADF");
|
|
2477
|
+
if (lock.kind !== "write") deps.flush();
|
|
2478
|
+
deps.kernel.setLock(target, lock.kind, lock.start, lock.len, cmd === F_SETLKW);
|
|
2479
|
+
if (lock.kind !== "unlock") held.set(Fs, true);
|
|
2480
|
+
return 0;
|
|
2481
|
+
} catch (err) {
|
|
2482
|
+
return -errnoOf(err);
|
|
2483
|
+
}
|
|
2484
|
+
};
|
|
2485
|
+
}
|
|
2486
|
+
function closeDropsLocks(Fs, kernel) {
|
|
2487
|
+
const close = Fs.close;
|
|
2488
|
+
if (typeof close !== "function") return;
|
|
2489
|
+
Fs.close = (stream) => {
|
|
2490
|
+
const target = held.has(Fs) && !stream.sliccKernelFile ? lockTarget(stream) : void 0;
|
|
2491
|
+
close.call(Fs, stream);
|
|
2492
|
+
if (!target) return;
|
|
2493
|
+
try {
|
|
2494
|
+
kernel.closeLocks(target);
|
|
2495
|
+
} catch {
|
|
2496
|
+
}
|
|
2497
|
+
};
|
|
2498
|
+
}
|
|
2499
|
+
var F_GETLK, F_SETLK, F_SETLKW, F_RDLCK, F_WRLCK, F_UNLCK, SEEK_CUR2, SEEK_END2, O_ACCMODE2, O_RDONLY, O_WRONLY, held;
|
|
2500
|
+
var init_process_locks = __esm({
|
|
2501
|
+
"src/process/process-locks.ts"() {
|
|
2502
|
+
"use strict";
|
|
2503
|
+
init_live_vfs_fs();
|
|
2504
|
+
init_wasi_errno();
|
|
2505
|
+
F_GETLK = 12;
|
|
2506
|
+
F_SETLK = 13;
|
|
2507
|
+
F_SETLKW = 14;
|
|
2508
|
+
F_RDLCK = 0;
|
|
2509
|
+
F_WRLCK = 1;
|
|
2510
|
+
F_UNLCK = 2;
|
|
2511
|
+
SEEK_CUR2 = 1;
|
|
2512
|
+
SEEK_END2 = 2;
|
|
2513
|
+
O_ACCMODE2 = 3;
|
|
2514
|
+
O_RDONLY = 0;
|
|
2515
|
+
O_WRONLY = 1;
|
|
2516
|
+
held = /* @__PURE__ */ new WeakMap();
|
|
2517
|
+
}
|
|
2518
|
+
});
|
|
2519
|
+
|
|
2380
2520
|
// src/process/process-pty.ts
|
|
2381
2521
|
function failed(e) {
|
|
2382
2522
|
const code2 = e?.code;
|
|
@@ -2532,7 +2672,7 @@ function wrapperFactories(deps) {
|
|
|
2532
2672
|
const { pty, timer } = deps;
|
|
2533
2673
|
return {
|
|
2534
2674
|
...timer ? { setitimer: (f) => kernelTimer(f, timer) } : {},
|
|
2535
|
-
fcntl: (f) => cloexecFcntl(f, deps),
|
|
2675
|
+
fcntl: (f) => cloexecFcntl(deps.locks ? recordLock(f, { ...deps.locks, fs: deps.fs }) : f, deps),
|
|
2536
2676
|
pipe2: (f) => cloexecPipe2(f, deps),
|
|
2537
2677
|
dup3: (f) => cloexecByFlag(quietTarget(f, deps), 2, deps),
|
|
2538
2678
|
socket: (f) => cloexecByFlag(f, 1, deps),
|
|
@@ -2666,7 +2806,7 @@ function noFollowUtimes(imports, fs, glue, memory = () => void 0) {
|
|
|
2666
2806
|
}
|
|
2667
2807
|
);
|
|
2668
2808
|
}
|
|
2669
|
-
function
|
|
2809
|
+
function errnoOf2(err) {
|
|
2670
2810
|
const { errno: errno2, code: code2 } = err ?? {};
|
|
2671
2811
|
if (typeof errno2 === "number") return errno2;
|
|
2672
2812
|
if (typeof code2 === "string") return wasiErrno(code2);
|
|
@@ -2701,7 +2841,7 @@ function syncFsync(imports, fs, glue) {
|
|
|
2701
2841
|
const result = stream.stream_ops.fsync?.(stream);
|
|
2702
2842
|
return typeof result === "number" ? result : 0;
|
|
2703
2843
|
} catch (err) {
|
|
2704
|
-
return
|
|
2844
|
+
return errnoOf2(err);
|
|
2705
2845
|
}
|
|
2706
2846
|
};
|
|
2707
2847
|
}
|
|
@@ -2742,7 +2882,7 @@ function positioned(original, write2, deps) {
|
|
|
2742
2882
|
if (moved < len) break;
|
|
2743
2883
|
}
|
|
2744
2884
|
} catch (err) {
|
|
2745
|
-
return
|
|
2885
|
+
return errnoOf2(err);
|
|
2746
2886
|
}
|
|
2747
2887
|
view.setUint32(Number(rest2[rest2.length - 1]), done, true);
|
|
2748
2888
|
return 0;
|
|
@@ -2778,7 +2918,7 @@ function useFileMmap(Fs, deps) {
|
|
|
2778
2918
|
const shared = (flags & MAP_TYPE) !== MAP_PRIVATE && (prot & PROT_WRITE) !== 0;
|
|
2779
2919
|
const kfd = stream.sliccKernelFile ? stream.sliccKernelFd : void 0;
|
|
2780
2920
|
if (shared && kfd !== void 0) throw new Fs.ErrnoError(wasiErrno("ENODEV"));
|
|
2781
|
-
if (stream.stream_ops.mmap && kfd === void 0 || !memalign || !memory || length <= 0 || shared || (stream.flags &
|
|
2921
|
+
if (stream.stream_ops.mmap && kfd === void 0 || !memalign || !memory || length <= 0 || shared || (stream.flags & O_ACCMODE3) === O_WRONLY2 || !Fs.isFile(stream.node.mode)) {
|
|
2782
2922
|
return mmap.call(fs, stream, length, position, prot, flags);
|
|
2783
2923
|
}
|
|
2784
2924
|
const data = staging(Fs, length);
|
|
@@ -2791,7 +2931,7 @@ function useFileMmap(Fs, deps) {
|
|
|
2791
2931
|
}
|
|
2792
2932
|
}
|
|
2793
2933
|
} catch (err) {
|
|
2794
|
-
throw new Fs.ErrnoError(
|
|
2934
|
+
throw new Fs.ErrnoError(errnoOf2(err));
|
|
2795
2935
|
}
|
|
2796
2936
|
const size = Math.ceil(length / MAP_ALIGN) * MAP_ALIGN;
|
|
2797
2937
|
const ptr = memalign(MAP_ALIGN, size);
|
|
@@ -2900,8 +3040,8 @@ function useDevRemoval(Fs) {
|
|
|
2900
3040
|
const remove = fs[name2];
|
|
2901
3041
|
if (typeof remove !== "function") continue;
|
|
2902
3042
|
fs[name2] = (path) => {
|
|
2903
|
-
const
|
|
2904
|
-
if (
|
|
3043
|
+
const refused2 = devRemoval(absoluteOf(path, Fs.cwd()), fs.sliccCred);
|
|
3044
|
+
if (refused2) throw new Fs.ErrnoError(wasiErrno(refused2));
|
|
2905
3045
|
remove.call(Fs, path);
|
|
2906
3046
|
};
|
|
2907
3047
|
}
|
|
@@ -3007,7 +3147,7 @@ function useMounts(Fs, env = {}, live = false) {
|
|
|
3007
3147
|
const open = Fs.open.bind(Fs);
|
|
3008
3148
|
Fs.open = (path, flags, mode) => {
|
|
3009
3149
|
const instead = backing[path];
|
|
3010
|
-
if (!instead || (flags & (
|
|
3150
|
+
if (!instead || (flags & (O_ACCMODE3 | O_CREAT)) !== 0) return open(path, flags, mode);
|
|
3011
3151
|
try {
|
|
3012
3152
|
return open(path, flags, mode);
|
|
3013
3153
|
} catch (e) {
|
|
@@ -3020,14 +3160,14 @@ function cString(memory, at) {
|
|
|
3020
3160
|
const bytes = new Uint8Array(memory.buffer, at);
|
|
3021
3161
|
return new TextDecoder().decode(bytes.subarray(0, bytes.indexOf(0)));
|
|
3022
3162
|
}
|
|
3023
|
-
function
|
|
3163
|
+
function baseOf2(Fs, dirfd) {
|
|
3024
3164
|
return dirfd === AT_FDCWD ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
|
|
3025
3165
|
}
|
|
3026
3166
|
function readonlyRefusal(Fs, memory, call2) {
|
|
3027
3167
|
if (!(call2.amode & W_ACCESS)) return 0;
|
|
3028
3168
|
try {
|
|
3029
3169
|
const name2 = cString(memory, call2.path);
|
|
3030
|
-
const abs = name2.startsWith("/") ? name2 : `${
|
|
3170
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf2(Fs, call2.dirfd)}/${name2}`;
|
|
3031
3171
|
const follow2 = (call2.flags & AT_SYMLINK_NOFOLLOW) === 0;
|
|
3032
3172
|
const { node } = Fs.lookupPath.call(Fs, abs, {
|
|
3033
3173
|
follow: follow2
|
|
@@ -3042,7 +3182,7 @@ function readonlyRefusal(Fs, memory, call2) {
|
|
|
3042
3182
|
}
|
|
3043
3183
|
function kernelChecks(Fs, memory, call2) {
|
|
3044
3184
|
const name2 = cString(memory, call2.path);
|
|
3045
|
-
const abs = name2.startsWith("/") ? name2 : `${
|
|
3185
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf2(Fs, call2.dirfd)}/${name2}`;
|
|
3046
3186
|
const lookupPath = Fs.lookupPath;
|
|
3047
3187
|
const { node } = lookupPath.call(Fs, abs, { follow: (call2.flags & AT_SYMLINK_NOFOLLOW) === 0 });
|
|
3048
3188
|
const bridge = node.live ? node.mount.opts.bridge : void 0;
|
|
@@ -3056,14 +3196,14 @@ function kernelAccess(imports, fs, memory, glue) {
|
|
|
3056
3196
|
const Fs = fs();
|
|
3057
3197
|
const heap = memory();
|
|
3058
3198
|
const call2 = { dirfd, path, amode: amode & 7, flags };
|
|
3059
|
-
const
|
|
3060
|
-
if (
|
|
3199
|
+
const refused2 = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap, call2) : 0;
|
|
3200
|
+
if (refused2 !== 0) return refused2;
|
|
3061
3201
|
const rc = own(dirfd, path, amode, flags);
|
|
3062
3202
|
if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
|
|
3063
3203
|
try {
|
|
3064
3204
|
return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
|
|
3065
3205
|
} catch (err) {
|
|
3066
|
-
return -
|
|
3206
|
+
return -errnoOf2(err);
|
|
3067
3207
|
}
|
|
3068
3208
|
});
|
|
3069
3209
|
}
|
|
@@ -3078,7 +3218,7 @@ function kernelLink(imports, fs, memory, glue) {
|
|
|
3078
3218
|
if (!Fs?.lookupPath || !heap) return own(olddirfd, oldpath, newdirfd, newpath, flags);
|
|
3079
3219
|
const at = (dirfd, ptr) => {
|
|
3080
3220
|
const name2 = cString(heap, ptr);
|
|
3081
|
-
return name2.startsWith("/") ? name2 : `${
|
|
3221
|
+
return name2.startsWith("/") ? name2 : `${baseOf2(Fs, dirfd)}/${name2}`;
|
|
3082
3222
|
};
|
|
3083
3223
|
try {
|
|
3084
3224
|
const from = at(olddirfd, oldpath);
|
|
@@ -3086,7 +3226,7 @@ function kernelLink(imports, fs, memory, glue) {
|
|
|
3086
3226
|
const follow2 = (flags & AT_SYMLINK_FOLLOW) !== 0;
|
|
3087
3227
|
if (linkLive(Fs, from, to, follow2)) return 0;
|
|
3088
3228
|
} catch (err) {
|
|
3089
|
-
return -
|
|
3229
|
+
return -errnoOf2(err);
|
|
3090
3230
|
}
|
|
3091
3231
|
return own(olddirfd, oldpath, newdirfd, newpath, flags);
|
|
3092
3232
|
},
|
|
@@ -3103,7 +3243,7 @@ function kernelChdir(Fs) {
|
|
|
3103
3243
|
try {
|
|
3104
3244
|
bridge?.access?.(liveNodePath(node), X_ACCESS, "eaccess", false);
|
|
3105
3245
|
} catch (err) {
|
|
3106
|
-
throw new ErrnoError(
|
|
3246
|
+
throw new ErrnoError(errnoOf2(err));
|
|
3107
3247
|
}
|
|
3108
3248
|
chdir.call(Fs, path);
|
|
3109
3249
|
};
|
|
@@ -3120,13 +3260,14 @@ function linuxDevices(Fs) {
|
|
|
3120
3260
|
}
|
|
3121
3261
|
}
|
|
3122
3262
|
}
|
|
3123
|
-
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_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE,
|
|
3263
|
+
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_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY2, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE3, O_CREAT, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, DEVICE_MODES;
|
|
3124
3264
|
var init_process_fds = __esm({
|
|
3125
3265
|
"src/process/process-fds.ts"() {
|
|
3126
3266
|
"use strict";
|
|
3127
3267
|
init_dev_removal();
|
|
3128
3268
|
init_loopback_names();
|
|
3129
3269
|
init_live_vfs_fs();
|
|
3270
|
+
init_process_locks();
|
|
3130
3271
|
init_process_pty();
|
|
3131
3272
|
init_wasi_errno();
|
|
3132
3273
|
O_CLOEXEC = 524288;
|
|
@@ -3169,12 +3310,12 @@ var init_process_fds = __esm({
|
|
|
3169
3310
|
PROT_WRITE = 2;
|
|
3170
3311
|
MAP_PRIVATE = 2;
|
|
3171
3312
|
MAP_TYPE = 15;
|
|
3172
|
-
|
|
3313
|
+
O_WRONLY2 = 1;
|
|
3173
3314
|
MAP_ALIGN = 65536;
|
|
3174
3315
|
DIR_MODE = 16749;
|
|
3175
3316
|
LINK_MODE = 41408;
|
|
3176
3317
|
CHAR_DEVICE = 8630;
|
|
3177
|
-
|
|
3318
|
+
O_ACCMODE3 = 3;
|
|
3178
3319
|
O_CREAT = 64;
|
|
3179
3320
|
field = (text) => (text || "none").replace(/[\s\\]/g, (c) => `\\${c.charCodeAt(0).toString(8).padStart(3, "0")}`);
|
|
3180
3321
|
rootKind = () => globalThis.navigator?.storage ? "opfs" : "memory";
|
|
@@ -3914,12 +4055,12 @@ function vfsPromoter(Fs, sys, streams, livePath) {
|
|
|
3914
4055
|
const version = ranged?.pinnedVersion;
|
|
3915
4056
|
const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
|
|
3916
4057
|
const handle = stream.node.live?.handle;
|
|
3917
|
-
const
|
|
4058
|
+
const held2 = { ...pin ? { pin } : {}, ...handle !== void 0 ? { handle } : {} };
|
|
3918
4059
|
kfd = sys.openVfs(
|
|
3919
4060
|
livePath(stream),
|
|
3920
4061
|
stream.flags,
|
|
3921
4062
|
stream.position,
|
|
3922
|
-
contents !== void 0 ? { contents, orphan: true } : Object.keys(
|
|
4063
|
+
contents !== void 0 ? { contents, orphan: true } : Object.keys(held2).length > 0 ? held2 : void 0
|
|
3923
4064
|
);
|
|
3924
4065
|
promoted.set(stream.shared, kfd);
|
|
3925
4066
|
}
|
|
@@ -3948,7 +4089,7 @@ function kernelEntry(stream, kernel) {
|
|
|
3948
4089
|
}
|
|
3949
4090
|
const device2 = stream.path === void 0 ? void 0 : NAMED_DEVICES[stream.path];
|
|
3950
4091
|
const kind = stream.sliccKernelFile ? "file" : stream.tty ? "tty" : device2 ?? "stream";
|
|
3951
|
-
const access = kind === "tty" ? O_RDWR : (stream.flags ?? O_RDWR) &
|
|
4092
|
+
const access = kind === "tty" ? O_RDWR : (stream.flags ?? O_RDWR) & O_ACCMODE4;
|
|
3952
4093
|
return { fd: stream.fd, kernel, kind, flags: access, ...cloexec };
|
|
3953
4094
|
}
|
|
3954
4095
|
function describeInherited(Fs, sys, streams, livePath, actions = []) {
|
|
@@ -3978,7 +4119,7 @@ function describeInherited(Fs, sys, streams, livePath, actions = []) {
|
|
|
3978
4119
|
function deviceOfStream(stream) {
|
|
3979
4120
|
const device2 = stream.path === void 0 ? void 0 : DEVICES[stream.path];
|
|
3980
4121
|
if (!device2 || stream.sliccKernelFd !== void 0) return void 0;
|
|
3981
|
-
const access = ACCESS[stream.flags &
|
|
4122
|
+
const access = ACCESS[stream.flags & O_ACCMODE4];
|
|
3982
4123
|
return { device: device2, ...access ? { access } : {} };
|
|
3983
4124
|
}
|
|
3984
4125
|
function inheritedSlot(fd, stream) {
|
|
@@ -4051,13 +4192,13 @@ function restoreForkedStreams(Fs, streams, table) {
|
|
|
4051
4192
|
}
|
|
4052
4193
|
}
|
|
4053
4194
|
}
|
|
4054
|
-
var O_RDWR,
|
|
4195
|
+
var O_RDWR, O_ACCMODE4, O_CREAT3, O_EXCL2, O_TRUNC3, PLACEHOLDER_DIR, NAMED_DEVICES, ACCESS, DEVICES, FIFO_MODE, nextStreamIno, streamInos;
|
|
4055
4196
|
var init_process_fork = __esm({
|
|
4056
4197
|
"src/process/process-fork.ts"() {
|
|
4057
4198
|
"use strict";
|
|
4058
4199
|
init_process_fds();
|
|
4059
4200
|
O_RDWR = 2;
|
|
4060
|
-
|
|
4201
|
+
O_ACCMODE4 = 3;
|
|
4061
4202
|
O_CREAT3 = 64;
|
|
4062
4203
|
O_EXCL2 = 128;
|
|
4063
4204
|
O_TRUNC3 = 512;
|
|
@@ -4527,7 +4668,7 @@ function socketNode(Fs, addr) {
|
|
|
4527
4668
|
const fs = Fs;
|
|
4528
4669
|
let stream;
|
|
4529
4670
|
try {
|
|
4530
|
-
stream = Fs.open(addr.path,
|
|
4671
|
+
stream = Fs.open(addr.path, O_WRONLY3 | O_CREAT4 | O_EXCL3, 493);
|
|
4531
4672
|
} catch (e) {
|
|
4532
4673
|
if (e?.errno === wasiErrno("EEXIST")) {
|
|
4533
4674
|
throw new SyscallError("EADDRINUSE");
|
|
@@ -4659,7 +4800,7 @@ function createSocketKernel(deps) {
|
|
|
4659
4800
|
})
|
|
4660
4801
|
};
|
|
4661
4802
|
}
|
|
4662
|
-
var O_RDWR2, KILLED_BY_SIGPIPE2,
|
|
4803
|
+
var O_RDWR2, KILLED_BY_SIGPIPE2, O_WRONLY3, O_CREAT4, O_EXCL3;
|
|
4663
4804
|
var init_process_sockets = __esm({
|
|
4664
4805
|
"src/process/process-sockets.ts"() {
|
|
4665
4806
|
"use strict";
|
|
@@ -4669,7 +4810,7 @@ var init_process_sockets = __esm({
|
|
|
4669
4810
|
init_wasi_errno();
|
|
4670
4811
|
O_RDWR2 = 2;
|
|
4671
4812
|
KILLED_BY_SIGPIPE2 = 128 + 13;
|
|
4672
|
-
|
|
4813
|
+
O_WRONLY3 = 1;
|
|
4673
4814
|
O_CREAT4 = 64;
|
|
4674
4815
|
O_EXCL3 = 128;
|
|
4675
4816
|
}
|
|
@@ -4703,7 +4844,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4703
4844
|
var init_version = __esm({
|
|
4704
4845
|
"src/version.ts"() {
|
|
4705
4846
|
"use strict";
|
|
4706
|
-
KERNEL_VERSION = true ? "1.97.
|
|
4847
|
+
KERNEL_VERSION = true ? "1.97.2" : "0.0.0-dev";
|
|
4707
4848
|
OS_RELEASE = "6.0.0-slicc";
|
|
4708
4849
|
}
|
|
4709
4850
|
});
|
|
@@ -5261,6 +5402,16 @@ function kernelSys(transport) {
|
|
|
5261
5402
|
mountList() {
|
|
5262
5403
|
return json2(call2({ op: "mount-list" }, "mount-list"));
|
|
5263
5404
|
},
|
|
5405
|
+
setLock(target, kind, start2, len, wait2) {
|
|
5406
|
+
const req = { op: "lk-set", ...target, kind, start: start2, len, ...wait2 ? { wait: wait2 } : {} };
|
|
5407
|
+
call2(req, "lk-set");
|
|
5408
|
+
},
|
|
5409
|
+
getLock(target, kind, start2, len) {
|
|
5410
|
+
return json2(call2({ op: "lk-get", ...target, kind, start: start2, len }, "lk-get"));
|
|
5411
|
+
},
|
|
5412
|
+
closeLocks(target) {
|
|
5413
|
+
call2({ op: "lk-close", ...target }, "lk-close");
|
|
5414
|
+
},
|
|
5264
5415
|
ptyNumber(fd) {
|
|
5265
5416
|
return json2(call2({ op: "pty-number", fd }, `pty-number ${fd}`));
|
|
5266
5417
|
},
|
|
@@ -5290,7 +5441,7 @@ function openDevice(Fs, fd, meta) {
|
|
|
5290
5441
|
return openAt(Fs, fd, `/dev/${meta.device}`, accessMode(meta.access));
|
|
5291
5442
|
}
|
|
5292
5443
|
function openHeld(Fs, fd, meta) {
|
|
5293
|
-
return "dir" in meta ? openAt(Fs, fd, meta.dir,
|
|
5444
|
+
return "dir" in meta ? openAt(Fs, fd, meta.dir, O_RDONLY2 | O_DIRECTORY2) : openDevice(Fs, fd, meta);
|
|
5294
5445
|
}
|
|
5295
5446
|
function openAt(Fs, fd, path, flags) {
|
|
5296
5447
|
let stream;
|
|
@@ -5313,7 +5464,7 @@ function wireKernelStdio(Fs, streams, sys) {
|
|
|
5313
5464
|
const meta = kind === "device" || kind === "held" ? sys?.heldMeta?.(fd) : void 0;
|
|
5314
5465
|
if (meta && openHeld(Fs, fd, meta)) continue;
|
|
5315
5466
|
if (kind && PLACED.has(kind)) {
|
|
5316
|
-
const flags = sys?.access ? stream.flags & ~
|
|
5467
|
+
const flags = sys?.access ? stream.flags & ~O_ACCMODE5 | accessMode(sys.access(fd)) : stream.flags;
|
|
5317
5468
|
Fs.closeStream(fd);
|
|
5318
5469
|
const kernel = { fd, kernel: fd, kind, flags };
|
|
5319
5470
|
placeKernelStream(Fs, streams, kernel).flags = flags;
|
|
@@ -5465,6 +5616,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
5465
5616
|
fs: () => ownValue(module, "FS"),
|
|
5466
5617
|
heap: () => memory ? new Int32Array(memory.buffer) : void 0,
|
|
5467
5618
|
pty: sys,
|
|
5619
|
+
locks: { kernel: sys, memory: () => memory?.buffer, flush: () => early() },
|
|
5468
5620
|
timer: {
|
|
5469
5621
|
arm: (ms) => {
|
|
5470
5622
|
transport.call(
|
|
@@ -5522,6 +5674,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
5522
5674
|
cred: init.owners ? init.cred : void 0
|
|
5523
5675
|
});
|
|
5524
5676
|
early = () => signals.quiet(() => vfs.flushDirty());
|
|
5677
|
+
closeDropsLocks(running.FS, sys);
|
|
5525
5678
|
const sigpipe = () => running.sliccSigpipe?.() === 1;
|
|
5526
5679
|
const restartable = () => signals.restartable();
|
|
5527
5680
|
const owners = init.owners ? { owners: true } : {};
|
|
@@ -5538,7 +5691,6 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
5538
5691
|
atExit = () => streams.exiting();
|
|
5539
5692
|
useMounts(running.FS, init.env, true);
|
|
5540
5693
|
useZeroDevices(running.FS);
|
|
5541
|
-
useDevRemoval(running.FS);
|
|
5542
5694
|
useProcfs(running.FS, sys, init.pid);
|
|
5543
5695
|
if (init.fork) restoreForkedStreams(running.FS, streams, init.fork.streams ?? []);
|
|
5544
5696
|
else {
|
|
@@ -5550,6 +5702,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
5550
5702
|
streams.useControllingTerminal();
|
|
5551
5703
|
streams.useKernelFdMetadata();
|
|
5552
5704
|
useDevFd(running.FS);
|
|
5705
|
+
useDevRemoval(running.FS);
|
|
5553
5706
|
useFileMmap(running.FS, {
|
|
5554
5707
|
sys,
|
|
5555
5708
|
memory: () => memory,
|
|
@@ -5649,7 +5802,7 @@ function runMain(running, init) {
|
|
|
5649
5802
|
return status2;
|
|
5650
5803
|
}
|
|
5651
5804
|
}
|
|
5652
|
-
var FS_OPS,
|
|
5805
|
+
var FS_OPS, O_RDONLY2, O_WRONLY4, O_RDWR3, O_ACCMODE5, O_DIRECTORY2, accessMode, PLACED, GLUE_TRAILER, evaluateGlue, EVAL_BLOCKED;
|
|
5653
5806
|
var init_process_runtime = __esm({
|
|
5654
5807
|
"src/process/process-runtime.ts"() {
|
|
5655
5808
|
"use strict";
|
|
@@ -5665,18 +5818,19 @@ var init_process_runtime = __esm({
|
|
|
5665
5818
|
init_process_fds();
|
|
5666
5819
|
init_process_fork();
|
|
5667
5820
|
init_process_http();
|
|
5821
|
+
init_process_locks();
|
|
5668
5822
|
init_process_signals();
|
|
5669
5823
|
init_process_sockets();
|
|
5670
5824
|
init_procfs();
|
|
5671
5825
|
init_realm_user();
|
|
5672
5826
|
init_kernel_streams();
|
|
5673
5827
|
FS_OPS = new Set(SYNC_FS_OPS);
|
|
5674
|
-
|
|
5675
|
-
|
|
5828
|
+
O_RDONLY2 = 0;
|
|
5829
|
+
O_WRONLY4 = 1;
|
|
5676
5830
|
O_RDWR3 = 2;
|
|
5677
|
-
|
|
5831
|
+
O_ACCMODE5 = 3;
|
|
5678
5832
|
O_DIRECTORY2 = 65536;
|
|
5679
|
-
accessMode = (access) => access === "read" ?
|
|
5833
|
+
accessMode = (access) => access === "read" ? O_RDONLY2 : access === "write" ? O_WRONLY4 : O_RDWR3;
|
|
5680
5834
|
PLACED = /* @__PURE__ */ new Set(["stream", "file", "socket", "clipboard", "sealed"]);
|
|
5681
5835
|
GLUE_TRAILER = [
|
|
5682
5836
|
"if (typeof ENV !== 'undefined') Object.assign(ENV, Module.sliccEnv);",
|
|
@@ -6498,7 +6652,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
6498
6652
|
op: "fd-promote",
|
|
6499
6653
|
fd,
|
|
6500
6654
|
path: f.path,
|
|
6501
|
-
flags: (f.writable ? f.readable ? O_RDWR4 :
|
|
6655
|
+
flags: (f.writable ? f.readable ? O_RDWR4 : O_WRONLY5 : 0) | (f.append ? O_APPEND2 : 0),
|
|
6502
6656
|
position: f.offset,
|
|
6503
6657
|
...joins ? {} : { contents: f.buffer.contents() },
|
|
6504
6658
|
...orphan ? { orphan: true } : {},
|
|
@@ -6507,7 +6661,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
6507
6661
|
...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {}
|
|
6508
6662
|
};
|
|
6509
6663
|
}
|
|
6510
|
-
var SYNTHETIC_DIRS2, O_NONBLOCK2,
|
|
6664
|
+
var SYNTHETIC_DIRS2, O_NONBLOCK2, O_WRONLY5, O_RDWR4, O_APPEND2, SEALED_PATH2, CLIPBOARD_PATH2, WasiFds, GEN2;
|
|
6511
6665
|
var init_wasi_fds = __esm({
|
|
6512
6666
|
"src/process/wasi/wasi-fds.ts"() {
|
|
6513
6667
|
"use strict";
|
|
@@ -6517,7 +6671,7 @@ var init_wasi_fds = __esm({
|
|
|
6517
6671
|
init_wasi_files();
|
|
6518
6672
|
SYNTHETIC_DIRS2 = ["usr", "bin"];
|
|
6519
6673
|
O_NONBLOCK2 = 2048;
|
|
6520
|
-
|
|
6674
|
+
O_WRONLY5 = 1;
|
|
6521
6675
|
O_RDWR4 = 2;
|
|
6522
6676
|
O_APPEND2 = 1024;
|
|
6523
6677
|
SEALED_PATH2 = "/dev/sealed";
|
|
@@ -7040,7 +7194,7 @@ var init_wasi_fds = __esm({
|
|
|
7040
7194
|
if (oflags & OFLAGS.DIRECTORY) throw new WasiError("ENOTDIR");
|
|
7041
7195
|
if (oflags & OFLAGS.CREAT && oflags & OFLAGS.EXCL) throw new WasiError("EEXIST");
|
|
7042
7196
|
const want = wantOf2(oflags, rights);
|
|
7043
|
-
const flags = want === 6 ? O_RDWR4 : want === 2 ?
|
|
7197
|
+
const flags = want === 6 ? O_RDWR4 : want === 2 ? O_WRONLY5 : 0;
|
|
7044
7198
|
return openDevice2.call(this.kernel.sys, flags);
|
|
7045
7199
|
}
|
|
7046
7200
|
open(path, oflags, rights, fdflags) {
|
|
@@ -7140,7 +7294,7 @@ var init_wasi_fds = __esm({
|
|
|
7140
7294
|
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
7141
7295
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
7142
7296
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
7143
|
-
const flags = (writable2 ? readable3 ? O_RDWR4 :
|
|
7297
|
+
const flags = (writable2 ? readable3 ? O_RDWR4 : O_WRONLY5 : 0) | (append ? O_APPEND2 : 0);
|
|
7144
7298
|
const made = !existing && this.createNew(path, oflags);
|
|
7145
7299
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
7146
7300
|
const fd = this.kernel.sys.openVfs(path, flags, 0, {
|
|
@@ -8868,14 +9022,14 @@ function restarted2(issue) {
|
|
|
8868
9022
|
function resolveFrom(cwd, path) {
|
|
8869
9023
|
return normalize(path.startsWith("/") ? path : `${cwd}/${path}`);
|
|
8870
9024
|
}
|
|
8871
|
-
var
|
|
9025
|
+
var O_WRONLY6, O_RDWR5, O_APPEND3, OFLAG_CREAT, OFLAG_TRUNC, JOIN_NON_BLOCKING, JOIN_WAKE_STOPPED, JOIN_STOPPED, WasixProcess;
|
|
8872
9026
|
var init_wasix_process = __esm({
|
|
8873
9027
|
"src/process/wasi/wasix-process.ts"() {
|
|
8874
9028
|
"use strict";
|
|
8875
9029
|
init_physical_path();
|
|
8876
9030
|
init_wasi_files();
|
|
8877
9031
|
init_wasi_host();
|
|
8878
|
-
|
|
9032
|
+
O_WRONLY6 = 1;
|
|
8879
9033
|
O_RDWR5 = 2;
|
|
8880
9034
|
O_APPEND3 = 1024;
|
|
8881
9035
|
OFLAG_CREAT = 1;
|
|
@@ -8977,7 +9131,7 @@ var init_wasix_process = __esm({
|
|
|
8977
9131
|
throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
|
|
8978
9132
|
}
|
|
8979
9133
|
const flags = (op.rightsWrite ? O_RDWR5 : 0) | (op.append ? O_APPEND3 : 0);
|
|
8980
|
-
return this.host.o.kernel.sys.openVfs(path, op.rightsWrite ? flags ||
|
|
9134
|
+
return this.host.o.kernel.sys.openVfs(path, op.rightsWrite ? flags || O_WRONLY6 : 0, 0, {
|
|
8981
9135
|
...create ? { create } : {},
|
|
8982
9136
|
...op.oflags & OFLAG_TRUNC ? { truncate: true } : {}
|
|
8983
9137
|
});
|
|
@@ -9535,10 +9689,10 @@ function procfsBridge(fs, tree) {
|
|
|
9535
9689
|
],
|
|
9536
9690
|
() => fs.link(from, to, follow2)
|
|
9537
9691
|
),
|
|
9538
|
-
hold: (p,
|
|
9692
|
+
hold: (p, held2, open, handle, want) => {
|
|
9539
9693
|
if (handle !== void 0 && snapshots.delete(handle)) return void 0;
|
|
9540
|
-
if (!
|
|
9541
|
-
return via(p, snapshot, () => fs.hold?.(p,
|
|
9694
|
+
if (!held2) return fs.hold?.(p, held2, open, handle);
|
|
9695
|
+
return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want) ?? late(p));
|
|
9542
9696
|
},
|
|
9543
9697
|
kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
|
|
9544
9698
|
pinned: (handle) => {
|
|
@@ -11652,12 +11806,12 @@ function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
|
11652
11806
|
const wasix = imports.some((i) => i.module === WASIX);
|
|
11653
11807
|
const wasi = wasix || imports.some((i) => i.module === PREVIEW1);
|
|
11654
11808
|
const scope2 = { extended, wasi, wasix, pie: dylinkInfo(module) !== void 0, memory };
|
|
11655
|
-
const
|
|
11656
|
-
if (
|
|
11657
|
-
if (
|
|
11658
|
-
return `imports ${
|
|
11809
|
+
const refused2 = imports.find((imp) => !accepted(imp, scope2));
|
|
11810
|
+
if (refused2) {
|
|
11811
|
+
if (refused2.kind === "memory" || refused2.module === "wasi") {
|
|
11812
|
+
return `imports ${refused2.module}.${refused2.name}: no WASI program this host runs`;
|
|
11659
11813
|
}
|
|
11660
|
-
return `imports ${
|
|
11814
|
+
return `imports ${refused2.module}.${refused2.name}: no WASI preview1 program (an Emscripten one runs with its glue)`;
|
|
11661
11815
|
}
|
|
11662
11816
|
const unanswerable = extended ? void 0 : firstOther(foreign);
|
|
11663
11817
|
if (unanswerable) return noErrno(unanswerable);
|
|
@@ -11718,7 +11872,7 @@ function fillMemory(memory, copy2) {
|
|
|
11718
11872
|
if (pages2 > 0) memory.grow(pages2);
|
|
11719
11873
|
new Uint8Array(memory.buffer).set(copy2);
|
|
11720
11874
|
}
|
|
11721
|
-
function
|
|
11875
|
+
function sizeOf2(main) {
|
|
11722
11876
|
return () => main.memory?.buffer.byteLength ?? 0;
|
|
11723
11877
|
}
|
|
11724
11878
|
function memoryOf(instance, imported) {
|
|
@@ -11912,19 +12066,19 @@ async function runWasiProcess(init, port2) {
|
|
|
11912
12066
|
call: kernelCall,
|
|
11913
12067
|
say,
|
|
11914
12068
|
gate
|
|
11915
|
-
} = kernelOf(init, port2, signals,
|
|
12069
|
+
} = kernelOf(init, port2, signals, sizeOf2(main));
|
|
11916
12070
|
const id = identify(transport, init);
|
|
11917
12071
|
const stats = init.env.SLICC_WASI_STATS === "1" ? new WasiStats() : void 0;
|
|
11918
12072
|
const call2 = stats ? timedCalls(stats, kernelCall) : kernelCall;
|
|
11919
12073
|
const { module } = init.program;
|
|
11920
|
-
const
|
|
12074
|
+
const refused2 = unsupportedImport(
|
|
11921
12075
|
module,
|
|
11922
12076
|
init.program.memory,
|
|
11923
12077
|
init.program.imports !== void 0,
|
|
11924
12078
|
init.program.foreign
|
|
11925
12079
|
);
|
|
11926
|
-
if (
|
|
11927
|
-
say(
|
|
12080
|
+
if (refused2) {
|
|
12081
|
+
say(refused2);
|
|
11928
12082
|
return 126;
|
|
11929
12083
|
}
|
|
11930
12084
|
const fork = init.fork?.wasi;
|
|
@@ -11965,7 +12119,7 @@ async function runWasiProcess(init, port2) {
|
|
|
11965
12119
|
});
|
|
11966
12120
|
restoreExportedMemory(instance, memory, init);
|
|
11967
12121
|
main.memory = memoryOf(instance, memory);
|
|
11968
|
-
publishMemory(init.sab,
|
|
12122
|
+
publishMemory(init.sab, sizeOf2(main)());
|
|
11969
12123
|
signals.bind(instance.exports);
|
|
11970
12124
|
if (importsSigactionHook(module)) signals.useHook();
|
|
11971
12125
|
if (fork?.signals) signals.restore(fork.signals);
|
|
@@ -12778,7 +12932,7 @@ function checkOpen(abs, o, existing) {
|
|
|
12778
12932
|
}
|
|
12779
12933
|
function flagsOf(o) {
|
|
12780
12934
|
const write2 = o.write || o.append || o.truncate;
|
|
12781
|
-
const access = write2 ? o.read ? O_RDWR6 :
|
|
12935
|
+
const access = write2 ? o.read ? O_RDWR6 : O_WRONLY7 : 0;
|
|
12782
12936
|
return access | (o.append ? O_APPEND4 : 0);
|
|
12783
12937
|
}
|
|
12784
12938
|
function openRequest2(abs, o) {
|
|
@@ -12795,7 +12949,7 @@ function openRequest2(abs, o) {
|
|
|
12795
12949
|
function index2(n, what) {
|
|
12796
12950
|
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
12797
12951
|
}
|
|
12798
|
-
var CHUNK, MAX_IO,
|
|
12952
|
+
var CHUNK, MAX_IO, O_WRONLY7, O_RDWR6, O_APPEND4, BLOCK;
|
|
12799
12953
|
var init_js_io = __esm({
|
|
12800
12954
|
"src/process/js/js-io.ts"() {
|
|
12801
12955
|
"use strict";
|
|
@@ -12803,7 +12957,7 @@ var init_js_io = __esm({
|
|
|
12803
12957
|
init_js_kernel();
|
|
12804
12958
|
CHUNK = 64 * 1024;
|
|
12805
12959
|
MAX_IO = 1024 * 1024;
|
|
12806
|
-
|
|
12960
|
+
O_WRONLY7 = 1;
|
|
12807
12961
|
O_RDWR6 = 2;
|
|
12808
12962
|
O_APPEND4 = 1024;
|
|
12809
12963
|
BLOCK = 4096;
|
|
@@ -15306,17 +15460,17 @@ function processEntry(port2, run = runWasmProcess, wasi = loadWasi, js = loadJs,
|
|
|
15306
15460
|
message: err instanceof Error ? err.stack ?? err.message : String(err),
|
|
15307
15461
|
...code2 === void 0 ? {} : { code: code2 }
|
|
15308
15462
|
});
|
|
15309
|
-
let
|
|
15463
|
+
let refused2;
|
|
15310
15464
|
const sealOnce = () => {
|
|
15311
|
-
if (
|
|
15465
|
+
if (refused2 === void 0) {
|
|
15312
15466
|
try {
|
|
15313
15467
|
seal();
|
|
15314
|
-
|
|
15468
|
+
refused2 = null;
|
|
15315
15469
|
} catch (error) {
|
|
15316
|
-
|
|
15470
|
+
refused2 = { error };
|
|
15317
15471
|
}
|
|
15318
15472
|
}
|
|
15319
|
-
return
|
|
15473
|
+
return refused2;
|
|
15320
15474
|
};
|
|
15321
15475
|
return (data) => {
|
|
15322
15476
|
const type = data?.type;
|