@ai-ecoverse/slicc-kernel 1.61.1 → 1.61.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.
@@ -5661,9 +5661,34 @@ var init_wasi_fds = __esm({
5661
5661
  }
5662
5662
  if (!s && !(oflags & OFLAGS.CREAT)) throw new WasiError("ENOENT");
5663
5663
  refuseWrite(s, oflags, rights);
5664
- if (this.shared) return this.kernelFile(path, s, oflags, rights, fdflags);
5664
+ return this.regular(path, s, oflags, rights, fdflags);
5665
+ }
5666
+ regular(path, s, oflags, rights, fdflags) {
5667
+ if (this.shared || this.kernelHolds(path, s)) {
5668
+ return this.kernelFile(path, s, oflags, rights, fdflags);
5669
+ }
5665
5670
  return this.install({ type: "file", file: this.file(path, s, oflags, rights, fdflags) });
5666
5671
  }
5672
+ kernelHolds(path, st) {
5673
+ for (const [fd, e] of this.table) {
5674
+ if (e.type !== "kernel" || this.kind(fd, e) !== "file") continue;
5675
+ this.named(fd, e);
5676
+ if (e.path === path || st?.ino !== void 0 && e.ino === st.ino) return true;
5677
+ }
5678
+ return false;
5679
+ }
5680
+ learned = /* @__PURE__ */ new WeakSet();
5681
+ named(fd, e) {
5682
+ if (e.path !== void 0 || this.learned.has(e)) return;
5683
+ this.learned.add(e);
5684
+ try {
5685
+ const vfs = this.kernel.call({ op: "fd-vfs-stat", fd });
5686
+ if (vfs.orphan || vfs.path === void 0) return;
5687
+ e.path = vfs.path;
5688
+ e.ino = this.inoOf(vfs.path);
5689
+ } catch {
5690
+ }
5691
+ }
5667
5692
  file(path, existing, oflags, rights, fdflags) {
5668
5693
  const { readable: readable2, writable: writable2 } = openAccess(existing, oflags, rights);
5669
5694
  let buffer = this.buffers.get(path);