@ai-ecoverse/slicc-kernel 1.41.4 → 1.42.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.
@@ -9171,7 +9171,7 @@ var WasmProcess = class {
9171
9171
  const fd = this.fds.install(heldFile(), 3);
9172
9172
  try {
9173
9173
  const nodes = this.nodes;
9174
- 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));
9174
+ 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);
9175
9175
  const open = { ...req, path };
9176
9176
  if (req.exclusive) {
9177
9177
  await nodes.createExclusive(path);
@@ -9329,7 +9329,10 @@ var WasmProcess = class {
9329
9329
  }
9330
9330
  }
9331
9331
  keptPath;
9332
- async keptOr(path) {
9332
+ keptHandle;
9333
+ async keptOr(path, handle) {
9334
+ const held = handle === void 0 ? void 0 : this.keptHandle?.(handle);
9335
+ if (held !== void 0) return held;
9333
9336
  const kept = this.keptPath?.(path);
9334
9337
  return kept !== void 0 && !await present(this.options.fs, path, true) ? kept : path;
9335
9338
  }
@@ -9340,7 +9343,7 @@ var WasmProcess = class {
9340
9343
  return;
9341
9344
  }
9342
9345
  if (req.path === void 0) throw new KernelError("EINVAL");
9343
- const path = req.orphan ? req.path : await this.keptOr(await this.nodes.targetKey(req.path));
9346
+ const path = req.orphan ? req.path : await this.keptOr(await this.nodes.targetKey(req.path), req.handle);
9344
9347
  if (!this.fds.get(req.fd).file.held) throw new KernelError("EBADF");
9345
9348
  const file = vfsFile(
9346
9349
  this.options.fs,
@@ -9372,6 +9375,8 @@ var WasmProcess = class {
9372
9375
  ...file.heldMeta ? { meta: file.heldMeta } : {},
9373
9376
  ...flags !== void 0 ? { flags } : {},
9374
9377
  ...this.fds.closesOnExec(fd) ? { cloexec: true } : {},
9378
+ ...file.read && !file.write ? { access: "read" } : {},
9379
+ ...file.write && !file.read ? { access: "write" } : {},
9375
9380
  ...file.tty?.name ? { name: file.tty.name } : file.pty ? { name: "/dev/ptmx" } : {}
9376
9381
  };
9377
9382
  }
@@ -9781,6 +9786,7 @@ function spawnWasmProcess(opts) {
9781
9786
  opts.held?.add(holds);
9782
9787
  const token = holdingToken(opts, holds);
9783
9788
  process.keptPath = (path) => holds.keptAt(path)?.hidden;
9789
+ process.keptHandle = (handle2) => holds.keptFor(handle2)?.hidden;
9784
9790
  const worker = opts.createWorker();
9785
9791
  const dying = new Dying();
9786
9792
  const dispatch2 = (req) => dying.serving(() => isWasmSyscall(req) ? process.syscall(req) : dispatchSyncFs(req));