@ai-ecoverse/slicc-kernel 1.110.7 → 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.
package/README.md CHANGED
@@ -1106,6 +1106,14 @@ A threaded WASIX C program for `test/integration/thread-signal.test.mjs` (#520).
1106
1106
 
1107
1107
  **Build:** `WASIX_SYSROOT_28=/path/to/wasix-sysroot ./build.sh`, with `wasixcc` 0.4.7 (`-pthread`) and binaryen's `wasm-opt` on `PATH`. `bin/sigthread.wasm` is 44,788 bytes, sha256 `5781fa39d0a0032cd9b214b71de1f15f589b40e4cecd6862362048dd27f0db56`.
1108
1108
 
1109
+ ### `fdalias`
1110
+
1111
+ A WASIX C program for `test/integration/fd-alias.test.mjs` (#894).
1112
+ - `fdalias PATH...` prints, for each path, what `stat`, `lstat` and `readlink` give: a file type (`fifo`, `chr`, `reg`, `lnk`, `dir`, `sock`) or the error. A `pipe:[N]`/`socket:[N]` link is cut after the `[`, so the inode number doesn't enter the expected output.
1113
+ - `fdalias cat PATH` opens the path and prints what one read returns.
1114
+
1115
+ **Build:** `WASIX_SYSROOT_28=/path/to/wasix-sysroot ./build.sh`, with `wasixcc` 0.4.7 and binaryen's `wasm-opt` on `PATH`. `bin/fdalias.wasm` is 46,260 bytes, sha256 `70412137fb34d310f8ad200345557490d0441acce4e8f917a7ad37094efb70ec`.
1116
+
1109
1117
  ### `spintest`
1110
1118
 
1111
1119
  A WASIX C program and a JS command for `test/integration/transport-spin.test.mjs`, which guards the sync transport's paths from #856 (#864).
@@ -6176,7 +6176,7 @@ function satisfies(version, range2) {
6176
6176
  }
6177
6177
 
6178
6178
  // src/version.ts
6179
- var KERNEL_VERSION = true ? "1.110.7" : "0.0.0-dev";
6179
+ var KERNEL_VERSION = true ? "1.110.8" : "0.0.0-dev";
6180
6180
  var OS_RELEASE = "6.0.0-slicc";
6181
6181
  function procVersion() {
6182
6182
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -3664,7 +3664,7 @@ function wrap(table) {
3664
3664
  }
3665
3665
  return out;
3666
3666
  }
3667
- var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3667
+ var WasiExit, IDS, NS_PER_MS4, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, S_IFLNK, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, FD_ALIAS, STDIO_FDS, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
3668
3668
  var init_wasi_host = __esm({
3669
3669
  "src/process/wasi/wasi-host.ts"() {
3670
3670
  "use strict";
@@ -3699,9 +3699,12 @@ var init_wasi_host = __esm({
3699
3699
  ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
3700
3700
  GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
3701
3701
  S_IFIFO = 4096;
3702
+ S_IFLNK = 40960;
3702
3703
  DEFAULT_UMASK = 18;
3703
3704
  MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS4;
3704
3705
  MAX_READ = 1024 * 1024;
3706
+ FD_ALIAS = /^\/(?:dev\/(stdin|stdout|stderr)|dev\/fd\/(\d+)|proc\/(self|[1-9]\d*)\/fd\/(\d+))$/;
3707
+ STDIO_FDS = { stdin: 0, stdout: 1, stderr: 2 };
3705
3708
  SIGPIPE_EXIT = 128 + SIG.PIPE;
3706
3709
  SIG_IGN = 1;
3707
3710
  SEALED_MODE = 8630;
@@ -3814,7 +3817,20 @@ var init_wasi_host = __esm({
3814
3817
  return void 0;
3815
3818
  }
3816
3819
  };
3820
+ const fdMode = (fd) => {
3821
+ const e = fds.get(fd);
3822
+ const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
3823
+ if (kind === "stream") return S_IFIFO | 384;
3824
+ if (kind === "sealed" || kind === "clipboard") return SEALED_MODE;
3825
+ return modeOf2(this.o.fs.stat(pathOf(fd)));
3826
+ };
3817
3827
  const pathOwned = (path, follow2) => {
3828
+ const alias = this.fdAlias(path);
3829
+ if (alias && !follow2) return alias.stdio ? ROOT_IDS : void 0;
3830
+ if (alias) {
3831
+ this.openFd(alias.fd);
3832
+ return fdOwned(alias.fd);
3833
+ }
3818
3834
  if (this.synthetic(path)) return ROOT_IDS;
3819
3835
  return follow2 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
3820
3836
  };
@@ -3864,14 +3880,18 @@ var init_wasi_host = __esm({
3864
3880
  const old = this.o.kernel.call({ op: "proc-umask", mask });
3865
3881
  mem.view().setUint32(out, old, true);
3866
3882
  },
3867
- fd_mode: (fd, out) => {
3868
- const e = fds.get(fd);
3869
- const kind = e.type === "kernel" ? fds.kind(fd, e) : void 0;
3870
- const mode = kind === "stream" ? S_IFIFO | 384 : kind === "sealed" || kind === "clipboard" ? SEALED_MODE : modeOf2(this.o.fs.stat(pathOf(fd)));
3871
- mem.view().setUint32(out, mode, true);
3872
- },
3883
+ fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
3873
3884
  path_mode: (dirfd, p, l, flags, out) => {
3874
3885
  const path = at(dirfd, p, l);
3886
+ const alias = this.fdAlias(path);
3887
+ if (alias && flags & AT_SYMLINK_NOFOLLOW) {
3888
+ this.fdTarget(alias);
3889
+ return void mem.view().setUint32(out, S_IFLNK | 511, true);
3890
+ }
3891
+ if (alias) {
3892
+ this.openFd(alias.fd);
3893
+ return void mem.view().setUint32(out, fdMode(alias.fd), true);
3894
+ }
3875
3895
  if (this.synthetic(path) && deviceOf(path) === void 0)
3876
3896
  return void mem.view().setUint32(out, SEALED_MODE, true);
3877
3897
  const st = flags & AT_SYMLINK_NOFOLLOW ? this.o.fs.lstat(path) : this.o.fs.stat(path);
@@ -4166,7 +4186,10 @@ var init_wasi_host = __esm({
4166
4186
  path_open: (dirfd, lookup2, p, l, oflags, rights, _inheriting, fdflags, out) => {
4167
4187
  const follow2 = (lookup2 & LOOKUP_SYMLINK_FOLLOW) !== 0;
4168
4188
  try {
4169
- const path = at(dirfd, p, l);
4189
+ const asked = at(dirfd, p, l);
4190
+ const alias = this.fdAlias(asked);
4191
+ if (alias && !alias.stdio) this.openFd(alias.fd);
4192
+ const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
4170
4193
  if (deviceOf(path)) this.interrupted?.();
4171
4194
  const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
4172
4195
  mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
@@ -4228,7 +4251,9 @@ var init_wasi_host = __esm({
4228
4251
  o.fs.symlink(mem.string(tp, tl), path);
4229
4252
  },
4230
4253
  path_readlink: (dirfd, p, l, buf, len, used) => {
4231
- const target = new TextEncoder().encode(o.fs.readlink(at(dirfd, p, l)));
4254
+ const path = at(dirfd, p, l);
4255
+ const alias = this.fdAlias(path);
4256
+ const target = new TextEncoder().encode(alias ? this.fdTarget(alias) : o.fs.readlink(path));
4232
4257
  const n = Math.min(len, target.length);
4233
4258
  mem.bytes(buf, n).set(target.subarray(0, n));
4234
4259
  mem.view().setUint32(used, n, true);
@@ -4567,7 +4592,55 @@ var init_wasi_host = __esm({
4567
4592
  return void 0;
4568
4593
  }
4569
4594
  }
4595
+ fdAlias(path) {
4596
+ const m = FD_ALIAS.exec(path);
4597
+ if (!m) return void 0;
4598
+ if (m[1]) return { fd: STDIO_FDS[m[1]], stdio: true };
4599
+ if (m[3] !== void 0 && m[3] !== "self" && Number(m[3]) !== this.o.pid) return void 0;
4600
+ return { fd: Number(m[2] ?? m[4]), stdio: false };
4601
+ }
4602
+ openFd(fd) {
4603
+ try {
4604
+ this.fds.get(fd);
4605
+ } catch {
4606
+ throw new WasiError("ENOENT");
4607
+ }
4608
+ }
4609
+ fdTarget(alias) {
4610
+ if (alias.stdio) return `/proc/self/fd/${alias.fd}`;
4611
+ this.openFd(alias.fd);
4612
+ const e = this.fds.get(alias.fd);
4613
+ if (e.type === "file") return e.file.path;
4614
+ if (e.type === "dir") return e.path;
4615
+ if (e.type === "device") return `/dev/${e.device}`;
4616
+ const kind = e.type === "kernel" ? this.fds.kind(alias.fd, e) : void 0;
4617
+ if (kind === "file") {
4618
+ const vfs = this.kernelStat(alias.fd);
4619
+ if (vfs.path) return vfs.path;
4620
+ }
4621
+ if (kind === "tty") return "/dev/tty";
4622
+ if (kind === "device") return "/dev/null";
4623
+ const ino = this.fdFilestat(alias.fd).ino;
4624
+ if (kind === "stream") return `pipe:[${ino}]`;
4625
+ if (kind === "socket") return `socket:[${ino}]`;
4626
+ return `anon_inode:[${kind ?? "fd"}]`;
4627
+ }
4628
+ aliasFilestat(path, alias, lookup2) {
4629
+ if ((lookup2 & LOOKUP_SYMLINK_FOLLOW) === 0) {
4630
+ const target = this.fdTarget(alias);
4631
+ return this.local({
4632
+ filetype: FILETYPE.SYMBOLIC_LINK,
4633
+ size: BigInt(new TextEncoder().encode(target).length),
4634
+ ino: pathInode(path),
4635
+ mtimeNs: 0n
4636
+ });
4637
+ }
4638
+ this.openFd(alias.fd);
4639
+ return this.fdFilestat(alias.fd);
4640
+ }
4570
4641
  pathFilestat(path, lookup2) {
4642
+ const alias = this.fdAlias(path);
4643
+ if (alias) return this.aliasFilestat(path, alias, lookup2);
4571
4644
  if (this.synthetic(path)) {
4572
4645
  return this.local({
4573
4646
  filetype: FILETYPE.CHARACTER_DEVICE,
@@ -5212,7 +5285,7 @@ var KERNEL_VERSION, OS_RELEASE;
5212
5285
  var init_version = __esm({
5213
5286
  "src/version.ts"() {
5214
5287
  "use strict";
5215
- KERNEL_VERSION = true ? "1.110.7" : "0.0.0-dev";
5288
+ KERNEL_VERSION = true ? "1.110.8" : "0.0.0-dev";
5216
5289
  OS_RELEASE = "6.0.0-slicc";
5217
5290
  }
5218
5291
  });
@@ -7250,7 +7323,7 @@ function exactIn(node) {
7250
7323
  return node?.mount.opts.bridge.owners === true;
7251
7324
  }
7252
7325
  function modeFromStat(st, exact = false) {
7253
- const type = st.isSymbolicLink ? S_IFLNK : st.isDirectory ? S_IFDIR : st.isSocket ? S_IFSOCK : S_IFREG;
7326
+ const type = st.isSymbolicLink ? S_IFLNK2 : st.isDirectory ? S_IFDIR : st.isSocket ? S_IFSOCK : S_IFREG;
7254
7327
  const fallback = st.isDirectory || st.isSymbolicLink ? 511 : 438;
7255
7328
  const perm = (st.mode ?? fallback) & PERM_MASK;
7256
7329
  return type | (exact ? perm : perm || fallback);
@@ -8277,7 +8350,7 @@ function readingLinks(Fs) {
8277
8350
  }
8278
8351
  };
8279
8352
  }
8280
- var S_IFDIR, S_IFREG, S_IFLNK, S_IFSOCK, S_IFMT2, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR2, SEEK_END2, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
8353
+ var S_IFDIR, S_IFREG, S_IFLNK2, S_IFSOCK, S_IFMT2, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR2, SEEK_END2, EARLY_WHOLE_FILE, O_APPEND4, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
8281
8354
  var init_live_vfs_fs = __esm({
8282
8355
  "src/realm/live-vfs-fs.ts"() {
8283
8356
  "use strict";
@@ -8289,7 +8362,7 @@ var init_live_vfs_fs = __esm({
8289
8362
  init_sync_sab_bridge();
8290
8363
  S_IFDIR = 16384;
8291
8364
  S_IFREG = 32768;
8292
- S_IFLNK = 40960;
8365
+ S_IFLNK2 = 40960;
8293
8366
  S_IFSOCK = 49152;
8294
8367
  S_IFMT2 = 61440;
8295
8368
  PERM_MASK = 4095;