@ai-ecoverse/slicc-kernel 1.124.6 → 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.6" : "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) {
@@ -9368,11 +9385,14 @@ function useZeroDevices(Fs) {
9368
9385
  mkdev.call(Fs, path, CHAR_DEVICE, dev);
9369
9386
  }
9370
9387
  }
9371
- function namesFifo(fs, path) {
9388
+ function namesFifo(fs, path, flags) {
9372
9389
  try {
9373
9390
  const { node } = fs.lookupPath?.(path, { follow: true }) ?? { node: { mode: 0 } };
9374
9391
  return (node.mode & S_IFMT_BITS) === S_IFIFO_BITS;
9375
- } catch {
9392
+ } catch (err) {
9393
+ const { errno: errno2, code: code2 } = err ?? {};
9394
+ const errnum = typeof errno2 === "number" ? errno2 : wasiErrno(String(code2));
9395
+ if (REFUSED.has(errnum) && (flags & OWN_ERRORS) === 0) throw err;
9376
9396
  return false;
9377
9397
  }
9378
9398
  }
@@ -9383,7 +9403,7 @@ function useFifoOpens(Fs, attach) {
9383
9403
  if (typeof open !== "function" || typeof fs.lookupPath !== "function") return;
9384
9404
  fs.open = (path, flags, ...rest2) => {
9385
9405
  const truncates = typeof path === "string" && typeof flags === "number" && flags & O_TRUNC2;
9386
- const kept = truncates && namesFifo(fs, path) ? flags & ~O_TRUNC2 : flags;
9406
+ const kept = truncates && namesFifo(fs, path, flags) ? flags & ~O_TRUNC2 : flags;
9387
9407
  return open.call(Fs, path, kept, ...rest2);
9388
9408
  };
9389
9409
  }
@@ -9698,7 +9718,7 @@ function linuxDevices(Fs) {
9698
9718
  }
9699
9719
  }
9700
9720
  }
9701
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY5, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_TRUNC2, S_IFMT_BITS, S_IFIFO_BITS, O_ACCMODE3, O_CREAT, O_EXCL, field, pinnedRoot, rootKind, NAME, AT_FDCWD2, AT_EACCESS2, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
9721
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY5, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_TRUNC2, S_IFMT_BITS, S_IFIFO_BITS, REFUSED, OWN_ERRORS, O_ACCMODE3, O_CREAT, O_EXCL, field, pinnedRoot, rootKind, NAME, AT_FDCWD2, AT_EACCESS2, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, UTS_FIELD, DEVICE_MODES;
9702
9722
  var init_process_fds = __esm({
9703
9723
  "src/process/process-fds.ts"() {
9704
9724
  "use strict";
@@ -9760,6 +9780,8 @@ var init_process_fds = __esm({
9760
9780
  O_TRUNC2 = 512;
9761
9781
  S_IFMT_BITS = 61440;
9762
9782
  S_IFIFO_BITS = 4096;
9783
+ REFUSED = /* @__PURE__ */ new Set([wasiErrno("EACCES"), wasiErrno("EPERM")]);
9784
+ OWN_ERRORS = 128 | 131072;
9763
9785
  O_ACCMODE3 = 3;
9764
9786
  O_CREAT = 64;
9765
9787
  O_EXCL = 128;
@@ -10389,10 +10411,10 @@ function procfsBridge(fs, tree) {
10389
10411
  ],
10390
10412
  () => fs.link(from, to, follow2)
10391
10413
  ),
10392
- hold: (p, held2, open, handle, want) => {
10414
+ hold: (p, held2, open, handle, want, seen) => {
10393
10415
  if (handle !== void 0 && snapshots.delete(handle)) return void 0;
10394
10416
  if (!held2) return fs.hold?.(p, held2, open, handle);
10395
- 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));
10396
10418
  },
10397
10419
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
10398
10420
  pinned: (handle) => {
@@ -12870,18 +12892,28 @@ function orphanContents(stream) {
12870
12892
  if (live.ranged) return live.ranged.read(0, live.ranged.size());
12871
12893
  return live.data?.slice(0, live.len ?? live.data.length) ?? new Uint8Array(0);
12872
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
+ }
12873
12907
  function vfsPromoter(Fs, sys, streams2, livePath) {
12874
12908
  const promoted = /* @__PURE__ */ new Map();
12875
12909
  return (stream) => {
12876
12910
  if (stream.sliccKernelFd !== void 0 || !isVfsFile(Fs, stream)) return;
12911
+ const live = stream.stream_ops;
12877
12912
  let kfd = promoted.get(stream.shared);
12878
12913
  if (kfd === void 0) {
12914
+ live.fsync?.(stream);
12879
12915
  const contents = orphanContents(stream);
12880
- const ranged = stream.node.live?.ranged;
12881
- const version = ranged?.pinnedVersion;
12882
- const pin = ranged && version !== void 0 ? { version, size: ranged.size() } : void 0;
12883
- const handle = stream.node.live?.handle;
12884
- const held2 = { ...pin ? { pin } : {}, ...handle !== void 0 ? { handle } : {} };
12916
+ const held2 = heldOf(stream.node.live);
12885
12917
  kfd = sys.openVfs(
12886
12918
  livePath(stream),
12887
12919
  stream.flags,
@@ -13722,6 +13754,7 @@ function kernelSys(transport) {
13722
13754
  ...opts?.created ? { created: true } : {},
13723
13755
  ...opts?.pin ? { pin: opts.pin } : {},
13724
13756
  ...opts?.handle !== void 0 ? { handle: opts.handle } : {},
13757
+ ...opts?.ino !== void 0 ? { ino: opts.ino } : {},
13725
13758
  ...opts?.fifo ? { fifo: true } : {}
13726
13759
  },
13727
13760
  `fd-open-vfs ${path}`