@ai-ecoverse/slicc-kernel 1.147.3 → 1.147.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.
@@ -7157,7 +7157,7 @@ var KERNEL_VERSION, OS_RELEASE;
7157
7157
  var init_version = __esm({
7158
7158
  "src/version.ts"() {
7159
7159
  "use strict";
7160
- KERNEL_VERSION = true ? "1.147.3" : "0.0.0-dev";
7160
+ KERNEL_VERSION = true ? "1.147.5" : "0.0.0-dev";
7161
7161
  OS_RELEASE = "6.0.0-slicc";
7162
7162
  }
7163
7163
  });
package/dist/node.js CHANGED
@@ -3305,7 +3305,7 @@ function satisfies(version, range2) {
3305
3305
  }
3306
3306
 
3307
3307
  // src/version.ts
3308
- var KERNEL_VERSION = true ? "1.147.3" : "0.0.0-dev";
3308
+ var KERNEL_VERSION = true ? "1.147.5" : "0.0.0-dev";
3309
3309
  var OS_RELEASE = "6.0.0-slicc";
3310
3310
  function procVersion() {
3311
3311
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18255,6 +18255,17 @@ var VfsNode = class {
18255
18255
  this.queue = next3.catch(() => void 0);
18256
18256
  return next3;
18257
18257
  }
18258
+ named = 0;
18259
+ byName(op) {
18260
+ return this.serial(async () => {
18261
+ this.named++;
18262
+ try {
18263
+ return await op();
18264
+ } finally {
18265
+ this.named--;
18266
+ }
18267
+ });
18268
+ }
18258
18269
  revoke() {
18259
18270
  this.revoked = true;
18260
18271
  clearTimeout(this.writeBack);
@@ -18262,7 +18273,7 @@ var VfsNode = class {
18262
18273
  this.data = void 0;
18263
18274
  this.ranged = void 0;
18264
18275
  }
18265
- async prepare() {
18276
+ async prepare(onFd = this.named === 0) {
18266
18277
  if (this.revoked) throw new KernelError("EIO");
18267
18278
  if (this.ranged || this.data) return this.ranged;
18268
18279
  const io = rangedOps(this.fs);
@@ -18277,15 +18288,15 @@ var VfsNode = class {
18277
18288
  this.ranged = new AsyncRangedFile(io, this.path, st.size ?? 0, st.version);
18278
18289
  return this.ranged;
18279
18290
  }
18280
- await this.load();
18291
+ await this.load(onFd);
18281
18292
  return void 0;
18282
18293
  }
18283
18294
  async keep() {
18284
- const ranged2 = await this.prepare();
18285
- if (ranged2) await this.followed(() => ranged2.pin());
18295
+ const ranged2 = await this.prepare(false);
18296
+ if (ranged2) await this.followed(() => ranged2.pin(), false);
18286
18297
  }
18287
18298
  moving = /* @__PURE__ */ new Set();
18288
- async followed(op) {
18299
+ async followed(op, onFd = this.named === 0) {
18289
18300
  for (; ; ) {
18290
18301
  const at = this.path;
18291
18302
  try {
@@ -18293,11 +18304,11 @@ var VfsNode = class {
18293
18304
  } catch (err) {
18294
18305
  if (!isMissing(err)) throw err;
18295
18306
  while (this.moving.size > 0) await Promise.all(this.moving);
18296
- if (this.path === at) throw err;
18307
+ if (this.path === at) throw onFd && !this.made ? new KernelError("EIO") : err;
18297
18308
  }
18298
18309
  }
18299
18310
  }
18300
- async load() {
18311
+ async load(onFd = this.named === 0) {
18301
18312
  if (this.revoked) throw new KernelError("EIO");
18302
18313
  while (!this.data) {
18303
18314
  const at = this.path;
@@ -18307,7 +18318,7 @@ var VfsNode = class {
18307
18318
  if (!isMissing(err)) throw err;
18308
18319
  while (this.moving.size > 0) await Promise.all(this.moving);
18309
18320
  if (this.path !== at) continue;
18310
- if (!this.made) throw new KernelError("ENOENT");
18321
+ if (!this.made) throw new KernelError(onFd ? "EIO" : "ENOENT");
18311
18322
  this.data = new Uint8Array(0);
18312
18323
  this.missing = true;
18313
18324
  }
@@ -18812,7 +18823,7 @@ function heldIo(fs, nodes, changed) {
18812
18823
  const write = async (path, op, fallback) => {
18813
18824
  const held = await node(path);
18814
18825
  if (!held) return fallback();
18815
- const out = await held.serial(async () => {
18826
+ const out = await held.byName(async () => {
18816
18827
  const done4 = await op(held);
18817
18828
  await held.flush();
18818
18829
  return done4;
@@ -18844,22 +18855,22 @@ function heldIo(fs, nodes, changed) {
18844
18855
  async stat(path) {
18845
18856
  const st = await fs.stat(path);
18846
18857
  const held = st.isFile ? await node(path) : void 0;
18847
- return held ? { ...st, size: await held.serial(() => held.size()) } : st;
18858
+ return held ? { ...st, size: await held.byName(() => held.size()) } : st;
18848
18859
  },
18849
18860
  async lstat(path) {
18850
18861
  const st = await fs.lstat(path);
18851
18862
  const held = st.isFile && !st.isSymbolicLink ? await node(path) : void 0;
18852
- return held ? { ...st, size: await held.serial(() => held.size()) } : st;
18863
+ return held ? { ...st, size: await held.byName(() => held.size()) } : st;
18853
18864
  },
18854
18865
  async readFileBuffer(path) {
18855
18866
  const held = await node(path);
18856
18867
  if (!held) return fs.readFileBuffer(path);
18857
- return held.serial(async () => held.pread(await held.size(), 0));
18868
+ return held.byName(async () => held.pread(await held.size(), 0));
18858
18869
  },
18859
18870
  ...ranged2 ? {
18860
18871
  pread: async (path, at, n, version) => {
18861
18872
  const held = await node(path);
18862
- return held ? held.serial(() => held.pread(n, at)) : ranged2.pread(path, at, n, version);
18873
+ return held ? held.byName(() => held.pread(n, at)) : ranged2.pread(path, at, n, version);
18863
18874
  },
18864
18875
  pwrite: (path, at, bytes, transfer) => write(
18865
18876
  path,
@@ -18912,7 +18923,7 @@ function keepingOpen(fs, nodes, changed = () => {
18912
18923
  const held = await heldAt(fs, nodes, at);
18913
18924
  if (!held) return nodes.onEntry(at, () => fs.writeFile(path, content, owner));
18914
18925
  const bytes = typeof content === "string" ? new TextEncoder().encode(content) : content;
18915
- return held.serial(async () => {
18926
+ return held.byName(async () => {
18916
18927
  await held.truncate(0);
18917
18928
  await held.pwrite(bytes, 0);
18918
18929
  await held.flush();
@@ -29092,6 +29103,25 @@ var Launcher = class {
29092
29103
  const optional = `${root}-names${beside.slice(root.length)}`;
29093
29104
  return await this.base.exists(optional) ? optional : void 0;
29094
29105
  }
29106
+ loaded(target, env, caller) {
29107
+ const read = () => this.program(target, env, caller);
29108
+ const id2 = () => this.exeId(target);
29109
+ return id2().then(
29110
+ (before) => read().then(
29111
+ (first) => id2().then(
29112
+ (after) => after.exeId === before.exeId ? [first, after] : this.reread(target, read).then(
29113
+ (again) => id2().then((last) => [again, last])
29114
+ )
29115
+ )
29116
+ )
29117
+ );
29118
+ }
29119
+ reread(target, read) {
29120
+ for (const key of this.compiled.keys()) {
29121
+ if (key.startsWith(`${target.wasm}:`)) this.compiled.delete(key);
29122
+ }
29123
+ return read();
29124
+ }
29095
29125
  exeId(target) {
29096
29126
  if (target.abi !== "wasi" || (target.copy ?? target.glue) !== target.wasm) {
29097
29127
  return Promise.resolve({});
@@ -29154,7 +29184,7 @@ var Launcher = class {
29154
29184
  try {
29155
29185
  const caller = { pid: req.ppid ?? 0, uid: req.cred.euid, tag: req.tags?.[0] };
29156
29186
  if (this.integrity) await this.checkedSources(planned, caller);
29157
- [program, exeId] = await Promise.all([this.program(target, env, caller), this.exeId(target)]);
29187
+ [program, exeId] = await this.loaded(target, env, caller);
29158
29188
  if (readsEtcHostname(program)) setOrDrop(env, "HOSTNAME", own);
29159
29189
  } catch (err) {
29160
29190
  await req.fds.closeAll();