@ai-ecoverse/slicc-kernel 1.107.1 → 1.108.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 +8 -2
- package/dist/kernel-worker.js +27 -5
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +191 -166
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +27 -5
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +191 -166
- package/dist/process-worker.js.map +4 -4
- package/dist/types/kernel/children.d.ts +3 -0
- package/dist/types/kernel/process.d.ts +6 -0
- package/dist/types/process/process-signals.d.ts +8 -6
- package/dist/types/process/wasi/wasi-fds.d.ts +1 -1
- package/dist/types/process/wasi/wasi-host.d.ts +1 -1
- package/dist/types/process/wasi/wasi-signals.d.ts +4 -7
- package/package.json +1 -1
|
@@ -2497,7 +2497,7 @@ var init_wasi_fds = __esm({
|
|
|
2497
2497
|
const flags = want === 6 ? O_RDWR : want === 2 ? O_WRONLY : 0;
|
|
2498
2498
|
return openDevice2.call(this.kernel.sys, flags);
|
|
2499
2499
|
}
|
|
2500
|
-
open(path, oflags, rights, fdflags) {
|
|
2500
|
+
open(path, oflags, rights, fdflags, mode) {
|
|
2501
2501
|
const device2 = deviceOf(path);
|
|
2502
2502
|
if (device2) return this.install({ type: "device", device: device2 });
|
|
2503
2503
|
const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
|
|
@@ -2518,13 +2518,16 @@ var init_wasi_fds = __esm({
|
|
|
2518
2518
|
}
|
|
2519
2519
|
if (!s && !(oflags & OFLAGS.CREAT)) throw new WasiError("ENOENT");
|
|
2520
2520
|
refuseWrite(s, oflags, rights);
|
|
2521
|
-
return this.regular(path, s, oflags, rights, fdflags);
|
|
2521
|
+
return this.regular(path, s, oflags, rights, fdflags, mode);
|
|
2522
2522
|
}
|
|
2523
|
-
regular(path, s, oflags, rights, fdflags) {
|
|
2523
|
+
regular(path, s, oflags, rights, fdflags, mode) {
|
|
2524
2524
|
if (this.shared || this.kernelHolds(path, s)) {
|
|
2525
|
-
return this.kernelFile(path, s, oflags, rights, fdflags);
|
|
2525
|
+
return this.kernelFile(path, s, oflags, rights, fdflags, mode);
|
|
2526
2526
|
}
|
|
2527
|
-
return this.install({
|
|
2527
|
+
return this.install({
|
|
2528
|
+
type: "file",
|
|
2529
|
+
file: this.file(path, s, oflags, rights, fdflags, mode)
|
|
2530
|
+
});
|
|
2528
2531
|
}
|
|
2529
2532
|
kernelHolds(path, st) {
|
|
2530
2533
|
for (const [fd, e] of this.table) {
|
|
@@ -2546,7 +2549,7 @@ var init_wasi_fds = __esm({
|
|
|
2546
2549
|
} catch {
|
|
2547
2550
|
}
|
|
2548
2551
|
}
|
|
2549
|
-
file(path, existing, oflags, rights, fdflags) {
|
|
2552
|
+
file(path, existing, oflags, rights, fdflags, mode) {
|
|
2550
2553
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
2551
2554
|
let buffer = this.buffers.get(path);
|
|
2552
2555
|
if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
|
|
@@ -2559,13 +2562,13 @@ var init_wasi_fds = __esm({
|
|
|
2559
2562
|
if (this.fs.owners) this.fs.access?.(path, want, "open");
|
|
2560
2563
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
2561
2564
|
} else {
|
|
2562
|
-
buffer = this.freshBuffer(path, existing, oflags, want);
|
|
2565
|
+
buffer = this.freshBuffer(path, existing, oflags, want, mode);
|
|
2563
2566
|
}
|
|
2564
2567
|
buffer.opens++;
|
|
2565
2568
|
return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
2566
2569
|
}
|
|
2567
|
-
freshBuffer(path, existing, oflags, want) {
|
|
2568
|
-
const made = !existing && this.createNew(path, oflags);
|
|
2570
|
+
freshBuffer(path, existing, oflags, want, mode) {
|
|
2571
|
+
const made = !existing && this.createNew(path, oflags, mode);
|
|
2569
2572
|
const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
2570
2573
|
if (existing?.ranged) this.fs.invalidate?.();
|
|
2571
2574
|
const seen = this.fs.changes?.now();
|
|
@@ -2595,11 +2598,11 @@ var init_wasi_fds = __esm({
|
|
|
2595
2598
|
if (id !== void 0) this.know(buffer, id);
|
|
2596
2599
|
return buffer;
|
|
2597
2600
|
}
|
|
2598
|
-
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
2601
|
+
kernelFile(path, existing, oflags, rights, fdflags, mode) {
|
|
2599
2602
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
2600
2603
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
2601
2604
|
const flags = (writable2 ? readable3 ? O_RDWR : O_WRONLY : 0) | (append ? O_APPEND : 0);
|
|
2602
|
-
const made = !existing && this.createNew(path, oflags);
|
|
2605
|
+
const made = !existing && this.createNew(path, oflags, mode);
|
|
2603
2606
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
2604
2607
|
const fd = this.kernel.sys.openVfs(path, flags, 0, {
|
|
2605
2608
|
...truncate ? { truncate } : {},
|
|
@@ -2612,13 +2615,13 @@ var init_wasi_fds = __esm({
|
|
|
2612
2615
|
this.bump();
|
|
2613
2616
|
return fd;
|
|
2614
2617
|
}
|
|
2615
|
-
createNew(path, oflags) {
|
|
2618
|
+
createNew(path, oflags, mode) {
|
|
2616
2619
|
if (!this.fs.create) {
|
|
2617
2620
|
this.fs.writeFile(path, new Uint8Array(0));
|
|
2618
2621
|
return true;
|
|
2619
2622
|
}
|
|
2620
2623
|
try {
|
|
2621
|
-
this.fs.create(path,
|
|
2624
|
+
this.fs.create(path, mode, true);
|
|
2622
2625
|
return true;
|
|
2623
2626
|
} catch (err) {
|
|
2624
2627
|
if (oflags & OFLAGS.EXCL || err.code !== "EEXIST") throw err;
|
|
@@ -2856,6 +2859,136 @@ var init_wasi_poll = __esm({
|
|
|
2856
2859
|
}
|
|
2857
2860
|
});
|
|
2858
2861
|
|
|
2862
|
+
// src/process/wasi/wasi-sigmask.ts
|
|
2863
|
+
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER, NS_PER_MS2, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
2864
|
+
var init_wasi_sigmask = __esm({
|
|
2865
|
+
"src/process/wasi/wasi-sigmask.ts"() {
|
|
2866
|
+
"use strict";
|
|
2867
|
+
init_signals();
|
|
2868
|
+
init_sync_sab_wire();
|
|
2869
|
+
init_wasi_abi();
|
|
2870
|
+
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
2871
|
+
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
2872
|
+
FOREVER = 0xffffffffffffffffn;
|
|
2873
|
+
NS_PER_MS2 = 1000000n;
|
|
2874
|
+
POLL_MS = 50;
|
|
2875
|
+
SIG_BLOCK = 0;
|
|
2876
|
+
SIG_UNBLOCK = 1;
|
|
2877
|
+
SIG_SETMASK = 2;
|
|
2878
|
+
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
2879
|
+
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
2880
|
+
apply = (how, mask, set) => {
|
|
2881
|
+
if (how === SIG_BLOCK) return mask | set;
|
|
2882
|
+
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
2883
|
+
return set;
|
|
2884
|
+
};
|
|
2885
|
+
WasiSigmask = class {
|
|
2886
|
+
lo;
|
|
2887
|
+
hi;
|
|
2888
|
+
header;
|
|
2889
|
+
deliver;
|
|
2890
|
+
process;
|
|
2891
|
+
tid;
|
|
2892
|
+
constructor(header, deliver, process, tid = 1) {
|
|
2893
|
+
this.header = header;
|
|
2894
|
+
this.deliver = deliver;
|
|
2895
|
+
this.process = process;
|
|
2896
|
+
this.tid = tid;
|
|
2897
|
+
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
2898
|
+
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
2899
|
+
}
|
|
2900
|
+
static unsupported(header) {
|
|
2901
|
+
storeBlocked(header, [0, 0]);
|
|
2902
|
+
}
|
|
2903
|
+
set(how, setLo, setHi, old) {
|
|
2904
|
+
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
2905
|
+
old(this.lo >>> 0, this.hi >>> 0);
|
|
2906
|
+
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
2907
|
+
this.hi = apply(how, this.hi, setHi | 0);
|
|
2908
|
+
const now = kernelBits(this.lo);
|
|
2909
|
+
storeBlocked(this.header, [now, this.hi]);
|
|
2910
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
2911
|
+
return E.SUCCESS;
|
|
2912
|
+
}
|
|
2913
|
+
swap(setLo, setHi) {
|
|
2914
|
+
const old = [this.lo, this.hi];
|
|
2915
|
+
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
2916
|
+
this.hi = setHi | 0;
|
|
2917
|
+
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
2918
|
+
return old;
|
|
2919
|
+
}
|
|
2920
|
+
deliverUnblocked() {
|
|
2921
|
+
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
2922
|
+
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
2923
|
+
this.deliver();
|
|
2924
|
+
return true;
|
|
2925
|
+
}
|
|
2926
|
+
restore([lo, hi]) {
|
|
2927
|
+
this.set(SIG_SETMASK, lo, hi, () => {
|
|
2928
|
+
});
|
|
2929
|
+
}
|
|
2930
|
+
blockedBits() {
|
|
2931
|
+
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
2932
|
+
}
|
|
2933
|
+
blocks(sig) {
|
|
2934
|
+
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
2935
|
+
}
|
|
2936
|
+
inherited() {
|
|
2937
|
+
return [kernelBits(this.lo), this.hi];
|
|
2938
|
+
}
|
|
2939
|
+
discard(sig) {
|
|
2940
|
+
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
2941
|
+
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
2942
|
+
}
|
|
2943
|
+
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
2944
|
+
const set = kernelBits(setLo | 0);
|
|
2945
|
+
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
2946
|
+
const deadline = value2 === FOREVER ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS2 - 1n) / NS_PER_MS2);
|
|
2947
|
+
publish(set);
|
|
2948
|
+
try {
|
|
2949
|
+
for (; ; ) {
|
|
2950
|
+
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
2951
|
+
const sig = this.take(set);
|
|
2952
|
+
if (sig !== 0) {
|
|
2953
|
+
took(sig);
|
|
2954
|
+
return E.SUCCESS;
|
|
2955
|
+
}
|
|
2956
|
+
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
2957
|
+
const left = deadline - performance.now();
|
|
2958
|
+
if (left <= 0) return E.AGAIN;
|
|
2959
|
+
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
2960
|
+
}
|
|
2961
|
+
} finally {
|
|
2962
|
+
publish(0);
|
|
2963
|
+
}
|
|
2964
|
+
}
|
|
2965
|
+
take(set) {
|
|
2966
|
+
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
2967
|
+
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
2968
|
+
if (ready === 0) continue;
|
|
2969
|
+
const bit = ready & -ready;
|
|
2970
|
+
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
2971
|
+
}
|
|
2972
|
+
return 0;
|
|
2973
|
+
}
|
|
2974
|
+
interrupted() {
|
|
2975
|
+
const killed = this.process ?? this.header;
|
|
2976
|
+
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
2977
|
+
this.deliver();
|
|
2978
|
+
return true;
|
|
2979
|
+
}
|
|
2980
|
+
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
2981
|
+
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
2982
|
+
return true;
|
|
2983
|
+
}
|
|
2984
|
+
pending() {
|
|
2985
|
+
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
2986
|
+
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
2987
|
+
}
|
|
2988
|
+
};
|
|
2989
|
+
}
|
|
2990
|
+
});
|
|
2991
|
+
|
|
2859
2992
|
// src/process/wasi/wasi-termios.ts
|
|
2860
2993
|
function writeTermios(mem, ptr, termios) {
|
|
2861
2994
|
mem.bytes(ptr, OSPEED + 4).fill(0);
|
|
@@ -2934,8 +3067,8 @@ var init_wasi_termios = __esm({
|
|
|
2934
3067
|
// src/process/wasi/wasix-epoll.ts
|
|
2935
3068
|
function timeoutMs(ns) {
|
|
2936
3069
|
const value2 = BigInt.asUintN(64, ns);
|
|
2937
|
-
if (value2 ===
|
|
2938
|
-
const ms = (value2 +
|
|
3070
|
+
if (value2 === FOREVER2) return -1;
|
|
3071
|
+
const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
|
|
2939
3072
|
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
2940
3073
|
}
|
|
2941
3074
|
function wasixEpollImports(host) {
|
|
@@ -2996,7 +3129,7 @@ function wasixEpollImports(host) {
|
|
|
2996
3129
|
}
|
|
2997
3130
|
};
|
|
2998
3131
|
}
|
|
2999
|
-
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS,
|
|
3132
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER2, MAX_TIMEOUT_MS, NS_PER_MS3, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, WASIX_OPS, DUAL_OPS;
|
|
3000
3133
|
var init_wasix_epoll = __esm({
|
|
3001
3134
|
"src/process/wasi/wasix-epoll.ts"() {
|
|
3002
3135
|
"use strict";
|
|
@@ -3006,9 +3139,9 @@ var init_wasix_epoll = __esm({
|
|
|
3006
3139
|
DATA_OFFSET = 8;
|
|
3007
3140
|
DATA_SIZE = 24;
|
|
3008
3141
|
MAX_EVENTS = 4096;
|
|
3009
|
-
|
|
3142
|
+
FOREVER2 = 0xffffffffffffffffn;
|
|
3010
3143
|
MAX_TIMEOUT_MS = 2147483647;
|
|
3011
|
-
|
|
3144
|
+
NS_PER_MS3 = 1000000n;
|
|
3012
3145
|
EVENTFD_SEMAPHORE = 1;
|
|
3013
3146
|
EVENTFD_NONBLOCK = 4;
|
|
3014
3147
|
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
@@ -3449,7 +3582,7 @@ function filestatOf(path, s) {
|
|
|
3449
3582
|
size: BigInt(s.size),
|
|
3450
3583
|
ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
|
|
3451
3584
|
...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
|
|
3452
|
-
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) *
|
|
3585
|
+
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS4
|
|
3453
3586
|
};
|
|
3454
3587
|
}
|
|
3455
3588
|
function kernelFiletype(kind) {
|
|
@@ -3499,7 +3632,7 @@ function wrap(table) {
|
|
|
3499
3632
|
}
|
|
3500
3633
|
return out;
|
|
3501
3634
|
}
|
|
3502
|
-
var WasiExit, IDS,
|
|
3635
|
+
var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
3503
3636
|
var init_wasi_host = __esm({
|
|
3504
3637
|
"src/process/wasi/wasi-host.ts"() {
|
|
3505
3638
|
"use strict";
|
|
@@ -3516,6 +3649,7 @@ var init_wasi_host = __esm({
|
|
|
3516
3649
|
init_wasi_files();
|
|
3517
3650
|
init_wasi_memory();
|
|
3518
3651
|
init_wasi_poll();
|
|
3652
|
+
init_wasi_sigmask();
|
|
3519
3653
|
init_wasi_termios();
|
|
3520
3654
|
init_wasix_epoll();
|
|
3521
3655
|
init_wasix_sockets();
|
|
@@ -3527,14 +3661,14 @@ var init_wasi_host = __esm({
|
|
|
3527
3661
|
}
|
|
3528
3662
|
};
|
|
3529
3663
|
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
3530
|
-
|
|
3664
|
+
NS_PER_MS4 = 1000000n;
|
|
3531
3665
|
AT_SYMLINK_NOFOLLOW = 1;
|
|
3532
3666
|
AT_EACCESS = 2;
|
|
3533
3667
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
3534
3668
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
3535
3669
|
S_IFIFO = 4096;
|
|
3536
3670
|
DEFAULT_UMASK = 18;
|
|
3537
|
-
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) *
|
|
3671
|
+
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
|
|
3538
3672
|
MAX_READ = 1024 * 1024;
|
|
3539
3673
|
SIGPIPE_EXIT = 128 + SIG.PIPE;
|
|
3540
3674
|
SIG_IGN = 1;
|
|
@@ -3811,6 +3945,11 @@ var init_wasi_host = __esm({
|
|
|
3811
3945
|
this.entered
|
|
3812
3946
|
);
|
|
3813
3947
|
},
|
|
3948
|
+
sigaction_inherited: (out) => {
|
|
3949
|
+
const bits = this.o.kernel.call({ op: "sig-inherited" });
|
|
3950
|
+
mem.view().setBigUint64(out, BigInt(libcBits(bits) >>> 0), true);
|
|
3951
|
+
return E.SUCCESS;
|
|
3952
|
+
},
|
|
3814
3953
|
sigpending_get: (out) => {
|
|
3815
3954
|
if (!this.sigmask) return E.NOSYS;
|
|
3816
3955
|
mem.view().setBigUint64(out, BigInt(this.sigmask.pending()), true);
|
|
@@ -3890,7 +4029,7 @@ var init_wasi_host = __esm({
|
|
|
3890
4029
|
return this.cache;
|
|
3891
4030
|
}
|
|
3892
4031
|
now(id) {
|
|
3893
|
-
if (id === CLOCK.REALTIME) return BigInt(Date.now()) *
|
|
4032
|
+
if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS4;
|
|
3894
4033
|
if (id === CLOCK.MONOTONIC) {
|
|
3895
4034
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
3896
4035
|
}
|
|
@@ -4431,7 +4570,7 @@ var init_wasi_host = __esm({
|
|
|
4431
4570
|
current ??= statOf(path);
|
|
4432
4571
|
return current[field2] ?? current.mtimeMs ?? now;
|
|
4433
4572
|
};
|
|
4434
|
-
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 /
|
|
4573
|
+
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
|
|
4435
4574
|
(follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
|
|
4436
4575
|
this.o.fs,
|
|
4437
4576
|
path,
|
|
@@ -4761,13 +4900,15 @@ function importsContext({
|
|
|
4761
4900
|
const fds = {
|
|
4762
4901
|
open(path, o = {}) {
|
|
4763
4902
|
const abs = host.fds.resolve(3, path);
|
|
4764
|
-
|
|
4903
|
+
const fresh = o.create === true && o.exclusive === true && owners && fs.create !== void 0;
|
|
4904
|
+
if (!fresh && o.nofollow && fs.exists(abs) && fs.lstat(abs).isSymbolicLink)
|
|
4765
4905
|
throw new WasiError("ELOOP");
|
|
4766
|
-
const existed = fs.exists(abs);
|
|
4906
|
+
const existed = !fresh && fs.exists(abs);
|
|
4767
4907
|
const oflags = (o.create ? OFLAGS.CREAT : 0) | (o.exclusive ? OFLAGS.EXCL : 0) | (o.truncate ? OFLAGS.TRUNC : 0) | (o.directory ? OFLAGS.DIRECTORY : 0);
|
|
4768
4908
|
const rights = (o.write ? RIGHTS.FD_WRITE : 0n) | (o.read || !o.write ? RIGHTS.FD_READ : 0n);
|
|
4769
|
-
const
|
|
4770
|
-
|
|
4909
|
+
const flags = o.append ? FDFLAGS.APPEND : 0;
|
|
4910
|
+
const fd = host.fds.open(abs, oflags, rights, flags, fresh ? o.mode : void 0);
|
|
4911
|
+
if (o.mode !== void 0 && !existed && !fresh) fs.chmod(abs, o.mode);
|
|
4771
4912
|
return fd;
|
|
4772
4913
|
},
|
|
4773
4914
|
close(fd) {
|
|
@@ -5031,7 +5172,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
5031
5172
|
var init_version = __esm({
|
|
5032
5173
|
"src/version.ts"() {
|
|
5033
5174
|
"use strict";
|
|
5034
|
-
KERNEL_VERSION = true ? "1.
|
|
5175
|
+
KERNEL_VERSION = true ? "1.108.1" : "0.0.0-dev";
|
|
5035
5176
|
OS_RELEASE = "6.0.0-slicc";
|
|
5036
5177
|
}
|
|
5037
5178
|
});
|
|
@@ -12612,7 +12753,7 @@ var init_process_signals = __esm({
|
|
|
12612
12753
|
init_signals();
|
|
12613
12754
|
init_sync_sab_wire();
|
|
12614
12755
|
SignalGate = class {
|
|
12615
|
-
reported = { caught: 0, ignored: 0 };
|
|
12756
|
+
reported = { caught: 0, ignored: 0, nocldwait: false };
|
|
12616
12757
|
restart = 0;
|
|
12617
12758
|
lastDelivered = 0;
|
|
12618
12759
|
depth = 0;
|
|
@@ -12665,10 +12806,18 @@ var init_process_signals = __esm({
|
|
|
12665
12806
|
if (!masks) return;
|
|
12666
12807
|
this.restart = masks.restart;
|
|
12667
12808
|
const { caught, ignored, defaults = 0 } = masks;
|
|
12668
|
-
const
|
|
12809
|
+
const nocldwait = masks.nocldwait === true;
|
|
12810
|
+
const was = this.reported;
|
|
12811
|
+
const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
|
|
12669
12812
|
if (same && defaults === 0) return;
|
|
12670
|
-
this.reported = { caught, ignored };
|
|
12671
|
-
const req = {
|
|
12813
|
+
this.reported = { caught, ignored, nocldwait };
|
|
12814
|
+
const req = {
|
|
12815
|
+
op: "sig-mask",
|
|
12816
|
+
caught,
|
|
12817
|
+
ignored,
|
|
12818
|
+
...defaults ? { defaults } : {},
|
|
12819
|
+
...nocldwait ? { nocldwait } : {}
|
|
12820
|
+
};
|
|
12672
12821
|
this.raw.call(req, Number.POSITIVE_INFINITY, "sig-mask");
|
|
12673
12822
|
}
|
|
12674
12823
|
quiet(fn) {
|
|
@@ -13619,138 +13768,8 @@ var init_wasi_module = __esm({
|
|
|
13619
13768
|
}
|
|
13620
13769
|
});
|
|
13621
13770
|
|
|
13622
|
-
// src/process/wasi/wasi-sigmask.ts
|
|
13623
|
-
var UNBLOCKABLE, LIBC_UNBLOCKABLE, FOREVER2, NS_PER_MS4, POLL_MS, SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK, kernelBits, libcBits, apply, WasiSigmask;
|
|
13624
|
-
var init_wasi_sigmask = __esm({
|
|
13625
|
-
"src/process/wasi/wasi-sigmask.ts"() {
|
|
13626
|
-
"use strict";
|
|
13627
|
-
init_signals();
|
|
13628
|
-
init_sync_sab_wire();
|
|
13629
|
-
init_wasi_abi();
|
|
13630
|
-
UNBLOCKABLE = sigbit(SIG.KILL) | sigbit(SIG.STOP);
|
|
13631
|
-
LIBC_UNBLOCKABLE = 1 << SIG.KILL - 1 | 1 << SIG.STOP - 1;
|
|
13632
|
-
FOREVER2 = 0xffffffffffffffffn;
|
|
13633
|
-
NS_PER_MS4 = 1000000n;
|
|
13634
|
-
POLL_MS = 50;
|
|
13635
|
-
SIG_BLOCK = 0;
|
|
13636
|
-
SIG_UNBLOCK = 1;
|
|
13637
|
-
SIG_SETMASK = 2;
|
|
13638
|
-
kernelBits = (lo) => lo << 1 & ~UNBLOCKABLE;
|
|
13639
|
-
libcBits = (bits) => bits >>> 1 & ~LIBC_UNBLOCKABLE;
|
|
13640
|
-
apply = (how, mask, set) => {
|
|
13641
|
-
if (how === SIG_BLOCK) return mask | set;
|
|
13642
|
-
if (how === SIG_UNBLOCK) return mask & ~set;
|
|
13643
|
-
return set;
|
|
13644
|
-
};
|
|
13645
|
-
WasiSigmask = class {
|
|
13646
|
-
lo;
|
|
13647
|
-
hi;
|
|
13648
|
-
header;
|
|
13649
|
-
deliver;
|
|
13650
|
-
process;
|
|
13651
|
-
tid;
|
|
13652
|
-
constructor(header, deliver, process, tid = 1) {
|
|
13653
|
-
this.header = header;
|
|
13654
|
-
this.deliver = deliver;
|
|
13655
|
-
this.process = process;
|
|
13656
|
-
this.tid = tid;
|
|
13657
|
-
this.lo = libcBits(Atomics.load(header, SAB_I_BLOCKED));
|
|
13658
|
-
this.hi = Atomics.load(header, SAB_I_BLOCKED_HI);
|
|
13659
|
-
}
|
|
13660
|
-
static unsupported(header) {
|
|
13661
|
-
storeBlocked(header, [0, 0]);
|
|
13662
|
-
}
|
|
13663
|
-
set(how, setLo, setHi, old) {
|
|
13664
|
-
if (how !== SIG_BLOCK && how !== SIG_UNBLOCK && how !== SIG_SETMASK) return E.INVAL;
|
|
13665
|
-
old(this.lo >>> 0, this.hi >>> 0);
|
|
13666
|
-
this.lo = apply(how, this.lo, setLo | 0) & ~LIBC_UNBLOCKABLE;
|
|
13667
|
-
this.hi = apply(how, this.hi, setHi | 0);
|
|
13668
|
-
const now = kernelBits(this.lo);
|
|
13669
|
-
storeBlocked(this.header, [now, this.hi]);
|
|
13670
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) !== 0) this.deliver();
|
|
13671
|
-
return E.SUCCESS;
|
|
13672
|
-
}
|
|
13673
|
-
swap(setLo, setHi) {
|
|
13674
|
-
const old = [this.lo, this.hi];
|
|
13675
|
-
this.lo = setLo & ~LIBC_UNBLOCKABLE;
|
|
13676
|
-
this.hi = setHi | 0;
|
|
13677
|
-
storeBlocked(this.header, [kernelBits(this.lo), this.hi]);
|
|
13678
|
-
return old;
|
|
13679
|
-
}
|
|
13680
|
-
deliverUnblocked() {
|
|
13681
|
-
const now = Atomics.load(this.header, SAB_I_BLOCKED);
|
|
13682
|
-
if ((Atomics.load(this.header, SAB_I_SIGNALS) & ~now) === 0) return false;
|
|
13683
|
-
this.deliver();
|
|
13684
|
-
return true;
|
|
13685
|
-
}
|
|
13686
|
-
restore([lo, hi]) {
|
|
13687
|
-
this.set(SIG_SETMASK, lo, hi, () => {
|
|
13688
|
-
});
|
|
13689
|
-
}
|
|
13690
|
-
blockedBits() {
|
|
13691
|
-
return Atomics.load(this.header, SAB_I_BLOCKED);
|
|
13692
|
-
}
|
|
13693
|
-
blocks(sig) {
|
|
13694
|
-
return (Atomics.load(this.header, SAB_I_BLOCKED) & sigbit(sig)) !== 0;
|
|
13695
|
-
}
|
|
13696
|
-
inherited() {
|
|
13697
|
-
return [kernelBits(this.lo), this.hi];
|
|
13698
|
-
}
|
|
13699
|
-
discard(sig) {
|
|
13700
|
-
Atomics.and(this.header, SAB_I_SIGNALS, ~sigbit(sig));
|
|
13701
|
-
if (this.process) Atomics.and(this.process, SAB_I_SIGNALS, ~sigbit(sig));
|
|
13702
|
-
}
|
|
13703
|
-
sigwait(setLo, timeoutNs, publish, took, entered = false) {
|
|
13704
|
-
const set = kernelBits(setLo | 0);
|
|
13705
|
-
const value2 = BigInt.asUintN(64, timeoutNs);
|
|
13706
|
-
const deadline = value2 === FOREVER2 ? Number.POSITIVE_INFINITY : performance.now() + Number((value2 + NS_PER_MS4 - 1n) / NS_PER_MS4);
|
|
13707
|
-
publish(set);
|
|
13708
|
-
try {
|
|
13709
|
-
for (; ; ) {
|
|
13710
|
-
const seen = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
13711
|
-
const sig = this.take(set);
|
|
13712
|
-
if (sig !== 0) {
|
|
13713
|
-
took(sig);
|
|
13714
|
-
return E.SUCCESS;
|
|
13715
|
-
}
|
|
13716
|
-
if (entered || this.deliverUnblocked() || this.interrupted()) return E.INTR;
|
|
13717
|
-
const left = deadline - performance.now();
|
|
13718
|
-
if (left <= 0) return E.AGAIN;
|
|
13719
|
-
Atomics.wait(this.header, SAB_I_SIGNALS, seen, Math.min(left, POLL_MS));
|
|
13720
|
-
}
|
|
13721
|
-
} finally {
|
|
13722
|
-
publish(0);
|
|
13723
|
-
}
|
|
13724
|
-
}
|
|
13725
|
-
take(set) {
|
|
13726
|
-
for (const header of this.process ? [this.header, this.process] : [this.header]) {
|
|
13727
|
-
const ready = Atomics.load(header, SAB_I_SIGNALS) & set;
|
|
13728
|
-
if (ready === 0) continue;
|
|
13729
|
-
const bit = ready & -ready;
|
|
13730
|
-
if ((Atomics.and(header, SAB_I_SIGNALS, ~bit) & bit) !== 0) return 31 - Math.clz32(bit);
|
|
13731
|
-
}
|
|
13732
|
-
return 0;
|
|
13733
|
-
}
|
|
13734
|
-
interrupted() {
|
|
13735
|
-
const killed = this.process ?? this.header;
|
|
13736
|
-
if (Atomics.load(killed, SAB_I_KILLED) !== 0) {
|
|
13737
|
-
this.deliver();
|
|
13738
|
-
return true;
|
|
13739
|
-
}
|
|
13740
|
-
if (Atomics.load(killed, SAB_I_STOP) !== 1) return false;
|
|
13741
|
-
while (Atomics.load(killed, SAB_I_STOP) === 1) Atomics.wait(killed, SAB_I_STOP, 1);
|
|
13742
|
-
return true;
|
|
13743
|
-
}
|
|
13744
|
-
pending() {
|
|
13745
|
-
const own = Atomics.load(this.header, SAB_I_SIGNALS);
|
|
13746
|
-
return libcBits(own | (this.process ? Atomics.load(this.process, SAB_I_SIGNALS) : 0));
|
|
13747
|
-
}
|
|
13748
|
-
};
|
|
13749
|
-
}
|
|
13750
|
-
});
|
|
13751
|
-
|
|
13752
13771
|
// src/process/wasi/wasi-signals.ts
|
|
13753
|
-
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
13772
|
+
var DELIVERED_MASK, KERNEL_DEFAULTS, LIBC_DEFAULT_EXIT, SA_RESTART, SA_NOCLDWAIT, DISPOSITION_IGNORE, DISPOSITION_HANDLER, withBit, WASIX_LIBC_DEFAULT_LINE, WasiSignals;
|
|
13754
13773
|
var init_wasi_signals = __esm({
|
|
13755
13774
|
"src/process/wasi/wasi-signals.ts"() {
|
|
13756
13775
|
"use strict";
|
|
@@ -13761,6 +13780,7 @@ var init_wasi_signals = __esm({
|
|
|
13761
13780
|
KERNEL_DEFAULTS = [SIG.TSTP, SIG.TTIN, SIG.TTOU, SIG.CHLD, SIG.CONT, SIG.URG, SIG.WINCH].map(sigbit).reduce((m, bit) => m | bit, 0);
|
|
13762
13781
|
LIBC_DEFAULT_EXIT = 127;
|
|
13763
13782
|
SA_RESTART = 268435456;
|
|
13783
|
+
SA_NOCLDWAIT = 2;
|
|
13764
13784
|
DISPOSITION_IGNORE = 1;
|
|
13765
13785
|
DISPOSITION_HANDLER = 2;
|
|
13766
13786
|
withBit = (mask, bit, on) => on ? mask | bit : mask & ~bit;
|
|
@@ -13777,6 +13797,7 @@ var init_wasi_signals = __esm({
|
|
|
13777
13797
|
ignoring = 0;
|
|
13778
13798
|
restarting = 0;
|
|
13779
13799
|
defaults = 0;
|
|
13800
|
+
nocldwait = false;
|
|
13780
13801
|
fallBack;
|
|
13781
13802
|
onKilled;
|
|
13782
13803
|
constructor(fallBack, onKilled) {
|
|
@@ -13802,6 +13823,7 @@ var init_wasi_signals = __esm({
|
|
|
13802
13823
|
this.ignoring = withBit(this.ignoring, bit, disposition === DISPOSITION_IGNORE);
|
|
13803
13824
|
this.restarting = withBit(this.restarting, bit, (flags & SA_RESTART) !== 0);
|
|
13804
13825
|
this.defaults = withBit(this.defaults, bit, disposition === 0);
|
|
13826
|
+
if (sig === SIG.CHLD) this.nocldwait = (flags & SA_NOCLDWAIT) !== 0;
|
|
13805
13827
|
return E.SUCCESS;
|
|
13806
13828
|
}
|
|
13807
13829
|
snapshot() {
|
|
@@ -13811,7 +13833,8 @@ var init_wasi_signals = __esm({
|
|
|
13811
13833
|
handlers: this.handlers,
|
|
13812
13834
|
ignoring: this.ignoring,
|
|
13813
13835
|
restarting: this.restarting,
|
|
13814
|
-
uncaught: this.uncaught
|
|
13836
|
+
uncaught: this.uncaught,
|
|
13837
|
+
...this.nocldwait ? { nocldwait: true } : {}
|
|
13815
13838
|
};
|
|
13816
13839
|
}
|
|
13817
13840
|
restore(state) {
|
|
@@ -13821,13 +13844,15 @@ var init_wasi_signals = __esm({
|
|
|
13821
13844
|
this.ignoring = state.ignoring;
|
|
13822
13845
|
this.restarting = state.restarting;
|
|
13823
13846
|
this.uncaught = state.uncaught;
|
|
13847
|
+
this.nocldwait = state.nocldwait === true;
|
|
13824
13848
|
}
|
|
13825
13849
|
masks() {
|
|
13826
13850
|
if (this.hooked) {
|
|
13827
13851
|
const caught = this.handler() ? this.handlers : 0;
|
|
13828
13852
|
const defaults = this.defaults;
|
|
13829
13853
|
this.defaults = 0;
|
|
13830
|
-
|
|
13854
|
+
const nocldwait = this.nocldwait ? { nocldwait: true } : {};
|
|
13855
|
+
return { caught, ignored: this.ignoring, restart: this.restarting, defaults, ...nocldwait };
|
|
13831
13856
|
}
|
|
13832
13857
|
if (!this.handler()) return null;
|
|
13833
13858
|
return { caught: DELIVERED_MASK & ~this.uncaught & ~KERNEL_DEFAULTS, ignored: 0, restart: 0 };
|