@ai-ecoverse/slicc-kernel 1.63.0 → 1.64.1

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.
@@ -2126,12 +2126,27 @@ var init_kernel_streams = __esm({
2126
2126
  const original = fs[name2];
2127
2127
  if (typeof original !== "function") continue;
2128
2128
  fs[name2] = (path, ...rest2) => {
2129
- if (!isPtyPath(path)) return original.call(fs, path, ...rest2);
2129
+ const owned = this.ownedTty(path);
2130
+ if (owned && isPtyPath(path)) return this.owned(path, ptyStat(path));
2131
+ if (!isPtyPath(path)) {
2132
+ const st = original.call(fs, path, ...rest2);
2133
+ return owned && TTY_PATH.test(path) ? this.owned(path, st) : st;
2134
+ }
2130
2135
  this.existingPty(path);
2131
2136
  return ptyStat(path);
2132
2137
  };
2133
2138
  }
2134
2139
  }
2140
+ ownedTty(path) {
2141
+ return this.options.owners === true && this.sys.ttyOwner !== void 0 && path !== "/dev/ptmx";
2142
+ }
2143
+ owned(path, st) {
2144
+ const ask = this.sys.ttyOwner;
2145
+ const owner = this.call(() => ask.call(this.sys, path));
2146
+ if (!owner) return st;
2147
+ const mode = st.mode & ~4095 | (owner.mode ?? 400);
2148
+ return { ...st, uid: owner.uid, gid: owner.gid, mode };
2149
+ }
2135
2150
  existingPty(path) {
2136
2151
  const n = PTY_PATH.exec(path)?.[1];
2137
2152
  const exists = n === void 0 ? this.sys.openPty !== void 0 : this.sys.ptyNumbers?.().includes(Number(n)) ?? false;
@@ -2965,6 +2980,7 @@ var init_process_fds = __esm({
2965
2980
  AT_FDCWD = -100;
2966
2981
  AT_EACCESS = 512;
2967
2982
  DEVICE_MODES = [
2983
+ ["/", 493],
2968
2984
  ["/dev", 493],
2969
2985
  ["/dev/null", 438],
2970
2986
  ["/dev/zero", 438],
@@ -4229,6 +4245,9 @@ function kernelSys(transport) {
4229
4245
  ttyNames() {
4230
4246
  return json(call2({ op: "fd-tty-names" }, "fd-tty-names"));
4231
4247
  },
4248
+ ttyOwner(name2) {
4249
+ return json(call2({ op: "fd-tty-owner", name: name2 }, `fd-tty-owner ${name2}`));
4250
+ },
4232
4251
  openTty(name2) {
4233
4252
  const req = name2 === void 0 ? { op: "fd-open-tty" } : { op: "fd-open-tty", name: name2 };
4234
4253
  return json(call2(req, `fd-open-tty ${name2 ?? ""}`));
@@ -4473,7 +4492,8 @@ async function runWasmProcess(init, port2, deps = {}) {
4473
4492
  early = () => signals.quiet(() => vfs.flushDirty());
4474
4493
  const sigpipe = () => running.sliccSigpipe?.() === 1;
4475
4494
  const restartable = () => signals.restartable();
4476
- const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
4495
+ const owners = init.owners ? { owners: true } : {};
4496
+ const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable, ...owners });
4477
4497
  trackCloseOnExec(running.FS);
4478
4498
  quietQuit(running.FS);
4479
4499
  useMounts(running.FS, init.env, true);