@ai-ecoverse/slicc-kernel 1.133.4 → 1.134.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.
@@ -2693,7 +2693,7 @@ var KERNEL_VERSION, OS_RELEASE;
2693
2693
  var init_version = __esm({
2694
2694
  "src/version.ts"() {
2695
2695
  "use strict";
2696
- KERNEL_VERSION = true ? "1.133.4" : "0.0.0-dev";
2696
+ KERNEL_VERSION = true ? "1.134.0" : "0.0.0-dev";
2697
2697
  OS_RELEASE = "6.0.0-slicc";
2698
2698
  }
2699
2699
  });
@@ -6608,6 +6608,59 @@ var init_physical_path = __esm({
6608
6608
  }
6609
6609
  });
6610
6610
 
6611
+ // src/kernel/held-cwd.ts
6612
+ var CWD_SLOTS, UNTRACKED, HeldCwd;
6613
+ var init_held_cwd = __esm({
6614
+ "src/kernel/held-cwd.ts"() {
6615
+ "use strict";
6616
+ CWD_SLOTS = 1024;
6617
+ UNTRACKED = CWD_SLOTS - 1;
6618
+ HeldCwd = class {
6619
+ view;
6620
+ seen;
6621
+ dead = false;
6622
+ slot;
6623
+ at;
6624
+ ask;
6625
+ constructor(sab, slot2, ask, state) {
6626
+ this.view = new Int32Array(sab);
6627
+ this.slot = slot2;
6628
+ this.ask = ask;
6629
+ this.seen = state.seen;
6630
+ this.dead = state.dead;
6631
+ this.at = state.path;
6632
+ }
6633
+ moved(reply, path) {
6634
+ if (reply.slot === void 0) return false;
6635
+ this.slot = reply.slot;
6636
+ this.seen = reply.seen ?? Atomics.load(this.view, reply.slot);
6637
+ this.dead = reply.dead === true;
6638
+ this.at = path;
6639
+ return true;
6640
+ }
6641
+ follow() {
6642
+ const answer2 = this.ask();
6643
+ if (answer2.slot !== void 0) this.slot = answer2.slot;
6644
+ this.seen = answer2.gen;
6645
+ this.dead = !answer2.alive;
6646
+ return answer2.alive;
6647
+ }
6648
+ alive(path) {
6649
+ if (path !== void 0 && this.at !== void 0 && path !== this.at) {
6650
+ this.at = path;
6651
+ return this.follow();
6652
+ }
6653
+ if (this.dead) return false;
6654
+ if (Atomics.load(this.view, this.slot) === this.seen) return true;
6655
+ return this.follow();
6656
+ }
6657
+ get current() {
6658
+ return this.slot;
6659
+ }
6660
+ };
6661
+ }
6662
+ });
6663
+
6611
6664
  // src/process/wasi/dylink.ts
