@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.
@@ -968,6 +968,7 @@ function parseSyncFsStat(json2) {
968
968
  ...s.ranged === true ? { ranged: true } : {},
969
969
  ...s.linkable === true ? { linkable: true } : {},
970
970
  ...typeof s.version === "string" ? { version: s.version } : {},
971
+ ...typeof s.gen === "number" ? { gen: s.gen } : {},
971
972
  ...typeof s.uid === "number" ? { uid: s.uid } : {},
972
973
  ...typeof s.gid === "number" ? { gid: s.gid } : {}
973
974
  };
@@ -1317,9 +1318,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
1317
1318
  access: (path, mode, kind = "access", nofollow) => {
1318
1319
  run({ op: "access", path, mode, arg2: kind, ...nofollow ? { nofollow } : {} }, path);
1319
1320
  },
1320
- hold: (path, held2, open, handle, want = 0) => {
1321
+ hold: (path, held2, open, handle, want = 0, seen = {}) => {
1321
1322
  const mode = (held2 ? 1 : 0) | (open ? 2 : 0);
1322
- if (mode === 3) return json2({ op: "hold", path, mode: mode | want }, path);
1323
+ if (mode === 3) {
1324
+ const at = seen.gen !== void 0 ? { gen: seen.gen } : {};
1325
+ return json2({ op: "hold", path, mode: mode | want, ...at }, path);
1326
+ }
1323
1327
  run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
1324
1328
  return void 0;
1325
1329
  },
@@ -1882,6 +1886,16 @@ function appendThrough(h, stream, bytes) {
1882
1886
  stream.position = after - body.length;
1883
1887
  return true;
1884
1888
  }
1889
+ function holdLive(bridge, node, on, want) {
1890
+ const s = node.live;
1891
+ const seen = on && s.stat ? { gen: s.stat.gen } : void 0;
1892
+ return bridge.hold?.(liveNodePath(node), on, true, s.handle, want, seen);
1893
+ }
1894
+ function dropOpen(s) {
1895
+ if (s.openCount === 0) return false;
1896
+ s.openCount -= 1;
1897
+ return true;
1898
+ }
1885
1899
  function createStreamOps(h) {
1886
1900
  const { Fs, statOf, ensureLoaded, ensureCapacity, flushNode, bridgeOf, rangedOf } = h;
1887
1901
  const held2 = (stream, change) => {
@@ -1899,7 +1913,7 @@ function createStreamOps(h) {
1899
1913
  const opened2 = (node, on, want = 0) => {
1900
1914
  const s = node.live;
1901
1915
  try {
1902
- const handle = bridgeOf(node).hold?.(liveNodePath(node), on, true, s.handle, want);
1916
+ const handle = holdLive(bridgeOf(node), node, on, want);
1903
1917
  s.handle = on ? handle : void 0;
1904
1918
  h.linked.opening(node, on);
1905
1919
  if (s.handle === void 0) h.handled.delete(node);
@@ -1991,7 +2005,7 @@ function createStreamOps(h) {
1991
2005
  const node = stream.node;
1992
2006
  if (!Fs.isFile(node.mode)) return;
1993
2007
  const s = node.live;
1994
- s.openCount = Math.max(0, s.openCount - 1);
2008
+ if (!dropOpen(s)) return;
1995
2009
  if (s.openCount > 0) {
1996
2010
  held2(stream, -1);
1997
2011
  return;
@@ -2005,7 +2019,7 @@ function createStreamOps(h) {
2005
2019
  s.len = 0;
2006
2020
  s.loaded = false;
2007
2021
  held2(stream, -1);
2008
- opened2(node, false);
2022
+ if (s.handle !== void 0) opened2(node, false);
2009
2023
  }
2010
2024
  },
2011
2025
  read(stream, buffer, offset, length, position) {
@@ -2610,7 +2624,7 @@ var KERNEL_VERSION, OS_RELEASE;
2610
2624
  var init_version = __esm({
2611
2625
  "src/version.ts"() {
2612
2626
  "use strict";
2613
- KERNEL_VERSION = true ? "1.124.7" : "0.0.0-dev";
2627
+ KERNEL_VERSION = true ? "1.124.8" : "0.0.0-dev";
2614
2628
  OS_RELEASE = "6.0.0-slicc";
2615
2629
  }
2616
2630
  });
@@ -4415,18 +4429,28 @@ function orphanContents(stream) {
4415
4429
  if (live.ranged) return live.ranged.read(0, live.ranged.size());
4416
4430
  return live.data?.slice(0, live.len ?? live.data.length) ?? new Uint8Array(0);
4417
4431
  }
4432
+ function heldOf(live) {
4433
+ const ranged = live?.ranged;
4434
+ const version = ranged?.pinnedVersion;
4435
+ const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
4436
+ const handle = live?.handle;
4437
+ const ino = live?.stat?.ino;
4438
+ return {
4439
+ ...pin ? { pin } : {},
4440
+ ...handle !== void 0 ? { handle } : {},
4441
+ ...handle !== void 0 && ino !== void 0 ? { ino } : {}
4442
+ };
4443
+ }
4418
4444
  function vfsPromoter(Fs, sys, streams2, livePath) {
4419
4445
  const promoted = /* @__PURE__ */ new Map();
4420
4446
  return (stream) => {
4421
4447
  if (stream.sliccKernelFd !== void 0 || !isVfsFile(Fs, stream)) return;
4448
+ const live = stream.stream_ops;
4422
4449
  let kfd = promoted.get(stream.shared);
4423
4450
  if (kfd === void 0) {
4451
+ live.fsync?.(stream);
4424
4452
  const contents = orphanContents(stream);
4425
- const ranged = stream.node.live?.ranged;
4426
- const version = ranged?.pinnedVersion;
4427
- const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
4428
- const handle = stream.node.live?.handle;
4429
- const held2 = { ...pin ? { pin } : {}, ...handle !== void 0 ? { handle } : {} };
4453
+ const held2 = heldOf(stream.node.live);
4430
4454
  kfd = sys.openVfs(
4431
4455
  livePath(stream),
4432
4456
  stream.flags,
@@ -5698,6 +5722,7 @@ function kernelSys(transport) {
5698
5722
  ...opts?.created ? { created: true } : {},
5699
5723
  ...opts?.pin ? { pin: opts.pin } : {},
5700
5724
  ...opts?.handle !== void 0 ? { handle: opts.handle } : {},
5725
+ ...opts?.ino !== void 0 ? { ino: opts.ino } : {},
5701
5726
  ...opts?.fifo ? { fifo: true } : {}
5702
5727
  },
5703
5728
  `fd-open-vfs ${path}`
@@ -7355,7 +7380,8 @@ function promoteRequest(fd, f, handed) {
7355
7380
  ...orphan ? { orphan: true } : {},
7356
7381
  ...!orphan && f.buffer.pin !== void 0 ? { pin: { version: f.buffer.pin, size: f.buffer.size() } } : {},
7357
7382
  ...!joins && f.buffer.isDirty() ? { dirty: true } : {},
7358
- ...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {}
7383
+ ...f.buffer.handle !== void 0 ? { handle: f.buffer.handle } : {},
7384
+ ...f.buffer.handle !== void 0 && f.ino !== void 0 ? { ino: f.ino } : {}
7359
7385
  };
7360
7386
  }
7361
7387
  var SYNTHETIC_DIRS2, O_NONBLOCK2, O_WRONLY4, O_RDWR4, O_APPEND2, SEALED_PATH2, CLIPBOARD_PATH2, WasiFds, GEN2;
@@ -8031,7 +8057,9 @@ var init_wasi_fds = __esm({
8031
8057
  const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
8032
8058
  const ranged = st.ranged ? st.size : void 0;
8033
8059
  const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
8034
- const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0);
8060
+ const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0, {
8061
+ gen: st.gen
8062
+ });
8035
8063
  const io = handle !== void 0 && this.fs.pinned ? this.fs.pinned(handle) : this.fs;
8036
8064
  const view = this.fs.changes;
8037
8065
  const watch = view && linkedWatch(
@@ -10969,10 +10997,10 @@ function procfsBridge(fs, tree) {
10969
10997
  ],
10970
10998
  () => fs.link(from, to, follow2)
10971
10999
  ),
10972
- hold: (p, held2, open, handle, want) => {
11000
+ hold: (p, held2, open, handle, want, seen) => {
10973
11001
  if (handle !== void 0 && snapshots.delete(handle)) return void 0;
10974
11002
  if (!held2) return fs.hold?.(p, held2, open, handle);
10975
- return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want) ?? late(p));
11003
+ return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
10976
11004
  },
10977
11005
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
10978
11006
  pinned: (handle) => {