@ai-ecoverse/slicc-kernel 1.125.10 → 1.125.12

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
@@ -4359,6 +4359,7 @@ var ABSENT_NAMES = 4096;
4359
4359
  var FILE_HANDLES = 4096;
4360
4360
  var STALE = /* @__PURE__ */ new Set(["NotFoundError", "TypeMismatchError"]);
4361
4361
  var REPLACED_ATTEMPTS = 4;
4362
+ var RECONCILE_LISTINGS = 8;
4362
4363
  var EXECUTABLE = /\/node_modules\/(?:@[^/]+\/)?[^/]+\/bin\//;
4363
4364
  var ERRNO_BY_DOM_ERROR = {
4364
4365
  NotFoundError: "ENOENT",
@@ -5714,15 +5715,57 @@ var OpfsFs = class {
5714
5715
  timesBy: this.id
5715
5716
  }));
5716
5717
  }
5718
+ async present(paths) {
5719
+ const listed = /* @__PURE__ */ new Map();
5720
+ const done4 = /* @__PURE__ */ new Map();
5721
+ const list = (dir) => {
5722
+ const known = listed.get(dir);
5723
+ if (known !== void 0) return known;
5724
+ const listing = (async () => {
5725
+ const above = dir === "/" ? void 0 : await list(parentOf4(dir));
5726
+ if (above === null) return null;
5727
+ const handle = dir === "/" ? this.root : above?.get(baseOf(dir));
5728
+ if (handle?.kind !== "directory") return void 0;
5729
+ this.calls++;
5730
+ const children3 = /* @__PURE__ */ new Map();
5731
+ try {
5732
+ for await (const child of handle.values())
5733
+ children3.set(child.name, child);
5734
+ } catch {
5735
+ return null;
5736
+ }
5737
+ return children3;
5738
+ })().then((children3) => {
5739
+ done4.set(dir, children3);
5740
+ return children3;
5741
+ });
5742
+ listed.set(dir, listing);
5743
+ return listing;
5744
+ };
5745
+ const dirs = [...new Set(paths.filter((p) => split(p).length > 0).map(parentOf4))];
5746
+ let next3 = 0;
5747
+ const lister = async () => {
5748
+ while (next3 < dirs.length) await list(dirs[next3++]);
5749
+ };
5750
+ await Promise.all(Array.from({ length: Math.min(RECONCILE_LISTINGS, dirs.length) }, lister));
5751
+ return async (path) => {
5752
+ if (split(path).length === 0) return true;
5753
+ const listing = done4.get(parentOf4(path));
5754
+ if (listing === null) return this.real(path);
5755
+ return listing?.has(baseOf(path)) === true;
5756
+ };
5757
+ }
5717
5758
  async reconcile() {
5718
5759
  if (this.remote && await this.remote.peered()) return 0;
5719
5760
  let removed = 0;
5720
5761
  const entries = await this.meta.all();
5721
5762
  const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
5722
- for (const entry of entries) {
5723
- if (entry.vacated && carried.has(inodeOf(entry.path))) continue;
5724
- const real = await this.real(entry.path);
5725
- const stale = entry.link === void 0 ? !real : real || !await this.real(parentOf4(entry.path));
5763
+ const checked = entries.filter((e) => !(e.vacated && carried.has(inodeOf(e.path))));
5764
+ const real = await this.present(
5765
+ checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf4(e.path)])
5766
+ );
5767
+ for (const entry of checked) {
5768
+ const stale = entry.link === void 0 ? !await real(entry.path) : await real(entry.path) || !await real(parentOf4(entry.path));
5726
5769
  if (!stale) continue;
5727
5770
  const seen = JSON.stringify(entry);
5728
5771
  await this.meta.update(
@@ -7110,7 +7153,7 @@ function satisfies(version, range2) {
7110
7153
  }
7111
7154
 
7112
7155
  // src/version.ts
7113
- var KERNEL_VERSION = true ? "1.125.10" : "0.0.0-dev";
7156
+ var KERNEL_VERSION = true ? "1.125.12" : "0.0.0-dev";
7114
7157
  var OS_RELEASE = "6.0.0-slicc";
7115
7158
  function procVersion() {
7116
7159
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -18386,9 +18429,21 @@ var VfsNode = class {
18386
18429
  }
18387
18430
  async keep() {
18388
18431
  const ranged2 = await this.prepare();
18389
- await ranged2?.pin();
18432
+ if (ranged2) await this.followed(() => ranged2.pin());
18390
18433
  }
18391
18434
  moving = /* @__PURE__ */ new Set();
18435
+ async followed(op) {
18436
+ for (; ; ) {
18437
+ const at = this.path;
18438
+ try {
18439
+ return await op();
18440
+ } catch (err) {
18441
+ if (!isMissing(err)) throw err;
18442
+ while (this.moving.size > 0) await Promise.all(this.moving);
18443
+ if (this.path === at) throw err;
18444
+ }
18445
+ }
18446
+ }
18392
18447
  async load() {
18393
18448
  if (this.revoked) throw new KernelError("EIO");
18394
18449
  while (!this.data) {
@@ -18434,7 +18489,7 @@ var VfsNode = class {
18434
18489
  }
18435
18490
  async pread(max, at) {
18436
18491
  const ranged2 = await this.prepare();
18437
- if (ranged2) return ranged2.read(at, max);
18492
+ if (ranged2) return this.followed(() => ranged2.read(at, max));
18438
18493
  const bytes = await this.load();
18439
18494
  const n = Math.max(0, Math.min(max, this.length - at));
18440
18495
  return bytes.slice(at, at + n);
@@ -18477,7 +18532,7 @@ var VfsNode = class {
18477
18532
  await this.fits(at + bytes.length);
18478
18533
  const ranged2 = await this.prepare();
18479
18534
  if (ranged2) {
18480
- await ranged2.write(at, bytes);
18535
+ await this.followed(() => ranged2.write(at, bytes));
18481
18536
  this.markDirty();
18482
18537
  return bytes.length;
18483
18538
  }
@@ -18546,8 +18601,9 @@ var VfsNode = class {
18546
18601
  this.dirty = false;
18547
18602
  const started = performance.now();
18548
18603
  try {
18549
- if (this.ranged) await this.ranged.flush();
18550
- else await this.fs.writeFile(this.path, this.data.slice(0, this.length));
18604
+ await this.followed(
18605
+ () => this.ranged ? this.ranged.flush() : this.fs.writeFile(this.path, this.data.slice(0, this.length))
18606
+ );
18551
18607
  } catch (err) {
18552
18608
  this.dirty = true;
18553
18609
  throw err;
@@ -19291,6 +19347,7 @@ var MAX_READ = 1024 * 1024;
19291
19347
  var O_NONBLOCK = 2048;
19292
19348
  var WRITE_ACCESS = 3;
19293
19349
  var KEYBOARD = /* @__PURE__ */ new Set([SIG.INT, SIG.QUIT, SIG.TSTP]);
19350
+ var STUCK_ESCAPES = /* @__PURE__ */ new Set([SIG.INT, SIG.TERM, SIG.QUIT, SIG.HUP]);
19294
19351
  var DEFAULT_UMASK2 = 18;
19295
19352
  function words(value2) {
19296
19353
  if (!Array.isArray(value2) || !value2.every((w) => typeof w === "string")) {
@@ -19347,6 +19404,8 @@ var WasmProcess = class {
19347
19404
  cred;
19348
19405
  execChild;
19349
19406
  killed = false;
19407
+ calls = 0;
19408
+ pendingAt = /* @__PURE__ */ new Map();
19350
19409
  execTermsig;
19351
19410
  stopped = 0;
19352
19411
  stops = 0;
@@ -19445,9 +19504,9 @@ var WasmProcess = class {
19445
19504
  const action = defaultAction(sig);
19446
19505
  return action === "stop" ? this.stop(sig) : action;
19447
19506
  }
19448
- if (((this.options.pendingBits?.() ?? 0) & bit) !== 0 && defaultAction(sig) === "terminate") {
19449
- return "terminate";
19450
- }
19507
+ if (((this.options.pendingBits?.() ?? 0) & bit) !== 0) {
19508
+ if (STUCK_ESCAPES.has(sig) && this.pendingAt.get(sig) === this.calls) return "terminate";
19509
+ } else this.pendingAt.set(sig, this.calls);
19451
19510
  this.options.onPending?.(sig);
19452
19511
  if (this.options.jobs?.keyboard && KEYBOARD.has(sig) && this.waiting.size === 0)
19453
19512
  this.owed = true;
@@ -19570,6 +19629,7 @@ var WasmProcess = class {
19570
19629
  }
19571
19630
  async syscall(req, cancelled, block) {
19572
19631
  this.options.onSyscall?.(req);
19632
+ this.calls += 1;
19573
19633
  const started = performance.now();
19574
19634
  let restarted = false;
19575
19635
  for (; ; ) {