@ai-ecoverse/slicc-kernel 1.61.0 → 1.61.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.
@@ -621,6 +621,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
621
621
  lutimes: (p, a, m) => mutating(() => bridge.lutimes(p, a, m), p),
622
622
  ...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
623
623
  ...bridge.kept ? { kept: bridge.kept.bind(bridge) } : {},
624
+ ...bridge.keptStat ? { keptStat: bridge.keptStat.bind(bridge) } : {},
624
625
  ...bridge.pinned ? { pinned: (handle) => pinnedIo(bridge, handle, rewriting) } : {},
625
626
  ...bridge.create ? { create: (p) => mutating(() => bridge.create?.(p), ...entry(p)) } : {},
626
627
  ...chown ? {
@@ -2746,16 +2747,41 @@ var init_wasi_host = __esm({
2746
2747
  fdFilestat(fd) {
2747
2748
  const e = this.fds.get(fd);
2748
2749
  if (e.type === "dir") return filestatOf(e.path, this.o.fs.stat(e.path));
2749
- if (e.type === "file") return this.statOrphanable(e.file.path, e.file.size());
2750
+ if (e.type === "file") return this.localFilestat(e.file);
2750
2751
  const kind = e.type === "kernel" ? this.fds.kind(fd, e) : void 0;
2751
2752
  if (kind === "file") {
2752
2753
  const vfs = this.kernelStat(fd);
2753
- if (vfs.path) return this.statOrphanable(vfs.path, vfs.size, vfs.orphan);
2754
+ if (vfs.path) return this.statOrphanable(vfs.path, vfs.size, vfs.orphan, vfs.orphan);
2754
2755
  }
2755
2756
  const filetype = kind ? kernelFiletype(kind).filetype : FILETYPE.CHARACTER_DEVICE;
2756
2757
  return this.local({ filetype, size: 0n, ino: BigInt(fd + 1), mtimeNs: 0n });
2757
2758
  }
2758
- statOrphanable(path, size, orphan = false) {
2759
+ localFilestat(file) {
2760
+ const { buffer } = file;
2761
+ if (buffer.isOrphan()) return this.statOrphanable(file.path, file.size(), false, true);
2762
+ let s;
2763
+ try {
2764
+ s = this.o.fs.stat(file.path);
2765
+ } catch {
2766
+ s = this.keptStat(buffer.handle);
2767
+ }
2768
+ return this.sized(file.path, s, file.size());
2769
+ }
2770
+ keptStat(handle) {
2771
+ if (handle === void 0) return void 0;
2772
+ try {
2773
+ return this.o.fs.keptStat?.(handle);
2774
+ } catch {
2775
+ return void 0;
2776
+ }
2777
+ }
2778
+ sized(path, s, size) {
2779
+ return {
2780
+ ...filestatOf(path, s ?? { isFile: true, isDirectory: false, size: 0 }),
2781
+ size: BigInt(size)
2782
+ };
2783
+ }
2784
+ statOrphanable(path, size, orphan = false, gone = false) {
2759
2785
  let s;
2760
2786
  if (!orphan) {
2761
2787
  try {
@@ -2763,10 +2789,8 @@ var init_wasi_host = __esm({
2763
2789
  } catch {
2764
2790
  }
2765
2791
  }
2766
- return {
2767
- ...filestatOf(path, s ?? { isFile: true, isDirectory: false, size: 0 }),
2768
- size: BigInt(size)
2769
- };
2792
+ const out = this.sized(path, s, size);
2793
+ return gone ? { ...out, nlink: 0n } : out;
2770
2794
  }
2771
2795
  pathFilestat(path, lookup) {
2772
2796
  if (deviceOf(path)) {
@@ -4503,6 +4527,11 @@ function createSyncFsSabBridge(transport, opts = {}) {
4503
4527
  ...io({}),
4504
4528
  pinned: (handle) => io({ handle }),
4505
4529
  kept: (handle) => json({ op: "kept", path: "/", handle }, "/") === true,
4530
+ keptStat: (handle) => {
4531
+ const s = parseSyncFsStat(json({ op: "stat", path: "/", handle }, "/"));
4532
+ if (!s) throw errnoError("EIO", "/");
4533
+ return s;
4534
+ },
4506
4535
  stat: (path) => {
4507
4536
  const s = parseSyncFsStat(json({ op: "stat", path }, path));
4508
4537
  if (!s) throw errnoError("EIO", path);