@ai-ecoverse/slicc-kernel 1.124.7 → 1.124.8

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.
@@ -600,6 +600,7 @@ function parseSyncFsStat(json2) {
600
600
  ...s.ranged === true ? { ranged: true } : {},
601
601
  ...s.linkable === true ? { linkable: true } : {},
602
602
  ...typeof s.version === "string" ? { version: s.version } : {},
603
+ ...typeof s.gen === "number" ? { gen: s.gen } : {},
603
604
  ...typeof s.uid === "number" ? { uid: s.uid } : {},
604
605
  ...typeof s.gid === "number" ? { gid: s.gid } : {}
605
606
  };
@@ -1984,7 +1985,8 @@ function promoteRequest(fd, f, handed) {
1984
1985
  ...orphan ? { orphan: true } : {},
1985
1986
  ...!orphan && f.buffer.pin !== void 0 ? { pin: { version: f.buffer.pin, size: f.buffer.size() } } : {},
1986
1987
  ...!joins && f.buffer.isDirty() ? { dirty: true } : {},
1987
- ...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {}
1988
+ ...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {},
1989
+ ...f.buffer.handle !== void 0 && f.ino !== void 0 ? { ino: f.ino } : {}
1988
1990
  };
1989
1991
  }
1990
1992
  var SYNTHETIC_DIRS, O_NONBLOCK, O_WRONLY, O_RDWR, O_APPEND, SEALED_PATH, CLIPBOARD_PATH, WasiFds, GEN;
@@ -2660,7 +2662,9 @@ var init_wasi_fds = __esm({
2660
2662
  const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
2661
2663
  const ranged = st.ranged ? st.size : void 0;
2662
2664
  const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
2663
- const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0);
2665
+ const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0, {
2666
+ gen: st.gen
2667
+ });
2664
2668
  const io = handle !== void 0 && this.fs.pinned ? this.fs.pinned(handle) : this.fs;
2665
2669
  const view = this.fs.changes;
