@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.
@@ -1060,6 +1060,7 @@ var init_wasi_files = __esm({
1060
1060
  LocalFile = class {
1061
1061
  offset = 0;
1062
1062
  refs = 1;
1063
+ ino;
1063
1064
  buffer;
1064
1065
  readable;
1065
1066
  writable;
@@ -1732,6 +1733,7 @@ function lockImports(host) {
1732
1733
  },
1733
1734
  fcntl_lock: (fd, cmd, at) => {
1734
1735
  if (cmd !== F_GETLK && cmd !== F_SETLK && cmd !== F_SETLKW) throw new WasiError("EINVAL");
1736
+ host.promote(fd, true);
1735
1737
  const file = host.file(fd);
1736
1738
  const view = host.mem.view();
1737
1739
  const kind = kindOf(view.getInt16(at, true));
@@ -2245,9 +2247,9 @@ var init_wasi_fds = __esm({
2245
2247
  }
2246
2248
  this.bump();
2247
2249
  }
2248
- promote(fd) {
2250
+ promote(fd, moved = false) {
2249
2251
  const e = this.get(fd);
2250
- if (e.type === "file") this.promoteFiles(e.file.buffer);
2252
+ if (e.type === "file" && (!moved || this.moved(fd))) this.promoteFiles(e.file.buffer);
2251
2253
  }
2252
2254
  promoteFiles(only) {
2253
2255
  const promoted = /* @__PURE__ */ new Map();
@@ -2477,6 +2479,12 @@ var init_wasi_fds = __esm({
2477
2479
  throw err;
2478
2480
  }
2479
2481
  }
2482
+ moved(fd) {
2483
+ const e = this.get(fd);
2484
+ if (e.type !== "file") return false;
2485
+ if (e.file.buffer.isOrphan()) return true;
2486
+ return e.file.ino !== void 0 && this.inoOf(e.file.path) !== e.file.ino;
2487
+ }
2480
2488
  inoOf(path) {
2481
2489
  try {
2482
2490
  return this.fs.stat(path).ino;
@@ -2620,7 +2628,9 @@ var init_wasi_fds = __esm({
2620
2628
  buffer = this.freshBuffer(path, existing, oflags, want, mode);
2621
2629
  }
2622
2630
  buffer.opens++;
2623
- return new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
2631
+ const file = new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
2632
+ file.ino = existing?.ino;
2633
+ return file;
2624
2634
  }
2625
2635
  freshBuffer(path, existing, oflags, want, mode) {
2626
2636
  const made = !existing && this.createNew(path, oflags, mode);
@@ -3993,7 +4003,7 @@ var init_wasi_host = __esm({
3993
4003
  else if (file.target.fd !== void 0) this.o.kernel.sys.flush(file.target.fd);
3994
4004
  },
3995
4005
  locked: () => this.fds.holdLocks(),
3996
- promote: (fd) => this.fds.promote(fd),
4006
+ promote: (fd, moved) => this.fds.promote(fd, moved),
3997
4007
  calls: {
3998
4008
  flock: (fd, kind, wait2) => void this.fds.restarting(
3999
4009
  () => this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} })
@@ -5385,7 +5395,7 @@ var KERNEL_VERSION, OS_RELEASE;
5385
5395
  var init_version = __esm({
5386
5396
  "src/version.ts"() {
5387
5397
  "use strict";
5388
- KERNEL_VERSION = true ? "1.119.0" : "0.0.0-dev";
5398
+ KERNEL_VERSION = true ? "1.119.2" : "0.0.0-dev";
5389
5399
  OS_RELEASE = "6.0.0-slicc";
5390
5400
  }
5391
5401
  });
@@ -8586,6 +8596,7 @@ function recordLock(fcntl, deps) {
8586
8596
  const Fs = deps.fs();
8587
8597
  const buffer = deps.memory();
8588
8598
  const stream = Fs?.getStream(fd);
8599
+ if (stream && Fs && !stream.sliccKernelFile) lockPromoters.get(Fs)?.()(stream);
8589
8600
  const target = stream ? lockTarget(stream) : void 0;
8590
8601
  if (!Fs || !buffer || !stream || !target) return fcntl(fd, cmd, varargs);
8591
8602
  const view = new DataView(buffer);
@@ -8624,7 +8635,7 @@ function closeDropsLocks(Fs, kernel) {
8624
8635
  }
8625
8636
  };
8626
8637
  }
8627
- var F_GETLK2, F_SETLK2, F_SETLKW2, F_RDLCK2, F_WRLCK2, F_UNLCK2, SEEK_CUR3, SEEK_END3, O_ACCMODE2, O_RDONLY, O_WRONLY4, held;
8638
+ var F_GETLK2, F_SETLK2, F_SETLKW2, F_RDLCK2, F_WRLCK2, F_UNLCK2, SEEK_CUR3, SEEK_END3, O_ACCMODE2, O_RDONLY, O_WRONLY4, lockPromoters, held;
8628
8639
  var init_process_locks = __esm({
8629
8640
  "src/process/process-locks.ts"() {
8630
8641
  "use strict";
@@ -8641,6 +8652,7 @@ var init_process_locks = __esm({
8641
8652
  O_ACCMODE2 = 3;
8642
8653
  O_RDONLY = 0;
8643
8654
  O_WRONLY4 = 1;
8655
+ lockPromoters = /* @__PURE__ */ new WeakMap();
8644
8656
  held = /* @__PURE__ */ new WeakMap();
8645
8657
  }
8646
8658
  });
@@ -12928,6 +12940,7 @@ function anySelect(Fs, transport, read2, write2, timeoutMs2) {
12928
12940
  }
12929
12941
  function createProcessKernel(deps) {
12930
12942
  const { transport, Fs } = deps;
12943
+ if (deps.stdioPromoter) lockPromoters.set(Fs, deps.stdioPromoter);
12931
12944
  const reaped = /* @__PURE__ */ new Map();
12932
12945
  const call2 = (req, label) => transport.call(req, Infinity, label);
12933
12946
  const at = (path) => path === "" || path.startsWith("/") ? path : `${Fs.cwd()}/${path}`;
@@ -13090,6 +13103,7 @@ var init_process_children = __esm({
13090
13103
  "use strict";
13091
13104
  init_signals();
13092
13105
  init_process_fork();
13106
+ init_process_locks();
13093
13107
  init_wasi_errno();
13094
13108
  S_IFMT3 = 61440;
13095
13109
  S_IFDIR2 = 16384;