@ai-ecoverse/slicc-kernel 1.119.0 → 1.119.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.
@@ -2542,7 +2542,7 @@ var KERNEL_VERSION, OS_RELEASE;
2542
2542
  var init_version = __esm({
2543
2543
  "src/version.ts"() {
2544
2544
  "use strict";
2545
- KERNEL_VERSION = true ? "1.119.0" : "0.0.0-dev";
2545
+ KERNEL_VERSION = true ? "1.119.2" : "0.0.0-dev";
2546
2546
  OS_RELEASE = "6.0.0-slicc";
2547
2547
  }
2548
2548
  });
@@ -2600,6 +2600,7 @@ function recordLock(fcntl, deps) {
2600
2600
  const Fs = deps.fs();
2601
2601
  const buffer = deps.memory();
2602
2602
  const stream = Fs?.getStream(fd);
2603
+ if (stream && Fs && !stream.sliccKernelFile) lockPromoters.get(Fs)?.()(stream);
2603
2604
  const target = stream ? lockTarget(stream) : void 0;
2604
2605
  if (!Fs || !buffer || !stream || !target) return fcntl(fd, cmd, varargs);
2605
2606
  const view = new DataView(buffer);
@@ -2638,7 +2639,7 @@ function closeDropsLocks(Fs, kernel) {
2638
2639
  }
2639
2640
  };
2640
2641
  }
2641
- var F_GETLK, F_SETLK, F_SETLKW, F_RDLCK, F_WRLCK, F_UNLCK, SEEK_CUR2, SEEK_END2, O_ACCMODE2, O_RDONLY, O_WRONLY, held;
2642
+ var F_GETLK, F_SETLK, F_SETLKW, F_RDLCK, F_WRLCK, F_UNLCK, SEEK_CUR2, SEEK_END2, O_ACCMODE2, O_RDONLY, O_WRONLY, lockPromoters, held;
2642
2643
  var init_process_locks = __esm({
2643
2644
  "src/process/process-locks.ts"() {
2644
2645
  "use strict";
@@ -2655,6 +2656,7 @@ var init_process_locks = __esm({
2655
2656
  O_ACCMODE2 = 3;
2656
2657
  O_RDONLY = 0;
2657
2658
  O_WRONLY = 1;
2659
+ lockPromoters = /* @__PURE__ */ new WeakMap();
2658
2660
  held = /* @__PURE__ */ new WeakMap();
2659
2661
  }
2660
2662
  });
@@ -4600,6 +4602,7 @@ function anySelect(Fs, transport, read2, write2, timeoutMs2) {
4600
4602
  }
4601
4603
  function createProcessKernel(deps) {
4602
4604
  const { transport, Fs } = deps;
4605
+ if (deps.stdioPromoter) lockPromoters.set(Fs, deps.stdioPromoter);
4603
4606
  const reaped = /* @__PURE__ */ new Map();
4604
4607
  const call2 = (req, label) => transport.call(req, Infinity, label);
4605
4608
  const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
@@ -4762,6 +4765,7 @@ var init_process_children = __esm({
4762
4765
  "use strict";
4763
4766
  init_signals();
4764
4767
  init_process_fork();
4768
+ init_process_locks();
4765
4769
  init_wasi_errno();
4766
4770
  S_IFMT2 = 61440;
4767
4771
  S_IFDIR2 = 16384;
@@ -6720,6 +6724,7 @@ var init_wasi_files = __esm({
6720
6724
  LocalFile = class {
6721
6725
  offset = 0;
6722
6726
  refs = 1;
6727
+ ino;
6723
6728
  buffer;
6724
6729
  readable;
6725
6730
  writable;
@@ -6939,6 +6944,7 @@ function lockImports(host) {
6939
6944
  },
6940
6945
  fcntl_lock: (fd, cmd, at) => {
6941
6946
  if (cmd !== F_GETLK2 && cmd !== F_SETLK2 && cmd !== F_SETLKW2) throw new WasiError("EINVAL");
6947
+ host.promote(fd, true);
6942
6948
  const file = host.file(fd);
6943
6949
  const view = host.mem.view();
6944
6950
  const kind = kindOf2(view.getInt16(at, true));
@@ -7452,9 +7458,9 @@ var init_wasi_fds = __esm({
7452
7458
  }
7453
7459
  this.bump();
7454
7460
  }
7455
- promote(fd) {
7461
+ promote(fd, moved = false) {
7456
7462
  const e = this.get(fd);
7457
- if (e.type === "file") this.promoteFiles(e.file.buffer);
7463
+ if (e.type === "file" && (!moved || this.moved(fd))) this.promoteFiles(e.file.buffer);
7458
7464
  }
7459
7465
  promoteFiles(only) {
7460
7466
  const promoted = /* @__PURE__ */ new Map();
@@ -7684,6 +7690,12 @@ var init_wasi_fds = __esm({
7684
7690
  throw err;
7685
7691
  }
7686
7692
  }
7693
+ moved(fd) {
7694
+ const e = this.get(fd);
7695
+ if (e.type !== "file") return false;
7696
+ if (e.file.buffer.isOrphan()) return true;
7697
+ return e.file.ino !== void 0 && this.inoOf(e.file.path) !== e.file.ino;
7698
+ }
7687
7699
  inoOf(path) {
7688
7700
  try {
7689
7701
  return this.fs.stat(path).ino;
@@ -7827,7 +7839,9 @@ var init_wasi_fds = __esm({
7827
7839
  buffer = this.freshBuffer(path, existing, oflags, want, mode);
7828
7840
  }
7829
7841
  buffer.opens++;
7830
- return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
7842
+ const file = new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
7843
+ file.ino = existing?.ino;
7844
+ return file;
7831
7845
  }
7832
7846
  freshBuffer(path, existing, oflags, want, mode) {
7833
7847
  const made = !existing && this.createNew(path, oflags, mode);
@@ -9154,7 +9168,7 @@ var init_wasi_host = __esm({
9154
9168
  else if (file.target.fd !== void 0) this.o.kernel.sys.flush(file.target.fd);
9155
9169
  },
9156
9170
  locked: () => this.fds.holdLocks(),
9157
- promote: (fd) => this.fds.promote(fd),
9171
+ promote: (fd, moved) => this.fds.promote(fd, moved),
9158
9172
  calls: {
9159
9173
  flock: (fd, kind, wait2) => void this.fds.restarting(
9160
9174
  () => this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} })