2666
2670
  const watch = view && linkedWatch(
@@ -5434,7 +5438,7 @@ var KERNEL_VERSION, OS_RELEASE;
5434
5438
  var init_version = __esm({
5435
5439
  "src/version.ts"() {
5436
5440
  "use strict";
5437
- KERNEL_VERSION = true ? "1.124.7" : "0.0.0-dev";
5441
+ KERNEL_VERSION = true ? "1.124.8" : "0.0.0-dev";
5438
5442
  OS_RELEASE = "6.0.0-slicc";
5439
5443
  }
5440
5444
  });
@@ -7538,9 +7542,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
7538
7542
  access: (path, mode, kind = "access", nofollow) => {
7539
7543
  run({ op: "access", path, mode, arg2: kind, ...nofollow ? { nofollow } : {} }, path);
7540
7544
  },
7541
- hold: (path, held2, open, handle, want = 0) => {
7545
+ hold: (path, held2, open, handle, want = 0, seen = {}) => {
7542
7546
  const mode = (held2 ? 1 : 0) | (open ? 2 : 0);
7543
- if (mode === 3) return json2({ op: "hold", path, mode: mode | want }, path);
7547
+ if (mode === 3) {
7548
+ const at = seen.gen !== void 0 ? { gen: seen.gen } : {};
7549
+ return json2({ op: "hold", path, mode: mode | want, ...at }, path);
7550
+ }
7544
7551
  run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
7545
7552
  return void 0;
7546
7553
  },
@@ -8103,6 +8110,16 @@ function appendThrough(h, stream, bytes) {
8103
8110
  stream.position = after - body.length;
8104
8111
  return true;
8105
8112
  }
8113
+ function holdLive(bridge, node, on, want) {
8114
+ const s = node.live;
8115
+ const seen = on && s.stat ? { gen: s.stat.gen } : void 0;
8116
+ return bridge.hold?.(liveNodePath(node), on, true, s.handle, want, seen);
8117
+ }
8118
+ function dropOpen(s) {
8119
+ if (s.openCount === 0) return false;
8120
+ s.openCount -= 1;
8121
+ return true;
8122
+ }
8106
8123
  function createStreamOps(h) {
8107
8124
  const { Fs, statOf, ensureLoaded, ensureCapacity, flushNode, bridgeOf, rangedOf } = h;
8108
8125
  const held2 = (stream, change) => {
@@ -8120,7 +8137,7 @@ function createStreamOps(h) {
8120
8137
  const opened2 = (node, on, want = 0) => {
8121
8138
  const s = node.live;
8122
8139
  try {
8123
- const handle = bridgeOf(node).hold?.(liveNodePath(node), on, true, s.handle, want);
8140
+ const handle = holdLive(bridgeOf(node), node, on, want);
8124
8141
  s.handle = on ? handle : void 0;
8125
8142
  h.linked.opening(node, on);
8126
8143
  if (s.handle === void 0) h.handled.delete(node);
@@ -8212,7 +8229,7 @@ function createStreamOps(h) {
8212
8229
  const node = stream.node;
8213
8230
  if (!Fs.isFile(node.mode)) return;
8214
8231
  const s = node.live;
8215
- s.openCount = Math.max(0, s.openCount - 1);
8232
+ if (!dropOpen(s)) return;
8216
8233
  if (s.openCount > 0) {
8217
8234
  held2(stream, -1);
8218
8235
  return;
@@ -8226,7 +8243,7 @@ function createStreamOps(h) {
8226
8243
  s.len = 0;
8227
8244
  s.loaded = false;
8228
8245
  held2(stream, -1);
8229
- opened2(node, false);
8246
+ if (s.handle !== void 0) opened2(node, false);
8230
8247
  }
8231
8248
  },
8232
8249
  read(stream, buffer, offset, length, position) {
@@ -10394,10 +10411,10 @@ function procfsBridge(fs, tree) {
10394
10411
  ],
10395
10412
  () => fs.link(from, to, follow2)
10396
10413
  ),
10397
- hold: (p, held2, open, handle, want) => {
10414
+ hold: (p, held2, open, handle, want, seen) => {
10398
10415
  if (handle !== void 0 && snapshots.delete(handle)) return void 0;
10399
10416
  if (!held2) return fs.hold?.(p, held2, open, handle);
10400
- return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want) ?? late(p));
10417
+ return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
10401
10418
  },
10402
10419
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
10403
10420
  pinned: (handle) => {
@@ -12875,18 +12892,28 @@ function orphanContents(stream) {
12875
12892
  if (live.ranged) return live.ranged.read(0, live.ranged.size());
12876
12893
  return live.data?.slice(0, live.len ?? live.data.length) ?? new Uint8Array(0);
12877
12894
  }
12895
+ function heldOf(live) {
12896
+ const ranged = live?.ranged;
12897
+ const version = ranged?.pinnedVersion;
12898
+ const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
12899
+ const handle = live?.handle;
12900
+ const ino = live?.stat?.ino;
12901
+ return {
12902
+ ...pin ? { pin } : {},
12903
+ ...handle !== void 0 ? { handle } : {},
12904
+ ...handle !== void 0 && ino !== void 0 ? { ino } : {}
12905
+ };
12906
+ }
12878
12907
  function vfsPromoter(Fs, sys, streams2, livePath) {
12879
12908
  const promoted = /* @__PURE__ */ new Map();
12880
12909
  return (stream) => {
12881
12910
  if (stream.sliccKernelFd !== void 0 || !isVfsFile(Fs, stream)) return;
12911
+ const live = stream.stream_ops;
12882
12912
  let kfd = promoted.get(stream.shared);
12883
12913
  if (kfd === void 0) {
12914
+ live.fsync?.(stream);
12884
12915
  const contents = orphanContents(stream);
12885
- const ranged = stream.node.live?.ranged;
12886
- const version = ranged?.pinnedVersion;
12887
- const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
12888
- const handle = stream.node.live?.handle;
12889
- const held2 = { ...pin ? { pin } : {}, ...handle !== void 0 ? { handle } : {} };
12916
+ const held2 = heldOf(stream.node.live);
12890
12917
  kfd = sys.openVfs(
12891
12918
  livePath(stream),
12892
12919
  stream.flags,
@@ -13727,6 +13754,7 @@ function kernelSys(transport) {
13727
13754
  ...opts?.created ? { created: true } : {},
13728
13755
  ...opts?.pin ? { pin: opts.pin } : {},
13729
13756
  ...opts?.handle !== void 0 ? { handle: opts.handle } : {},
13757
+ ...opts?.ino !== void 0 ? { ino: opts.ino } : {},
13730
13758
  ...opts?.fifo ? { fifo: true } : {}
13731
13759
  },
13732
13760
  `fd-open-vfs ${path}`