@ai-ecoverse/slicc-kernel 1.141.1 → 1.141.3

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.
@@ -899,7 +899,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
899
899
  const live = (miss, path) => miss.until > now() && young2(miss) && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
900
900
  const seen = new SeenAt(view, lstats);
901
901
  const kept = remember(cache, seen, blind, (entry2) => filled2.set(entry2));
902
- const gone = (path) => goneAbove([lstats, stats], live, path);
902
+ const gone2 = (path) => goneAbove([lstats, stats], live, path);
903
903
  const usable = (map, path) => {
904
904
  const hit = map.get(path);
905
905
  if (hit === void 0) return void 0;
@@ -911,7 +911,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
911
911
  cache.fresh();
912
912
  let hit = usable(map, path);
913
913
  if (hit === void 0) {
914
- const missing2 = gone(path);
914
+ const missing2 = gone2(path);
915
915
  if (missing2) throw missing2.error;
916
916
  hit = fetched({ view, now, seen, filled: filled2, cache }, map, path, get);
917
917
  }
@@ -978,8 +978,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
978
978
  readlink: (p) => {
979
979
  const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
980
980
  const gen = seen.lstat(p);
981
- const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
982
- if (known && current && !("until" in known) && young2(known) && !known.isSymbolicLink) {
981
+ const current2 = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
982
+ if (known && current2 && !("until" in known) && young2(known) && !known.isSymbolicLink) {
983
983
  throw syncError("EINVAL", `'${p}' is not a symbolic link`);
984
984
  }
985
985
  return bridge.readlink(p);
@@ -2224,8 +2224,8 @@ var init_js_kernel = __esm({
2224
2224
  }
2225
2225
  async report(handlers, ignored, defaults) {
2226
2226
  const caught = caughtOf(handlers);
2227
- const same = caught === this.reported.caught && ignored === this.reported.ignored;
2228
- if (same && defaults === 0) return;
2227
+ const same2 = caught === this.reported.caught && ignored === this.reported.ignored;
2228
+ if (same2 && defaults === 0) return;
2229
2229
  this.reported = { caught, ignored };
2230
2230
  await this.call({ op: "sig-mask", caught, ignored, ...defaults ? { defaults } : {} });
2231
2231
  }
@@ -3699,6 +3699,10 @@ var init_wasi_fds = __esm({
3699
3699
  if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
3700
3700
  const s = this.statOrMissing(path);
3701
3701
  if (exclusive && s) throw new WasiError("EEXIST");
3702
+ if (s?.escape !== void 0) {
3703
+ refuseWrite({ readonly: true }, oflags, rights);
3704
+ return this.open(s.escape, oflags, rights, fdflags, mode);
3705
+ }
3702
3706
  if (oflags & OFLAGS.DIRECTORY && !s?.isDirectory) {
3703
3707
  throw new WasiError(s ? "ENOTDIR" : "ENOENT");
3704
3708
  }
@@ -5924,7 +5928,7 @@ var init_wasi_host = __esm({
5924
5928
  size: BigInt(size)
5925
5929
  };
5926
5930
  }
5927
- statOrphanable(path, size, orphan = false, gone = false) {
5931
+ statOrphanable(path, size, orphan = false, gone2 = false) {
5928
5932
  let s;
5929
5933
  if (!orphan) {
5930
5934
  try {
@@ -5933,7 +5937,7 @@ var init_wasi_host = __esm({
5933
5937
  }
5934
5938
  }
5935
5939
  const out = this.sized(path, s, size);
5936
- return gone ? { ...out, nlink: 0n } : out;
5940
+ return gone2 ? { ...out, nlink: 0n } : out;
5937
5941
  }
5938
5942
  synthetic(path) {
5939
5943
  return deviceOf(path) !== void 0 || path === SEALED_PATH && !!this.o.kernel.sys.openSealed || path === CLIPBOARD_PATH && !!this.o.kernel.sys.openClipboard;
@@ -6087,11 +6091,11 @@ var init_wasi_host = __esm({
6087
6091
  const asked = FSTFLAGS.ATIM | FSTFLAGS.ATIM_NOW | FSTFLAGS.MTIM | FSTFLAGS.MTIM_NOW;
6088
6092
  if (this.o.fs.owners && (flags & asked) === 0) return;
6089
6093
  const now = Date.now();
6090
- let current;
6094
+ let current2;
6091
6095
  const statOf = follow3 ? this.o.fs.stat.bind(this.o.fs) : this.o.fs.lstat.bind(this.o.fs);
6092
6096
  const kept = (field2) => {
6093
- current ??= statOf(path);
6094
- return current[field2] ?? current.mtimeMs ?? now;
6097
+ current2 ??= statOf(path);
6098
+ return current2[field2] ?? current2.mtimeMs ?? now;
6095
6099
  };
6096
6100
  const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS4) : kept(field2);
6097
6101
  (follow3 ? this.o.fs.utimes : this.o.fs.lutimes).call(
@@ -6721,7 +6725,7 @@ var KERNEL_VERSION, OS_RELEASE;
6721
6725
  var init_version = __esm({
6722
6726
  "src/version.ts"() {
6723
6727
  "use strict";
6724
- KERNEL_VERSION = true ? "1.141.1" : "0.0.0-dev";
6728
+ KERNEL_VERSION = true ? "1.141.3" : "0.0.0-dev";
6725
6729
  OS_RELEASE = "6.0.0-slicc";
6726
6730
  }
6727
6731
  });
@@ -7814,6 +7818,10 @@ function mayTrace(viewer, target) {
7814
7818
  const uid = of.ruid === by.euid && of.euid === by.euid && of.suid === by.euid;
7815
7819
  return uid && of.rgid === by.egid && of.egid === by.egid && of.sgid === by.egid;
7816
7820
  }
7821
+ function fileIdentity(ino, mtimeMs) {
7822
+ if (ino === void 0 || mtimeMs === void 0 || !Number.isFinite(mtimeMs)) return void 0;
7823
+ return `${ino}:${Math.trunc(mtimeMs)}`;
7824
+ }
7817
7825
  var init_proc_info = __esm({
7818
7826
  "src/kernel/proc-info.ts"() {
7819
7827
  "use strict";
@@ -8248,6 +8256,9 @@ function refusal(err) {
8248
8256
  const code2 = err?.code;
8249
8257
  return code2 === "EACCES" || code2 === "EPERM";
8250
8258
  }
8259
+ function gone(err) {
8260
+ return err?.code === "ENOENT";
8261
+ }
8251
8262
  function young(s) {
8252
8263
  return performance.now() - (s.filledAt ?? Number.NEGATIVE_INFINITY) < SHARED_TTL_MS;
8253
8264
  }
@@ -8765,7 +8776,9 @@ function createStreamOps(h) {
8765
8776
  if (s.handle === void 0) h.handled.delete(node);
8766
8777
  else h.handled.add(node);
8767
8778
  } catch (err) {
8768
- if (refusal(err)) throw new Fs.ErrnoError(wasiErrno(err.code));
8779
+ if (refusal(err) || gone(err)) {
8780
+ throw new Fs.ErrnoError(wasiErrno(err.code));
8781
+ }
8769
8782
  }
8770
8783
  };
8771
8784
  const permitted = (stream, created) => {
@@ -10792,15 +10805,15 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
10792
10805
  readdir: (node) => listAll(node)
10793
10806
  };
10794
10807
  const track = (stream, names) => {
10795
- let current = names;
10808
+ let current2 = names;
10796
10809
  const remember2 = (list) => scans.set(stream, new Set(list.filter((n) => /^[1-9]\d*$/.test(n)).map(Number)));
10797
- remember2(current ?? []);
10810
+ remember2(current2 ?? []);
10798
10811
  Object.defineProperty(stream, "getdents", {
10799
10812
  configurable: true,
10800
10813
  enumerable: true,
10801
- get: () => current,
10814
+ get: () => current2,
10802
10815
  set: (next2) => {
10803
- current = next2;
10816
+ current2 = next2;
10804
10817
  if (next2) remember2(next2);
10805
10818
  }
10806
10819
  });
@@ -10998,10 +11011,40 @@ function directMiss(err, path) {
10998
11011
  if (err?.direct !== true) return false;
10999
11012
  return !path.split("/").some((part) => part === "." || part === "..");
11000
11013
  }
11001
- function routing(tree, toProc, shadowing) {
11014
+ function same(fs, path, id) {
11015
+ try {
11016
+ const st = fs.stat(path);
11017
+ const now = fileIdentity(st.ino, st.mtimeMs);
11018
+ return now === void 0 || now === id;
11019
+ } catch {
11020
+ return false;
11021
+ }
11022
+ }
11023
+ function current(fs, tree, q) {
11024
+ const to = tree.escapeTo(q);
11025
+ if (!to || to.id === void 0) return to?.target;
11026
+ if (!same(fs, to.target, to.id)) throw syncError("ENOENT", q);
11027
+ return to.target;
11028
+ }
11029
+ function guard(toProc, shadowing) {
11030
+ return (paths, run) => {
11031
+ const physical2 = shadowing();
11032
+ for (const [p, follow3] of paths) {
11033
+ if (inProc(p) || physical2 && toProc(p, follow3) !== void 0) throw syncError("EROFS", p);
11034
+ }
11035
+ return run();
11036
+ };
11037
+ }
11038
+ function shownLink(fs, tree, q) {
11039
+ const target = tree.readlink(q);
11040
+ const to = tree.linkTo(q);
11041
+ if (!to) return target;
11042
+ return same(fs, to.target, to.id) ? target : `${target} (deleted)`;
11043
+ }
11044
+ function routing(fs, tree, toProc, shadowing) {
11002
11045
  return (p, inner, own, follow3 = true, outside) => {
11003
11046
  const proc = (q) => {
11004
- const target = outside ? tree.escape(q) : void 0;
11047
+ const target = outside ? current(fs, tree, q) : void 0;
11005
11048
  return target === void 0 ? inner(q) : outside(target);
11006
11049
  };
11007
11050
  if (inProc(p)) return proc(p);
@@ -11022,14 +11065,8 @@ function routing(tree, toProc, shadowing) {
11022
11065
  function procfsBridge(fs, tree) {
11023
11066
  const toProc = (path, follow3) => procPath(fs, path, follow3);
11024
11067
  const shadowing = physicalProc(fs);
11025
- const via = routing(tree, toProc, shadowing);
11026
- const readOnly2 = (paths, run) => {
11027
- const physical2 = shadowing();
11028
- for (const [p, follow3] of paths) {
11029
- if (inProc(p) || physical2 && toProc(p, follow3) !== void 0) throw syncError("EROFS", p);
11030
- }
11031
- return run();
11032
- };
11068
+ const via = routing(fs, tree, toProc, shadowing);
11069
+ const readOnly2 = guard(toProc, shadowing);
11033
11070
  const snapshots = /* @__PURE__ */ new Map();
11034
11071
  let lastSnapshot = 0;
11035
11072
  const snapshot = (q) => {
@@ -11054,7 +11091,7 @@ function procfsBridge(fs, tree) {
11054
11091
  (q) => tree.stat(q),
11055
11092
  () => fs.stat(p),
11056
11093
  true,
11057
- (t) => fs.stat(t)
11094
+ (t) => ({ ...fs.stat(t), escape: t })
11058
11095
  ),
11059
11096
  lstat: (p) => via(
11060
11097
  p,
@@ -11093,7 +11130,7 @@ function procfsBridge(fs, tree) {
11093
11130
  },
11094
11131
  readlink: (p) => via(
11095
11132
  p,
11096
- (q) => tree.readlink(q),
11133
+ (q) => shownLink(fs, tree, q),
11097
11134
  () => fs.readlink(p),
11098
11135
  false
11099
11136
  ),
@@ -11133,7 +11170,7 @@ function procfsBridge(fs, tree) {
11133
11170
  return via(p, snapshot, () => fs.hold?.(p, held2, open, void 0, want, seen) ?? late(p));
11134
11171
  },
11135
11172
  kept: (handle) => snapshots.has(handle) || fs.kept?.(handle) === true,
11136
- escape: (p) => inProc(p) ? tree.escape(p) : void 0,
11173
+ escape: (p) => inProc(p) ? current(fs, tree, p) : void 0,
11137
11174
  pinned: (handle) => {
11138
11175
  const bytes = snapshots.get(handle);
11139
11176
  return bytes ? frozen(bytes) : fs.pinned?.(handle) ?? fs;
@@ -11233,12 +11270,7 @@ var init_wasi_procfs = __esm({
11233
11270
  const exe = () => this.info(Number(top))?.exe === void 0 ? [] : ["exe"];
11234
11271
  return { kind: "dir", names: () => [...PID_NAMES, ...exe(), "task"] };
11235
11272
  }
11236
- if (leaf === "exe") {
11237
- const info = this.info(Number(top));
11238
- if (info?.exe === void 0) return void 0;
11239
- const denied = !mayTrace(this.ownInfo(), info);
11240
- return { kind: "link", target: info.exe, ...denied ? { denied } : {} };
11241
- }
11273
+ if (leaf === "exe") return this.exe(Number(top));
11242
11274
  if (!PID_NAMES.includes(leaf)) return void 0;
11243
11275
  return {
11244
11276
  kind: "file",
@@ -11250,6 +11282,13 @@ var init_wasi_procfs = __esm({
11250
11282
  }
11251
11283
  };
11252
11284
  }
11285
+ exe(pid) {
11286
+ const info = this.info(pid);
11287
+ if (info?.exe === void 0) return void 0;
11288
+ const denied = !mayTrace(this.ownInfo(), info);
11289
+ const id = info.exeId === void 0 ? {} : { id: info.exeId };
11290
+ return { kind: "link", target: info.exe, ...denied ? { denied } : {}, ...id };
11291
+ }
11253
11292
  ownInfo() {
11254
11293
  const processes2 = this.listing().processes;
11255
11294
  return processes2.find((p) => p.tid === this.pid) ?? processes2.find((p) => p.pid === this.pid);
@@ -11315,10 +11354,18 @@ var init_wasi_procfs = __esm({
11315
11354
  return node.names();
11316
11355
  }
11317
11356
  escape(path) {
11357
+ return this.escapeTo(path)?.target;
11358
+ }
11359
+ escapeTo(path) {
11318
11360
  const node = this.node(this.parts(path, true));
11319
11361
  if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
11320
11362
  if (node.denied) throw syncError("EACCES", path);
11321
- return node.target;
11363
+ return node.id === void 0 ? { target: node.target } : { target: node.target, id: node.id };
11364
+ }
11365
+ linkTo(path) {
11366
+ const node = this.node(this.parts(path, false));
11367
+ if (node?.kind !== "link" || node.id === void 0 || node.denied) return void 0;
11368
+ return { target: node.target, id: node.id };
11322
11369
  }
11323
11370
  readlink(path) {
11324
11371
  const node = this.find(path, false);
@@ -11937,9 +11984,9 @@ function ttyOps(kernel, syncKernel) {
11937
11984
  if (original) await setAttr(fd, original.termios);
11938
11985
  return;
11939
11986
  }
11940
- const current = await getAttr(fd);
11941
- if (!saved.has(terminal)) saved.set(terminal, { fd, termios: current });
11942
- await setAttr(fd, rawOf(current));
11987
+ const current2 = await getAttr(fd);
11988
+ if (!saved.has(terminal)) saved.set(terminal, { fd, termios: current2 });
11989
+ await setAttr(fd, rawOf(current2));
11943
11990
  },
11944
11991
  async size(fd) {
11945
11992
  const [rows, columns] = await kernel.json({ op: "tty-winsz", fd });
@@ -11985,9 +12032,9 @@ function ttyOps(kernel, syncKernel) {
11985
12032
  if (original) syncSet(fd, original.termios);
11986
12033
  return;
11987
12034
  }
11988
- const current = syncGet(fd);
11989
- if (!saved.has(terminal)) saved.set(terminal, { fd, termios: current });
11990
- syncSet(fd, rawOf(current));
12035
+ const current2 = syncGet(fd);
12036
+ if (!saved.has(terminal)) saved.set(terminal, { fd, termios: current2 });
12037
+ syncSet(fd, rawOf(current2));
11991
12038
  }
11992
12039
  };
11993
12040
  const modes = () => [...saved].reverse().map(([terminal, { fd, termios }]) => ({ terminal, fd, termios }));
@@ -13475,8 +13522,8 @@ var init_process_signals = __esm({
13475
13522
  const { caught, ignored, defaults = 0 } = masks;
13476
13523
  const nocldwait = masks.nocldwait === true;
13477
13524
  const was = this.reported;
13478
- const same = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
13479
- if (same && defaults === 0) return;
13525
+ const same2 = caught === was.caught && ignored === was.ignored && nocldwait === was.nocldwait;
13526
+ if (same2 && defaults === 0) return;
13480
13527
  this.reported = { caught, ignored, nocldwait };
13481
13528
  const req = {
13482
13529
  op: "sig-mask",
@@ -13561,7 +13608,7 @@ function createSocketKernel(deps) {
13561
13608
  call2(req);
13562
13609
  return 0;
13563
13610
  };
13564
- const guard = (op) => {
13611
+ const guard2 = (op) => {
13565
13612
  for (; ; ) {
13566
13613
  try {
13567
13614
  return op();
@@ -13593,8 +13640,8 @@ function createSocketKernel(deps) {
13593
13640
  return stream.fd;
13594
13641
  };
13595
13642
  return {
13596
- socket: (domain, nonblock, cloexec) => guard(() => install(json2({ op: "sock-open", domain }), nonblock, cloexec)),
13597
- socketpair: (domain, nonblock, cloexec) => guard(() => {
13643
+ socket: (domain, nonblock, cloexec) => guard2(() => install(json2({ op: "sock-open", domain }), nonblock, cloexec)),
13644
+ socketpair: (domain, nonblock, cloexec) => guard2(() => {
13598
13645
  const [a, b] = json2({ op: "sock-pair", domain });
13599
13646
  let first;
13600
13647
  try {
@@ -13612,9 +13659,9 @@ function createSocketKernel(deps) {
13612
13659
  throw e;
13613
13660
  }
13614
13661
  }),
13615
- bind: (fd, given) => guard(() => done({ op: "sock-bind", fd: kfd(fd), addr: resolved(Fs, given) })),
13616
- listen: (fd, backlog) => guard(() => done({ op: "sock-listen", fd: kfd(fd), backlog })),
13617
- accept: (fd, nonblock, cloexec) => guard(() => {
13662
+ bind: (fd, given) => guard2(() => done({ op: "sock-bind", fd: kfd(fd), addr: resolved(Fs, given) })),
13663
+ listen: (fd, backlog) => guard2(() => done({ op: "sock-listen", fd: kfd(fd), backlog })),
13664
+ accept: (fd, nonblock, cloexec) => guard2(() => {
13618
13665
  const listener = socketAt(fd);
13619
13666
  const req = {
13620
13667
  op: "sock-accept",
@@ -13624,7 +13671,7 @@ function createSocketKernel(deps) {
13624
13671
  const got = json2(req);
13625
13672
  return { fd: install(got.fd, nonblock, cloexec), peer: got.peer };
13626
13673
  }),
13627
- connect: (fd, addr) => guard(() => {
13674
+ connect: (fd, addr) => guard2(() => {
13628
13675
  const stream = socketAt(fd);
13629
13676
  const nonblock = (stream.flags & O_NONBLOCK2) !== 0;
13630
13677
  return done({
@@ -13634,12 +13681,12 @@ function createSocketKernel(deps) {
13634
13681
  nonblock
13635
13682
  });
13636
13683
  }),
13637
- shutdown: (fd, how) => guard(() => done({ op: "sock-shutdown", fd: kfd(fd), how })),
13638
- name: (fd, peer) => guard(() => json2({ op: "sock-name", fd: kfd(fd), peer })),
13639
- getopt: (fd, level, name2) => guard(() => ({ value: json2({ op: "sock-getopt", fd: kfd(fd), level, name: name2 }) })),
13640
- setopt: (fd, level, name2, value2) => guard(() => done({ op: "sock-setopt", fd: kfd(fd), level, name: name2, value: value2 })),
13641
- resolve: (name2, family = 4) => guard(() => json2({ op: "sock-resolve", name: name2, family })),
13642
- send: (fd, bytes, flags) => guard(() => {
13684
+ shutdown: (fd, how) => guard2(() => done({ op: "sock-shutdown", fd: kfd(fd), how })),
13685
+ name: (fd, peer) => guard2(() => json2({ op: "sock-name", fd: kfd(fd), peer })),
13686
+ getopt: (fd, level, name2) => guard2(() => ({ value: json2({ op: "sock-getopt", fd: kfd(fd), level, name: name2 }) })),
13687
+ setopt: (fd, level, name2, value2) => guard2(() => done({ op: "sock-setopt", fd: kfd(fd), level, name: name2, value: value2 })),
13688
+ resolve: (name2, family = 4) => guard2(() => json2({ op: "sock-resolve", name: name2, family })),
13689
+ send: (fd, bytes, flags) => guard2(() => {
13643
13690
  const stream = socketAt(fd);
13644
13691
  const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK2) !== 0;
13645
13692
  try {
@@ -13651,7 +13698,7 @@ function createSocketKernel(deps) {
13651
13698
  throw e;
13652
13699
  }
13653
13700
  }),
13654
- recv: (fd, max, flags) => guard(() => {
13701
+ recv: (fd, max, flags) => guard2(() => {
13655
13702
  const stream = socketAt(fd);
13656
13703
  const nonblock = flags.dontwait === true || (stream.flags & O_NONBLOCK2) !== 0;
13657
13704
  return sys.read(stream.sliccKernelFd, max, { nonblock, peek: flags.peek === true });