@ai-ecoverse/slicc-kernel 1.26.4 → 1.26.5

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
@@ -6709,8 +6709,10 @@ var VfsNodes = class {
6709
6709
  for (const [p, node] of this.byPath) if (within3(p, path)) await node.serial(() => node.flush());
6710
6710
  }
6711
6711
  async unlinking(path) {
6712
- const node = this.byPath.get(path);
6713
- if (node) await node.serial(async () => void await Promise.all([node.keep(), node.limit()]));
6712
+ for (const [held, node] of [...this.byPath]) {
6713
+ if (!within3(held, path)) continue;
6714
+ await node.serial(async () => void await Promise.all([node.keep(), node.limit()]));
6715
+ }
6714
6716
  }
6715
6717
  revoke(prefix) {
6716
6718
  for (const [path, node] of this.byPath) {
@@ -6720,10 +6722,11 @@ var VfsNodes = class {
6720
6722
  }
6721
6723
  }
6722
6724
  unlinked(path) {
6723
- const node = this.byPath.get(path);
6724
- if (!node) return;
6725
- node.orphaned = true;
6726
- this.byPath.delete(path);
6725
+ for (const [held, node] of [...this.byPath]) {
6726
+ if (!within3(held, path)) continue;
6727
+ node.orphaned = true;
6728
+ this.byPath.delete(held);
6729
+ }
6727
6730
  }
6728
6731
  renamed(from, to) {
6729
6732
  if (from === to) return;
@@ -6797,6 +6800,23 @@ async function refuseReadonly(fs, path, flags, opts = {}) {
6797
6800
  const st = own ?? await stat(await targetDir(fs, path));
6798
6801
  if (st?.readonly) throw new KernelError("EROFS");
6799
6802
  }
6803
+ function keepingOpen(fs, nodes) {
6804
+ return {
6805
+ ...fs,
6806
+ async rm(path, options) {
6807
+ const at = fs.resolvePath("/", path);
6808
+ await nodes.unlinking(at);
6809
+ await fs.rm(path, options);
6810
+ nodes.unlinked(at);
6811
+ },
6812
+ async rename(from, to) {
6813
+ const [a, b] = [fs.resolvePath("/", from), fs.resolvePath("/", to)];
6814
+ await nodes.unlinking(b);
6815
+ await fs.rename(from, to);
6816
+ nodes.renamed(a, b);
6817
+ }
6818
+ };
6819
+ }
6800
6820
  function vfsFile(fs, opts, nodes) {
6801
6821
  const access = opts.flags & O_ACCMODE;
6802
6822
  const readable = access !== O_WRONLY;
@@ -6992,8 +7012,8 @@ var WasmProcess = class {
6992
7012
  this.options = options;
6993
7013
  this.inherited = options.ignored ?? 0;
6994
7014
  this.children = new ChildTable(fds, options.spawner, options.forker);
6995
- this.nodes = new VfsNodes(options.fs);
6996
- options.openFiles?.add(this.nodes);
7015
+ this.nodes = options.nodes ?? new VfsNodes(options.fs);
7016
+ if (!options.nodes) options.openFiles?.add(this.nodes);
6997
7017
  this.children.onChildState = () => this.signal(SIG.CHLD);
6998
7018
  this.children.onReap = options.onReap;
6999
7019
  }
@@ -7496,7 +7516,7 @@ var WasmProcess = class {
7496
7516
  this.asyncOps.close();
7497
7517
  for (const pid of this.children.pids()) this.options.onReap?.(pid);
7498
7518
  await this.fds.closeAll();
7499
- this.options.openFiles?.delete(this.nodes);
7519
+ if (!this.options.nodes) this.options.openFiles?.delete(this.nodes);
7500
7520
  await this.options.http?.closeAll();
7501
7521
  }
7502
7522
  };
@@ -7546,6 +7566,7 @@ function spawnWasmProcess(opts) {
7546
7566
  kill: opts.kill,
7547
7567
  processes: opts.processes,
7548
7568
  openFiles: opts.openFiles,
7569
+ ...opts.nodes ? { nodes: opts.nodes } : {},
7549
7570
  mounts: opts.mounts,
7550
7571
  ...opts.mount ? { mount: opts.mount } : {},
7551
7572
  ...opts.umount ? { umount: opts.umount } : {},
@@ -9113,6 +9134,7 @@ var Launcher = class {
9113
9134
  fstabRetries;
9114
9135
  inserted = /* @__PURE__ */ new Map();
9115
9136
  openFiles = /* @__PURE__ */ new Set();
9137
+ nodes;
9116
9138
  held = /* @__PURE__ */ new Set();
9117
9139
  processMounts;
9118
9140
  booting = new AbortController();
@@ -9146,7 +9168,10 @@ var Launcher = class {
9146
9168
  ca: this.ca
9147
9169
  });
9148
9170
  enableCdp(this.net, this.cdp);
9149
- this.fs = withCommandDirs(this.base, async () => new Set((await this.commands()).keys()));
9171
+ const fs = withCommandDirs(this.base, async () => new Set((await this.commands()).keys()));
9172
+ this.nodes = new VfsNodes(fs);
9173
+ this.openFiles.add(this.nodes);
9174
+ this.fs = keepingOpen(fs, this.nodes);
9150
9175
  this.watchers.watch([this.modulesDir, this.pnpmHome], { recursive: true }, () => {
9151
9176
  this.catalog = void 0;
9152
9177
  });
@@ -9319,6 +9344,7 @@ var Launcher = class {
9319
9344
  kill: (target, sig) => this.kill(target, sig),
9320
9345
  processes: () => ({ boot: this.boot, processes: this.list() }),
9321
9346
  openFiles: this.openFiles,
9347
+ nodes: this.nodes,
9322
9348
  held: this.held,
9323
9349
  statfs: (path) => this.mounts.statfs(path),
9324
9350
  mounts: () => this.mounts.list(),