@ai-ecoverse/slicc-kernel 1.99.2 → 1.100.0
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 +17 -1
- package/dist/kernel-worker.js +7 -4
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +152 -35
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +7 -4
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +118 -1
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
|
@@ -1484,6 +1484,69 @@ var init_cred = __esm({
|
|
|
1484
1484
|
}
|
|
1485
1485
|
});
|
|
1486
1486
|
|
|
1487
|
+
// src/process/wasi/slicc-lock.ts
|
|
1488
|
+
function kindOf(type) {
|
|
1489
|
+
if (type === F_RDLCK) return "read";
|
|
1490
|
+
if (type === F_WRLCK) return "write";
|
|
1491
|
+
if (type === F_UNLCK) return "unlock";
|
|
1492
|
+
throw new WasiError("EINVAL");
|
|
1493
|
+
}
|
|
1494
|
+
function baseOf(file, whence) {
|
|
1495
|
+
if (whence === SEEK_SET) return 0;
|
|
1496
|
+
if (whence === SEEK_CUR) return file.offset();
|
|
1497
|
+
if (whence === SEEK_END) return file.size();
|
|
1498
|
+
throw new WasiError("EINVAL");
|
|
1499
|
+
}
|
|
1500
|
+
function writeHolder(view, at, found) {
|
|
1501
|
+
if (!found) {
|
|
1502
|
+
view.setInt16(at, F_UNLCK, true);
|
|
1503
|
+
return;
|
|
1504
|
+
}
|
|
1505
|
+
view.setInt16(at, found.kind === "read" ? F_RDLCK : F_WRLCK, true);
|
|
1506
|
+
view.setInt16(at + 2, SEEK_SET, true);
|
|
1507
|
+
view.setBigInt64(at + 8, BigInt(found.start), true);
|
|
1508
|
+
view.setBigInt64(at + 16, BigInt(found.len), true);
|
|
1509
|
+
view.setInt32(at + 24, found.pid, true);
|
|
1510
|
+
}
|
|
1511
|
+
function lockImports(host) {
|
|
1512
|
+
return {
|
|
1513
|
+
fcntl_lock: (fd, cmd, at) => {
|
|
1514
|
+
if (cmd !== F_GETLK && cmd !== F_SETLK && cmd !== F_SETLKW) throw new WasiError("EINVAL");
|
|
1515
|
+
const file = host.file(fd);
|
|
1516
|
+
const view = host.mem.view();
|
|
1517
|
+
const kind = kindOf(view.getInt16(at, true));
|
|
1518
|
+
const start2 = baseOf(file, view.getInt16(at + 2, true)) + Number(view.getBigInt64(at + 8, true));
|
|
1519
|
+
const len = Number(view.getBigInt64(at + 16, true));
|
|
1520
|
+
if (cmd === F_GETLK) {
|
|
1521
|
+
if (kind === "unlock") throw new WasiError("EINVAL");
|
|
1522
|
+
writeHolder(view, at, host.calls.get(file.target, kind, start2, len));
|
|
1523
|
+
return;
|
|
1524
|
+
}
|
|
1525
|
+
if (kind === "read" && file.readable === false || kind === "write" && file.writable === false)
|
|
1526
|
+
throw new WasiError("EBADF");
|
|
1527
|
+
if (kind !== "write") host.flush(file);
|
|
1528
|
+
host.calls.set(file.target, kind, start2, len, cmd === F_SETLKW);
|
|
1529
|
+
if (kind !== "unlock") host.locked();
|
|
1530
|
+
}
|
|
1531
|
+
};
|
|
1532
|
+
}
|
|
1533
|
+
var F_GETLK, F_SETLK, F_SETLKW, F_RDLCK, F_WRLCK, F_UNLCK, SEEK_SET, SEEK_CUR, SEEK_END;
|
|
1534
|
+
var init_slicc_lock = __esm({
|
|
1535
|
+
"src/process/wasi/slicc-lock.ts"() {
|
|
1536
|
+
"use strict";
|
|
1537
|
+
init_wasi_files();
|
|
1538
|
+
F_GETLK = 12;
|
|
1539
|
+
F_SETLK = 13;
|
|
1540
|
+
F_SETLKW = 14;
|
|
1541
|
+
F_RDLCK = 0;
|
|
1542
|
+
F_WRLCK = 1;
|
|
1543
|
+
F_UNLCK = 2;
|
|
1544
|
+
SEEK_SET = 0;
|
|
1545
|
+
SEEK_CUR = 1;
|
|
1546
|
+
SEEK_END = 2;
|
|
1547
|
+
}
|
|
1548
|
+
});
|
|
1549
|
+
|
|
1487
1550
|
// src/process/wasi/slicc-sem.ts
|
|
1488
1551
|
function remainingMs(deadline, now) {
|
|
1489
1552
|
if (deadline <= now) return 0;
|
|
@@ -2029,6 +2092,17 @@ var init_wasi_fds = __esm({
|
|
|
2029
2092
|
}
|
|
2030
2093
|
return out;
|
|
2031
2094
|
}
|
|
2095
|
+
locking = false;
|
|
2096
|
+
holdLocks() {
|
|
2097
|
+
this.locking = true;
|
|
2098
|
+
}
|
|
2099
|
+
dropLocks(e) {
|
|
2100
|
+
if (!this.locking || e?.type !== "file") return;
|
|
2101
|
+
try {
|
|
2102
|
+
this.kernel.call({ op: "lk-close", path: e.file.path });
|
|
2103
|
+
} catch {
|
|
2104
|
+
}
|
|
2105
|
+
}
|
|
2032
2106
|
close(fd) {
|
|
2033
2107
|
const e = this.get(fd);
|
|
2034
2108
|
this.table.delete(fd);
|
|
@@ -2037,6 +2111,7 @@ var init_wasi_fds = __esm({
|
|
|
2037
2111
|
this.kernel.sys.close(fd);
|
|
2038
2112
|
} finally {
|
|
2039
2113
|
this.release(e);
|
|
2114
|
+
this.dropLocks(e);
|
|
2040
2115
|
this.bump();
|
|
2041
2116
|
}
|
|
2042
2117
|
}
|
|
@@ -2055,6 +2130,7 @@ var init_wasi_fds = __esm({
|
|
|
2055
2130
|
if (this.cloexec.delete(from)) this.cloexec.add(to);
|
|
2056
2131
|
}
|
|
2057
2132
|
if (old) this.release(old);
|
|
2133
|
+
this.dropLocks(old);
|
|
2058
2134
|
this.bump();
|
|
2059
2135
|
}
|
|
2060
2136
|
release(e) {
|
|
@@ -3171,6 +3247,7 @@ var init_wasi_host = __esm({
|
|
|
3171
3247
|
init_physical_path();
|
|
3172
3248
|
init_cpu_clock();
|
|
3173
3249
|
init_cred();
|
|
3250
|
+
init_slicc_lock();
|
|
3174
3251
|
init_slicc_sem();
|
|
3175
3252
|
init_wasi_abi();
|
|
3176
3253
|
init_wasi_fds();
|
|
@@ -3393,6 +3470,26 @@ var init_wasi_host = __esm({
|
|
|
3393
3470
|
void this.o.kernel.call({ op: "proc-setcred", change });
|
|
3394
3471
|
},
|
|
3395
3472
|
...semImports(this),
|
|
3473
|
+
...lockImports({
|
|
3474
|
+
mem,
|
|
3475
|
+
file: (fd) => this.lockedFile(fd),
|
|
3476
|
+
flush: (file) => {
|
|
3477
|
+
if (file.path !== void 0) this.fds.flushPath(file.path);
|
|
3478
|
+
else if (file.target.fd !== void 0) this.o.kernel.sys.flush(file.target.fd);
|
|
3479
|
+
},
|
|
3480
|
+
locked: () => this.fds.holdLocks(),
|
|
3481
|
+
calls: {
|
|
3482
|
+
set: (target, kind, start2, len, wait2) => void this.o.kernel.call({
|
|
3483
|
+
op: "lk-set",
|
|
3484
|
+
...target,
|
|
3485
|
+
kind,
|
|
3486
|
+
start: start2,
|
|
3487
|
+
len,
|
|
3488
|
+
...wait2 ? { wait: wait2 } : {}
|
|
3489
|
+
}),
|
|
3490
|
+
get: (target, kind, start2, len) => this.o.kernel.call({ op: "lk-get", ...target, kind, start: start2, len })
|
|
3491
|
+
}
|
|
3492
|
+
}),
|
|
3396
3493
|
groups_get: (buf, cap, count) => {
|
|
3397
3494
|
const { groups } = this.o.kernel.call({ op: "proc-cred" });
|
|
3398
3495
|
if (cap !== 0 && cap < groups.length) throw new WasiError("EINVAL");
|
|
@@ -3785,6 +3882,26 @@ var init_wasi_host = __esm({
|
|
|
3785
3882
|
}
|
|
3786
3883
|
e.path = path;
|
|
3787
3884
|
}
|
|
3885
|
+
lockedFile(fd) {
|
|
3886
|
+
const e = this.fds.get(fd);
|
|
3887
|
+
if (e.type === "file") {
|
|
3888
|
+
const { file } = e;
|
|
3889
|
+
return {
|
|
3890
|
+
target: { path: file.path },
|
|
3891
|
+
path: file.path,
|
|
3892
|
+
readable: file.readable,
|
|
3893
|
+
writable: file.writable,
|
|
3894
|
+
offset: () => file.offset,
|
|
3895
|
+
size: () => file.size()
|
|
3896
|
+
};
|
|
3897
|
+
}
|
|
3898
|
+
if (e.type !== "kernel" || this.fds.kind(fd, e) !== "file") throw new WasiError("EBADF");
|
|
3899
|
+
return {
|
|
3900
|
+
target: { fd },
|
|
3901
|
+
offset: () => this.o.kernel.sys.seek(fd, 0, WHENCE.CUR),
|
|
3902
|
+
size: () => this.kernelStat(fd).size
|
|
3903
|
+
};
|
|
3904
|
+
}
|
|
3788
3905
|
kernelStat(fd) {
|
|
3789
3906
|
return this.o.kernel.call({ op: "fd-vfs-stat", fd });
|
|
3790
3907
|
}
|
|
@@ -4650,7 +4767,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4650
4767
|
var init_version = __esm({
|
|
4651
4768
|
"src/version.ts"() {
|
|
4652
4769
|
"use strict";
|
|
4653
|
-
KERNEL_VERSION = true ? "1.
|
|
4770
|
+
KERNEL_VERSION = true ? "1.100.0" : "0.0.0-dev";
|
|
4654
4771
|
OS_RELEASE = "6.0.0-slicc";
|
|
4655
4772
|
}
|
|
4656
4773
|
});
|
|
@@ -7246,8 +7363,8 @@ function createStreamOps(h) {
|
|
|
7246
7363
|
},
|
|
7247
7364
|
llseek(stream, offset, whence) {
|
|
7248
7365
|
let pos = offset;
|
|
7249
|
-
if (whence ===
|
|
7250
|
-
else if (whence ===
|
|
7366
|
+
if (whence === SEEK_CUR2) pos += stream.position;
|
|
7367
|
+
else if (whence === SEEK_END2 && Fs.isFile(stream.node.mode)) {
|
|
7251
7368
|
const s = stream.node.live;
|
|
7252
7369
|
pos += rangedOf(stream.node)?.size() ?? (s.loaded ? s.len : statOf(stream.node).size);
|
|
7253
7370
|
}
|
|
@@ -7607,7 +7724,7 @@ function readingLinks(Fs) {
|
|
|
7607
7724
|
}
|
|
7608
7725
|
};
|
|
7609
7726
|
}
|
|
7610
|
-
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK,
|
|
7727
|
+
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR2, SEEK_END2, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
|
|
7611
7728
|
var init_live_vfs_fs = __esm({
|
|
7612
7729
|
"src/realm/live-vfs-fs.ts"() {
|
|
7613
7730
|
"use strict";
|
|
@@ -7623,8 +7740,8 @@ var init_live_vfs_fs = __esm({
|
|
|
7623
7740
|
PERM_MASK = 4095;
|
|
7624
7741
|
DEFAULT_DIR_PERM = 493;
|
|
7625
7742
|
UMASK = 18;
|
|
7626
|
-
|
|
7627
|
-
|
|
7743
|
+
SEEK_CUR2 = 1;
|
|
7744
|
+
SEEK_END2 = 2;
|
|
7628
7745
|
EARLY_WHOLE_FILE = 64 * 1024;
|
|
7629
7746
|
O_APPEND4 = 1024;
|
|
7630
7747
|
O_ACCMODE = 3;
|
|
@@ -7653,23 +7770,23 @@ function sizeOf(Fs, stream) {
|
|
|
7653
7770
|
const st = Fs.fstat?.(stream.fd);
|
|
7654
7771
|
return st?.size ?? 0;
|
|
7655
7772
|
}
|
|
7656
|
-
function
|
|
7657
|
-
if (type ===
|
|
7658
|
-
if (type ===
|
|
7659
|
-
return type ===
|
|
7773
|
+
function kindOf2(type) {
|
|
7774
|
+
if (type === F_RDLCK2) return "read";
|
|
7775
|
+
if (type === F_WRLCK2) return "write";
|
|
7776
|
+
return type === F_UNLCK2 ? "unlock" : void 0;
|
|
7660
7777
|
}
|
|
7661
7778
|
function readFlock(view, at, base) {
|
|
7662
|
-
const kind =
|
|
7779
|
+
const kind = kindOf2(view.getInt16(at, true));
|
|
7663
7780
|
if (kind === void 0) return void 0;
|
|
7664
7781
|
const start2 = base(view.getInt16(at + 2, true)) + Number(view.getBigInt64(at + 8, true));
|
|
7665
7782
|
return { kind, start: start2, len: Number(view.getBigInt64(at + 16, true)) };
|
|
7666
7783
|
}
|
|
7667
|
-
function
|
|
7784
|
+
function writeHolder2(view, at, found) {
|
|
7668
7785
|
if (!found) {
|
|
7669
|
-
view.setInt16(at,
|
|
7786
|
+
view.setInt16(at, F_UNLCK2, true);
|
|
7670
7787
|
return;
|
|
7671
7788
|
}
|
|
7672
|
-
view.setInt16(at, found.kind === "read" ?
|
|
7789
|
+
view.setInt16(at, found.kind === "read" ? F_RDLCK2 : F_WRLCK2, true);
|
|
7673
7790
|
view.setInt16(at + 2, 0, true);
|
|
7674
7791
|
view.setBigInt64(at + 8, BigInt(found.start), true);
|
|
7675
7792
|
view.setBigInt64(at + 16, BigInt(found.len), true);
|
|
@@ -7679,12 +7796,12 @@ function refused2(kind, flags) {
|
|
|
7679
7796
|
const access = flags & O_ACCMODE2;
|
|
7680
7797
|
return kind === "write" && access === O_RDONLY || kind === "read" && access === O_WRONLY4;
|
|
7681
7798
|
}
|
|
7682
|
-
function
|
|
7683
|
-
return (whence) => whence ===
|
|
7799
|
+
function baseOf2(Fs, stream) {
|
|
7800
|
+
return (whence) => whence === SEEK_CUR3 ? stream.position : whence === SEEK_END3 ? sizeOf(Fs, stream) : 0;
|
|
7684
7801
|
}
|
|
7685
7802
|
function recordLock(fcntl, deps) {
|
|
7686
7803
|
return (fd, cmd, varargs) => {
|
|
7687
|
-
if (cmd !==
|
|
7804
|
+
if (cmd !== F_GETLK2 && cmd !== F_SETLK2 && cmd !== F_SETLKW2) return fcntl(fd, cmd, varargs);
|
|
7688
7805
|
const Fs = deps.fs();
|
|
7689
7806
|
const buffer = deps.memory();
|
|
7690
7807
|
const stream = Fs?.getStream(fd);
|
|
@@ -7692,11 +7809,11 @@ function recordLock(fcntl, deps) {
|
|
|
7692
7809
|
if (!Fs || !buffer || !stream || !target) return fcntl(fd, cmd, varargs);
|
|
7693
7810
|
const view = new DataView(buffer);
|
|
7694
7811
|
const at = view.getUint32(varargs, true);
|
|
7695
|
-
const lock = readFlock(view, at,
|
|
7696
|
-
if (!lock || cmd ===
|
|
7812
|
+
const lock = readFlock(view, at, baseOf2(Fs, stream));
|
|
7813
|
+
if (!lock || cmd === F_GETLK2 && lock.kind === "unlock") return -wasiErrno("EINVAL");
|
|
7697
7814
|
try {
|
|
7698
|
-
if (cmd ===
|
|
7699
|
-
|
|
7815
|
+
if (cmd === F_GETLK2) {
|
|
7816
|
+
writeHolder2(
|
|
7700
7817
|
view,
|
|
7701
7818
|
at,
|
|
7702
7819
|
deps.kernel.getLock(target, lock.kind, lock.start, lock.len)
|
|
@@ -7705,7 +7822,7 @@ function recordLock(fcntl, deps) {
|
|
|
7705
7822
|
}
|
|
7706
7823
|
if (refused2(lock.kind, stream.flags)) return -wasiErrno("EBADF");
|
|
7707
7824
|
if (lock.kind !== "write") deps.flush();
|
|
7708
|
-
deps.kernel.setLock(target, lock.kind, lock.start, lock.len, cmd ===
|
|
7825
|
+
deps.kernel.setLock(target, lock.kind, lock.start, lock.len, cmd === F_SETLKW2);
|
|
7709
7826
|
if (lock.kind !== "unlock") held.set(Fs, true);
|
|
7710
7827
|
return 0;
|
|
7711
7828
|
} catch (err) {
|
|
@@ -7726,20 +7843,20 @@ function closeDropsLocks(Fs, kernel) {
|
|
|
7726
7843
|
}
|
|
7727
7844
|
};
|
|
7728
7845
|
}
|
|
7729
|
-
var
|
|
7846
|
+
var F_GETLK2, F_SETLK2, F_SETLKW2, F_RDLCK2, F_WRLCK2, F_UNLCK2, SEEK_CUR3, SEEK_END3, O_ACCMODE2, O_RDONLY, O_WRONLY4, held;
|
|
7730
7847
|
var init_process_locks = __esm({
|
|
7731
7848
|
"src/process/process-locks.ts"() {
|
|
7732
7849
|
"use strict";
|
|
7733
7850
|
init_live_vfs_fs();
|
|
7734
7851
|
init_wasi_errno();
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7852
|
+
F_GETLK2 = 12;
|
|
7853
|
+
F_SETLK2 = 13;
|
|
7854
|
+
F_SETLKW2 = 14;
|
|
7855
|
+
F_RDLCK2 = 0;
|
|
7856
|
+
F_WRLCK2 = 1;
|
|
7857
|
+
F_UNLCK2 = 2;
|
|
7858
|
+
SEEK_CUR3 = 1;
|
|
7859
|
+
SEEK_END3 = 2;
|
|
7743
7860
|
O_ACCMODE2 = 3;
|
|
7744
7861
|
O_RDONLY = 0;
|
|
7745
7862
|
O_WRONLY4 = 1;
|
|
@@ -8387,14 +8504,14 @@ function cString(memory, at) {
|
|
|
8387
8504
|
const bytes = new Uint8Array(memory.buffer, at);
|
|
8388
8505
|
return new TextDecoder().decode(bytes.subarray(0, bytes.indexOf(0)));
|
|
8389
8506
|
}
|
|
8390
|
-
function
|
|
8507
|
+
function baseOf3(Fs, dirfd) {
|
|
8391
8508
|
return dirfd === AT_FDCWD ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
|
|
8392
8509
|
}
|
|
8393
8510
|
function readonlyRefusal(Fs, memory, call2) {
|
|
8394
8511
|
if (!(call2.amode & W_ACCESS)) return 0;
|
|
8395
8512
|
try {
|
|
8396
8513
|
const name2 = cString(memory, call2.path);
|
|
8397
|
-
const abs = name2.startsWith("/") ? name2 : `${
|
|
8514
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs, call2.dirfd)}/${name2}`;
|
|
8398
8515
|
const follow2 = (call2.flags & AT_SYMLINK_NOFOLLOW2) === 0;
|
|
8399
8516
|
const { node } = Fs.lookupPath.call(Fs, abs, {
|
|
8400
8517
|
follow: follow2
|
|
@@ -8409,7 +8526,7 @@ function readonlyRefusal(Fs, memory, call2) {
|
|
|
8409
8526
|
}
|
|
8410
8527
|
function kernelChecks(Fs, memory, call2) {
|
|
8411
8528
|
const name2 = cString(memory, call2.path);
|
|
8412
|
-
const abs = name2.startsWith("/") ? name2 : `${
|
|
8529
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf3(Fs, call2.dirfd)}/${name2}`;
|
|
8413
8530
|
const lookupPath = Fs.lookupPath;
|
|
8414
8531
|
const { node } = lookupPath.call(Fs, abs, { follow: (call2.flags & AT_SYMLINK_NOFOLLOW2) === 0 });
|
|
8415
8532
|
const bridge = node.live ? node.mount.opts.bridge : void 0;
|
|
@@ -8445,7 +8562,7 @@ function kernelLink(imports, fs, memory, glue) {
|
|
|
8445
8562
|
if (!Fs?.lookupPath || !heap) return own(olddirfd, oldpath, newdirfd, newpath, flags);
|
|
8446
8563
|
const at = (dirfd, ptr) => {
|
|
8447
8564
|
const name2 = cString(heap, ptr);
|
|
8448
|
-
return name2.startsWith("/") ? name2 : `${
|
|
8565
|
+
return name2.startsWith("/") ? name2 : `${baseOf3(Fs, dirfd)}/${name2}`;
|
|
8449
8566
|
};
|
|
8450
8567
|
try {
|
|
8451
8568
|
const from = at(olddirfd, oldpath);
|