6612
6665
  function dylinkInfo(module) {
6613
6666
  const [section2] = WebAssembly.Module.customSections(module, "dylink.0");
@@ -8799,6 +8852,7 @@ var init_wasi_fds = __esm({
8799
8852
  e.path = path;
8800
8853
  this.kernel.call({ op: "fd-meta", fd, meta: metaOf(e) });
8801
8854
  }
8855
+ this.held?.moved(this.kernel.call({ op: "cwd-chdir", path }), path);
8802
8856
  this.bump();
8803
8857
  }
8804
8858
  promote(fd, moved = false) {
@@ -9085,9 +9139,21 @@ var init_wasi_fds = __esm({
9085
9139
  this.buffers.set(next2, buffer);
9086
9140
  }
9087
9141
  }
9142
+ held;
9143
+ cwdEntry(dir) {
9144
+ return dir.preopen === "." || dir.preopen === "./";
9145
+ }
9146
+ goneCwd(dir) {
9147
+ return this.held !== void 0 && this.cwdEntry(dir) && !this.held.alive(dir.path);
9148
+ }
9088
9149
  resolve(dirfd, path) {
9089
9150
  if (path === "") throw new WasiError("ENOENT");
9090
- const joined2 = path.startsWith("/") ? path : `${this.dir(dirfd).path}/${path}`;
9151
+ if (path.startsWith("/")) return this.joined(path);
9152
+ const dir = this.dir(dirfd);
9153
+ if (path.split("/")[0] !== ".." && this.goneCwd(dir)) throw new WasiError("ENOENT");
9154
+ return this.joined(`${dir.path}/${path}`);
9155
+ }
9156
+ joined(joined2) {
9091
9157
  return joined2.split("/").includes("..") ? physical(this.fs, joined2) : normalize(joined2);
9092
9158
  }
9093
9159
  openKernelDevice(path, oflags, fdflags, rights) {
@@ -10384,6 +10450,7 @@ var init_wasi_host = __esm({
10384
10450
  this.o = { ...o, kernel: { sys, call: call2 } };
10385
10451
  this.startCwd = o.cwd;
10386
10452
  this.fds = new WasiFds(this.o.kernel, o.fs);
10453
+ if (o.held) this.fds.held = o.held;
10387
10454
  this.creds = new CredCache(
10388
10455
  () => this.o.kernel.call({ op: "proc-cred" }),
10389
10456
  o.credGen ?? o.shared
@@ -11465,7 +11532,9 @@ var init_wasi_host = __esm({
11465
11532
  }
11466
11533
  readdir(fd, buf, len, cookie, usedPtr) {
11467
11534
  const dir = this.fds.dir(fd);
11468
- if (cookie === 0 || !dir.listing) dir.listing = this.list(dir.path);
11535
+ if (cookie === 0 || !dir.listing) {
11536
+ dir.listing = this.fds.goneCwd(dir) ? { names: [], stats: /* @__PURE__ */ new Map() } : this.list(dir.path);
11537
+ }
11469
11538
  const { names, stats } = dir.listing;
11470
11539
  let at = 0;
11471
11540
  for (let i = cookie; i < names.length && at < len; i++) {
@@ -14704,6 +14773,12 @@ function ownersOf(init) {
14704
14773
  ...init.changes ? { changes: init.changes } : {}
14705
14774
  };
14706
14775
  }
14776
+ function heldOf2(init, call2) {
14777
+ const { held: held2 } = init;
14778
+ if (!held2) return {};
14779
+ const ask = () => call2({ op: "cwd-check" });
14780
+ return { held: new HeldCwd(held2.sab, held2.slot, ask, { ...held2, path: init.cwd }) };
14781
+ }
14707
14782
  async function runWasiProcess(init, port2) {
14708
14783
  captureBacktraces(init.env);
14709
14784
  const signals = new WasiSignals(
@@ -14761,6 +14836,7 @@ async function runWasiProcess(init, port2) {
14761
14836
  call2
14762
14837
  ),
14763
14838
  ...descriptors(init, fork, threads),
14839
+ ...heldOf2(init, call2),
14764
14840
  ...threads ? { credGen: threads.ids } : {}
14765
14841
  });
14766
14842
  host.sigmask = sigmaskOf(module, init.sab, gate, threads);
@@ -14869,7 +14945,8 @@ async function runWasiThread(init, port2) {
14869
14945
  ),
14870
14946
  call2
14871
14947
  ),
14872
- shared: threads.ids
14948
+ shared: threads.ids,
14949
+ ...heldOf2(init, call2)
14873
14950
  });
14874
14951
  host.tid = thread.tid;
14875
14952
  host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
@@ -14920,6 +14997,7 @@ var init_wasi_runtime = __esm({
14920
14997
  "src/process/wasi/wasi-runtime.ts"() {
14921
14998
  "use strict";
14922
14999
  init_physical_path();
15000
+ init_held_cwd();
14923
15001
  init_protocol();
14924
15002
  init_signals();
14925
15003
  init_sync_sab_bridge();