@ai-ecoverse/slicc-kernel 1.110.6 → 1.110.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.
@@ -2515,7 +2515,7 @@ var KERNEL_VERSION, OS_RELEASE;
2515
2515
  var init_version = __esm({
2516
2516
  "src/version.ts"() {
2517
2517
  "use strict";
2518
- KERNEL_VERSION = true ? "1.110.6" : "0.0.0-dev";
2518
+ KERNEL_VERSION = true ? "1.110.8" : "0.0.0-dev";
2519
2519
  OS_RELEASE = "6.0.0-slicc";
2520
2520
  }
2521
2521
  });
@@ -8774,7 +8774,7 @@ function wrap(table) {
8774
8774
  }
8775
8775
  return out;
8776
8776
  }
8777
- var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
8777
+ var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW2, AT_EACCESS2, ROOT_IDS, GONE, S_IFIFO, S_IFLNK2, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, FD_ALIAS, STDIO_FDS, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
8778
8778
  var init_wasi_host = __esm({
8779
8779
  "src/process/wasi/wasi-host.ts"() {
8780
8780
  "use strict";
@@ -8809,9 +8809,12 @@ var init_wasi_host = __esm({
8809
8809
  ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
8810
8810
  GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
8811
8811
  S_IFIFO = 4096;
8812
+ S_IFLNK2 = 40960;
8812
8813
  DEFAULT_UMASK = 18;
8813
8814
  MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
8814
8815
  MAX_READ = 1024 * 1024;
8816
+ FD_ALIAS = /^\/(?:dev\/(stdin|stdout|stderr)|dev\/fd\/(\d+)|proc\/(self|[1-9]\d*)\/fd\/(\d+))$/;
8817
+ STDIO_FDS = { stdin: 0, stdout: 1, stderr: 2 };
8815
8818
  SIGPIPE_EXIT = 128 + SIG.PIPE;
8816
8819
  SIG_IGN = 1;
8817
8820
  SEALED_MODE = 8630;
@@ -8924,7 +8927,20 @@ var init_wasi_host = __esm({
8924
8927
  return void 0;
8925
8928
  }
8926
8929
  };
8930
+ const fdMode = (fd) => {
8931
+ const e = fds.get(fd);
8932
+ const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
8933
+ if (kind === "stream") return S_IFIFO | 384;
8934
+ if (kind === "sealed" || kind === "clipboard") return SEALED_MODE;
8935
+ return modeOf2(this.o.fs.stat(pathOf(fd)));
8936
+ };
8927
8937
  const pathOwned = (path, follow2) => {
8938
+ const alias = this.fdAlias(path);
8939
+ if (alias && !follow2) return alias.stdio ? ROOT_IDS : void 0;
8940
+ if (alias) {
8941
+ this.openFd(alias.fd);
8942
+ return fdOwned(alias.fd);
8943
+ }
8928
8944
  if (this.synthetic(path)) return ROOT_IDS;
8929
8945
  return follow2 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
8930
8946
  };
@@ -8974,14 +8990,18 @@ var init_wasi_host = __esm({
8974
8990
  const old = this.o.kernel.call({ op: "proc-umask", mask });
8975
8991
  mem.view().setUint32(out, old, true);
8976
8992
  },
8977
- fd_mode: (fd, out) => {
8978
- const e = fds.get(fd);
8979
- const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
8980
- const mode = kind === "stream" ? S_IFIFO | 384 : kind === "sealed" || kind === "clipboard" ? SEALED_MODE : modeOf2(this.o.fs.stat(pathOf(fd)));
8981
- mem.view().setUint32(out, mode, true);
8982
- },
8993
+ fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
8983
8994
  path_mode: (dirfd, p, l, flags, out) => {
8984
8995
  const path = at(dirfd, p, l);
8996
+ const alias = this.fdAlias(path);
8997
+ if (alias && flags & AT_SYMLINK_NOFOLLOW2) {
8998
+ this.fdTarget(alias);
8999
+ return void mem.view().setUint32(out, S_IFLNK2 | 511, true);
9000
+ }
9001
+ if (alias) {
9002
+ this.openFd(alias.fd);
9003
+ return void mem.view().setUint32(out, fdMode(alias.fd), true);
9004
+ }
8985
9005
  if (this.synthetic(path) && deviceOf(path) === void 0)
8986
9006
  return void mem.view().setUint32(out, SEALED_MODE, true);
8987
9007
  const st = flags & AT_SYMLINK_NOFOLLOW2 ? this.o.fs.lstat(path) : this.o.fs.stat(path);
@@ -9276,7 +9296,10 @@ var init_wasi_host = __esm({
9276
9296
  path_open: (dirfd, lookup2, p, l, oflags, rights, _inheriting, fdflags, out) => {
9277
9297
  const follow2 = (lookup2 & LOOKUP_SYMLINK_FOLLOW) !== 0;
9278
9298
  try {
9279
- const path = at(dirfd, p, l);
9299
+ const asked = at(dirfd, p, l);
9300
+ const alias = this.fdAlias(asked);
9301
+ if (alias && !alias.stdio) this.openFd(alias.fd);
9302
+ const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
9280
9303
  if (deviceOf(path)) this.interrupted?.();
9281
9304
  const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
9282
9305
  mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
@@ -9338,7 +9361,9 @@ var init_wasi_host = __esm({
9338
9361
  o.fs.symlink(mem.string(tp, tl), path);
9339
9362
  },
9340
9363
  path_readlink: (dirfd, p, l, buf, len, used) => {
9341
- const target = new TextEncoder().encode(o.fs.readlink(at(dirfd, p, l)));
9364
+ const path = at(dirfd, p, l);
9365
+ const alias = this.fdAlias(path);
9366
+ const target = new TextEncoder().encode(alias ? this.fdTarget(alias) : o.fs.readlink(path));
9342
9367
  const n = Math.min(len, target.length);
9343
9368
  mem.bytes(buf, n).set(target.subarray(0, n));
9344
9369
  mem.view().setUint32(used, n, true);
@@ -9677,7 +9702,55 @@ var init_wasi_host = __esm({
9677
9702
  return void 0;
9678
9703
  }
9679
9704
  }
9705
+ fdAlias(path) {
9706
+ const m = FD_ALIAS.exec(path);
9707
+ if (!m) return void 0;
9708
+ if (m[1]) return { fd: STDIO_FDS[m[1]], stdio: true };
9709
+ if (m[3] !== void 0 && m[3] !== "self" && Number(m[3]) !== this.o.pid) return void 0;
9710
+ return { fd: Number(m[2] ?? m[4]), stdio: false };
9711
+ }
9712
+ openFd(fd) {
9713
+ try {
9714
+ this.fds.get(fd);
9715
+ } catch {
9716
+ throw new WasiError("ENOENT");
9717
+ }
9718
+ }
9719
+ fdTarget(alias) {
9720
+ if (alias.stdio) return `/proc/self/fd/${alias.fd}`;
9721
+ this.openFd(alias.fd);
9722
+ const e = this.fds.get(alias.fd);
9723
+ if (e.type === "file") return e.file.path;
9724
+ if (e.type === "dir") return e.path;
9725
+ if (e.type === "device") return `/dev/${e.device}`;
9726
+ const kind = e.type === "kernel" ? this.fds.kind(alias.fd, e) : void 0;
9727
+ if (kind === "file") {
9728
+ const vfs = this.kernelStat(alias.fd);
9729
+ if (vfs.path) return vfs.path;
9730
+ }
9731
+ if (kind === "tty") return "/dev/tty";
9732
+ if (kind === "device") return "/dev/null";
9733
+ const ino = this.fdFilestat(alias.fd).ino;
9734
+ if (kind === "stream") return `pipe:[${ino}]`;
9735
+ if (kind === "socket") return `socket:[${ino}]`;
9736
+ return `anon_inode:[${kind ?? "fd"}]`;
9737
+ }
9738
+ aliasFilestat(path, alias, lookup2) {
9739
+ if ((lookup2 & LOOKUP_SYMLINK_FOLLOW) === 0) {
9740
+ const target = this.fdTarget(alias);
9741
+ return this.local({
9742
+ filetype: FILETYPE.SYMBOLIC_LINK,
9743
+ size: BigInt(new TextEncoder().encode(target).length),
9744
+ ino: pathInode(path),
9745
+ mtimeNs: 0n
9746
+ });
9747
+ }
9748
+ this.openFd(alias.fd);
9749
+ return this.fdFilestat(alias.fd);
9750
+ }
9680
9751
  pathFilestat(path, lookup2) {
9752
+ const alias = this.fdAlias(path);
9753
+ if (alias) return this.aliasFilestat(path, alias, lookup2);
9681
9754
  if (this.synthetic(path)) {
9682
9755
  return this.local({
9683
9756
  filetype: FILETYPE.CHARACTER_DEVICE,