@ai-ecoverse/slicc-kernel 1.120.0 → 1.120.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 +7 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +52 -12
- package/dist/kernel-worker.js.map +3 -3
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.js +51 -31
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +52 -12
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +51 -31
- package/dist/process-worker.js.map +2 -2
- package/dist/types/fs/opfs.d.ts +6 -0
- package/dist/types/fs/ranged.d.ts +1 -0
- package/dist/types/fs/types.d.ts +5 -0
- package/dist/types/kernel/fd-table.d.ts +1 -0
- package/dist/types/kernel/host-ops.d.ts +1 -0
- package/dist/types/kernel/lock-service.d.ts +8 -1
- package/dist/types/kernel/process.d.ts +1 -0
- package/dist/types/kernel/vfs-file.d.ts +1 -0
- package/dist/types/launcher.d.ts +1 -0
- package/dist/types/process/wasi/slicc-lock.d.ts +3 -2
- package/dist/types/process/wasi/wasi-fds.d.ts +1 -0
- package/dist/types/process/wasi/wasi-files.d.ts +1 -0
- package/dist/types/process/wasi/wasi-host.d.ts +1 -0
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -1199,7 +1199,7 @@ var OpfsFs = class {
|
|
|
1199
1199
|
this.rootName = channel;
|
|
1200
1200
|
this.channel = channel === void 0 ? void 0 : new BroadcastChannel(channel);
|
|
1201
1201
|
this.remote = channel === void 0 ? void 0 : new RemoteWatch(`${channel}:watch`);
|
|
1202
|
-
if (this.remote) this.remote.quiet = () => this.quiet();
|
|
1202
|
+
if (this.remote) this.remote.quiet = () => this.quiet().then(() => this.settle?.());
|
|
1203
1203
|
if (this.channel) {
|
|
1204
1204
|
const remote = this.remote;
|
|
1205
1205
|
meta.listen?.(
|
|
@@ -1354,6 +1354,15 @@ var OpfsFs = class {
|
|
|
1354
1354
|
if (this.unlocked === 0) for (const done4 of this.idle.splice(0)) done4();
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
|
+
settle;
|
|
1358
|
+
onPeer(settle3) {
|
|
1359
|
+
this.settle = settle3;
|
|
1360
|
+
}
|
|
1361
|
+
peers() {
|
|
1362
|
+
const remote = this.remote;
|
|
1363
|
+
if (!remote) return void 0;
|
|
1364
|
+
return { joined: () => remote.peered(), crowded: () => remote.crowded() };
|
|
1365
|
+
}
|
|
1357
1366
|
quiet() {
|
|
1358
1367
|
if (this.unlocked === 0) return Promise.resolve();
|
|
1359
1368
|
return new Promise((resolve2) => this.idle.push(resolve2));
|
|
@@ -6376,7 +6385,7 @@ function satisfies(version, range2) {
|
|
|
6376
6385
|
}
|
|
6377
6386
|
|
|
6378
6387
|
// src/version.ts
|
|
6379
|
-
var KERNEL_VERSION = true ? "1.120.
|
|
6388
|
+
var KERNEL_VERSION = true ? "1.120.1" : "0.0.0-dev";
|
|
6380
6389
|
var OS_RELEASE = "6.0.0-slicc";
|
|
6381
6390
|
function procVersion() {
|
|
6382
6391
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -13643,10 +13652,14 @@ async function flock(req, ctx) {
|
|
|
13643
13652
|
if (!locks || !flockOf) throw new KernelError("ENOLCK");
|
|
13644
13653
|
if (!FLOCK_KINDS.has(req.kind)) throw new KernelError("EINVAL");
|
|
13645
13654
|
const { key, owner } = await flockOf(req.fd);
|
|
13655
|
+
const granted2 = req.kind !== "unlock";
|
|
13656
|
+
const shared = locks.shared?.() === true;
|
|
13657
|
+
if (shared && !granted2) await ctx.settle?.(req.fd, false);
|
|
13646
13658
|
if (req.kind !== "unlock" && req.wait)
|
|
13647
13659
|
await locks.flocks.wait(key, owner, req.kind, ctx.blocking);
|
|
13648
13660
|
else if (!await locks.flocks.set(key, owner, req.kind)) throw new KernelError("EAGAIN");
|
|
13649
|
-
|
|
13661
|
+
if (shared && granted2) await ctx.settle?.(req.fd, true);
|
|
13662
|
+
return shared ? json3(true) : done2;
|
|
13650
13663
|
}
|
|
13651
13664
|
async function recordLock2(req, ctx) {
|
|
13652
13665
|
const { locks, fileKey } = ctx;
|
|
@@ -13657,6 +13670,7 @@ async function recordLock2(req, ctx) {
|
|
|
13657
13670
|
...req.fd !== void 0 ? { fd: req.fd } : {}
|
|
13658
13671
|
};
|
|
13659
13672
|
if (req.op === "lk-close") {
|
|
13673
|
+
if (req.fd !== void 0 && locks.shared?.()) await ctx.settle?.(req.fd, false);
|
|
13660
13674
|
locks.dropFile(await fileKey(target, "close"), owner);
|
|
13661
13675
|
return done2;
|
|
13662
13676
|
}
|
|
@@ -13668,13 +13682,16 @@ async function recordLock2(req, ctx) {
|
|
|
13668
13682
|
const len = held.end === Number.POSITIVE_INFINITY ? 0 : held.end - held.start;
|
|
13669
13683
|
return json3({ kind: held.kind, pid: held.owner, start: held.start, len });
|
|
13670
13684
|
}
|
|
13671
|
-
|
|
13685
|
+
const granted2 = req.kind !== "unlock";
|
|
13686
|
+
const shared = locks.shared?.() === true;
|
|
13687
|
+
const fd = shared ? req.fd : void 0;
|
|
13688
|
+
if (!granted2 && fd !== void 0) await ctx.settle?.(fd, false);
|
|
13689
|
+
if (req.kind !== "unlock" && req.wait)
|
|
13672
13690
|
await locks.wait(key, owner, req.kind, range2, ctx.blocking);
|
|
13673
|
-
|
|
13674
|
-
}
|
|
13675
|
-
if (!await locks.set(key, owner, req.kind, range2.start, range2.end))
|
|
13691
|
+
else if (!await locks.set(key, owner, req.kind, range2.start, range2.end))
|
|
13676
13692
|
throw new KernelError("EAGAIN");
|
|
13677
|
-
|
|
13693
|
+
if (granted2 && fd !== void 0) await ctx.settle?.(fd, true);
|
|
13694
|
+
return shared ? json3(true) : done2;
|
|
13678
13695
|
}
|
|
13679
13696
|
|
|
13680
13697
|
// src/kernel/net/loopback-transport.ts
|
|
@@ -16984,6 +17001,11 @@ var VfsNode = class {
|
|
|
16984
17001
|
holds() {
|
|
16985
17002
|
return this.dirty;
|
|
16986
17003
|
}
|
|
17004
|
+
reread() {
|
|
17005
|
+
if (this.dirty || this.orphaned || this.pin || this.revoked) return;
|
|
17006
|
+
this.data = void 0;
|
|
17007
|
+
this.ranged = void 0;
|
|
17008
|
+
}
|
|
16987
17009
|
replace(contents2) {
|
|
16988
17010
|
this.ranged = void 0;
|
|
16989
17011
|
this.data = new Uint8Array(contents2);
|
|
@@ -17611,6 +17633,7 @@ function vfsFile(fs, opts, nodes) {
|
|
|
17611
17633
|
})),
|
|
17612
17634
|
known: () => node.known(),
|
|
17613
17635
|
flush: () => serial(() => node.flush()),
|
|
17636
|
+
reread: () => serial(async () => node.reread()),
|
|
17614
17637
|
close: () => node.serial(async () => {
|
|
17615
17638
|
try {
|
|
17616
17639
|
takeOpenError();
|
|
@@ -18093,6 +18116,7 @@ var WasmProcess = class {
|
|
|
18093
18116
|
owner: () => this.lockOwner(),
|
|
18094
18117
|
fileKey: (target, kind, setting) => this.lockKey(target, kind, setting),
|
|
18095
18118
|
flockOf: (fd) => this.flockOf(fd),
|
|
18119
|
+
settle: (fd, granted2) => this.settle(fd, granted2),
|
|
18096
18120
|
locks: this.options.locks,
|
|
18097
18121
|
ops: this.asyncOps,
|
|
18098
18122
|
blocking: () => this.blockingSignal(cancelled),
|
|
@@ -18176,6 +18200,11 @@ var WasmProcess = class {
|
|
|
18176
18200
|
else if (this.pathKeys.size < 4096) this.pathKeys.set(path, key);
|
|
18177
18201
|
return key;
|
|
18178
18202
|
}
|
|
18203
|
+
async settle(fd, granted2) {
|
|
18204
|
+
const file = this.fds.has(fd) ? this.fds.get(fd).file : void 0;
|
|
18205
|
+
if (granted2) await file?.reread?.();
|
|
18206
|
+
else await file?.flush?.();
|
|
18207
|
+
}
|
|
18179
18208
|
async flockOf(fd) {
|
|
18180
18209
|
const open = this.fds.get(fd);
|
|
18181
18210
|
const { locks } = this.options;
|
|
@@ -19861,13 +19890,20 @@ var LockService = class {
|
|
|
19861
19890
|
};
|
|
19862
19891
|
void this.locks.request(this.aliveOf(this.kernel), () => new Promise(() => {
|
|
19863
19892
|
}));
|
|
19864
|
-
|
|
19893
|
+
const peers = options.peers;
|
|
19894
|
+
this.role = peers ? Promise.all([this.elect(), peers.joined()]).then(() => void 0) : this.elect();
|
|
19895
|
+
this.peers = options.peers;
|
|
19865
19896
|
this.flocks = {
|
|
19866
19897
|
set: (key, owner, kind) => this.flockSet(key, owner, kind),
|
|
19867
19898
|
wait: (key, owner, kind, blocking) => this.flockWait(key, owner, kind, blocking),
|
|
19868
19899
|
drop: (owner) => this.flockDrop(owner)
|
|
19869
19900
|
};
|
|
19870
19901
|
}
|
|
19902
|
+
peers;
|
|
19903
|
+
shared() {
|
|
19904
|
+
if (!this.leader || this.ownerOf.size > 0 || this.tokens.size > 0) return true;
|
|
19905
|
+
return this.peers?.crowded() === true;
|
|
19906
|
+
}
|
|
19871
19907
|
aliveOf(kernel) {
|
|
19872
19908
|
return `slicc-locks-alive:${LOCKS_PROTOCOL}:${this.root}:${kernel}`;
|
|
19873
19909
|
}
|
|
@@ -20128,11 +20164,11 @@ var LockService = class {
|
|
|
20128
20164
|
this.table.closed(pid, fd);
|
|
20129
20165
|
}
|
|
20130
20166
|
};
|
|
20131
|
-
function kernelLocks(root) {
|
|
20167
|
+
function kernelLocks(root, peers) {
|
|
20132
20168
|
const locks = globalThis.navigator?.locks;
|
|
20133
20169
|
if (root === void 0 || !locks || typeof BroadcastChannel !== "function")
|
|
20134
20170
|
return new LockTable();
|
|
20135
|
-
return new LockService({ root, locks });
|
|
20171
|
+
return new LockService({ root, locks, ...peers ? { peers } : {} });
|
|
20136
20172
|
}
|
|
20137
20173
|
var ASK_OPS = /* @__PURE__ */ new Set([
|
|
20138
20174
|
"set",
|
|
@@ -23520,7 +23556,7 @@ var Launcher = class {
|
|
|
23520
23556
|
constructor(options) {
|
|
23521
23557
|
this.usersMode = usersMode(options.users);
|
|
23522
23558
|
this.rootFs = options.fs;
|
|
23523
|
-
this.locks = kernelLocks(options.fs.rootName);
|
|
23559
|
+
this.locks = kernelLocks(options.fs.rootName, options.fs.peers?.());
|
|
23524
23560
|
this.dac = this.usersMode === "off" ? void 0 : new Dac(this.usersMode, options.onDenial);
|
|
23525
23561
|
if (this.dac) this.dac.tagOf = (pid) => this.tagOf(pid);
|
|
23526
23562
|
this.clipboard = new ClipboardBroker(
|
|
@@ -23601,6 +23637,7 @@ var Launcher = class {
|
|
|
23601
23637
|
this.nodes = new VfsNodes(fs, (path) => this.released(path));
|
|
23602
23638
|
this.nodes.keepsOnDisk = true;
|
|
23603
23639
|
this.openFiles.add(this.nodes);
|
|
23640
|
+
options.fs.onPeer?.(() => this.flushOpen());
|
|
23604
23641
|
const holders = [this.held, this.openFiles];
|
|
23605
23642
|
this.unlinked = new UnlinkedKeeper(
|
|
23606
23643
|
fs,
|
|
@@ -25261,6 +25298,9 @@ var Launcher = class {
|
|
|
25261
25298
|
this.writers ??= this.writerStack();
|
|
25262
25299
|
return this.writers;
|
|
25263
25300
|
}
|
|
25301
|
+
async flushOpen() {
|
|
25302
|
+
for (const nodes of this.openFiles) await nodes.flush("/").catch(() => void 0);
|
|
25303
|
+
}
|
|
25264
25304
|
writerStack() {
|
|
25265
25305
|
const mounted = this.mounts.wrap(this.unguardedRoot);
|
|
25266
25306
|
const fs = this.commandFs(this.rooted(mounted));
|