@ai-ecoverse/slicc-kernel 1.42.0 → 1.42.2

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/dist/node.js CHANGED
@@ -8926,7 +8926,7 @@ var WasmProcess = class {
8926
8926
  const fd = this.fds.install(heldFile(), 3);
8927
8927
  try {
8928
8928
  const nodes = this.nodes;
8929
- const path = req.orphan ? req.path : req.exclusive ? await nodes.entryKey(req.path) : req.create ? await nodes.targetKey(req.path) : await this.keptOr(await nodes.targetKey(req.path));
8929
+ const path = req.orphan ? req.path : req.exclusive ? await nodes.entryKey(req.path) : req.create ? await nodes.targetKey(req.path) : await this.keptOr(await nodes.targetKey(req.path), req.handle);
8930
8930
  const open = { ...req, path };
8931
8931
  if (req.exclusive) {
8932
8932
  await nodes.createExclusive(path);
@@ -9084,7 +9084,10 @@ var WasmProcess = class {
9084
9084
  }
9085
9085
  }
9086
9086
  keptPath;
9087
- async keptOr(path) {
9087
+ keptHandle;
9088
+ async keptOr(path, handle) {
9089
+ const held = handle === void 0 ? void 0 : this.keptHandle?.(handle);
9090
+ if (held !== void 0) return held;
9088
9091
  const kept = this.keptPath?.(path);
9089
9092
  return kept !== void 0 && !await present(this.options.fs, path, true) ? kept : path;
9090
9093
  }
@@ -9095,7 +9098,7 @@ var WasmProcess = class {
9095
9098
  return;
9096
9099
  }
9097
9100
  if (req.path === void 0) throw new KernelError("EINVAL");
9098
- const path = req.orphan ? req.path : await this.keptOr(await this.nodes.targetKey(req.path));
9101
+ const path = req.orphan ? req.path : await this.keptOr(await this.nodes.targetKey(req.path), req.handle);
9099
9102
  if (!this.fds.get(req.fd).file.held) throw new KernelError("EBADF");
9100
9103
  const file = vfsFile(
9101
9104
  this.options.fs,
@@ -9127,6 +9130,8 @@ var WasmProcess = class {
9127
9130
  ...file.heldMeta ? { meta: file.heldMeta } : {},
9128
9131
  ...flags !== void 0 ? { flags } : {},
9129
9132
  ...this.fds.closesOnExec(fd) ? { cloexec: true } : {},
9133
+ ...file.read && !file.write ? { access: "read" } : {},
9134
+ ...file.write && !file.read ? { access: "write" } : {},
9130
9135
  ...file.tty?.name ? { name: file.tty.name } : file.pty ? { name: "/dev/ptmx" } : {}
9131
9136
  };
9132
9137
  }
@@ -9536,6 +9541,7 @@ function spawnWasmProcess(opts) {
9536
9541
  opts.held?.add(holds);
9537
9542
  const token = holdingToken(opts, holds);
9538
9543
  process2.keptPath = (path) => holds.keptAt(path)?.hidden;
9544
+ process2.keptHandle = (handle2) => holds.keptFor(handle2)?.hidden;
9539
9545
  const worker = opts.createWorker();
9540
9546
  const dying = new Dying();
9541
9547
  const dispatch2 = (req) => dying.serving(() => isWasmSyscall(req) ? process2.syscall(req) : dispatchSyncFs(req));