@ai-ecoverse/slicc-kernel 1.124.8 → 1.124.9

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.
@@ -2588,6 +2588,9 @@ var init_wasi_fds = __esm({
2588
2588
  const alias = stdioAlias(path);
2589
2589
  if (alias !== void 0) return this.reopen(alias);
2590
2590
  const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
2591
+ if (exclusive && this.shared && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
2592
+ return this.kernelFile(path, void 0, oflags, rights, fdflags, mode, true);
2593
+ }
2591
2594
  if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
2592
2595
  const s = this.statOrMissing(path);
2593
2596
  if (exclusive && s) throw new WasiError("EEXIST");
@@ -2687,11 +2690,11 @@ var init_wasi_fds = __esm({
2687
2690
  if (id !== void 0) this.know(buffer, id);
2688
2691
  return buffer;
2689
2692
  }
2690
- kernelFile(path, existing, oflags, rights, fdflags, mode) {
2693
+ kernelFile(path, existing, oflags, rights, fdflags, mode, created = false) {
2691
2694
  const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
2692
2695
  const append = (fdflags & FDFLAGS.APPEND) !== 0;
2693
2696
  const flags = (writable2 ? readable3 ? O_RDWR : O_WRONLY : 0) | (append ? O_APPEND : 0);
2694
- const made = !existing && this.createNew(path, oflags, mode);
2697
+ const made = created || !existing && this.createNew(path, oflags, mode);
2695
2698
  const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
2696
2699
  const fd = this.kernel.sys.openVfs(path, flags, 0, {
2697
2700
  ...truncate ? { truncate } : {},
@@ -2726,6 +2729,16 @@ var init_wasi_fds = __esm({
2726
2729
  }
2727
2730
  }
2728
2731
  }
2732
+ madeAtOnce(path, mode) {
2733
+ if (!this.fs.create) return false;
2734
+ try {
2735
+ this.fs.create(path, mode, true);
2736
+ return true;
2737
+ } catch (err) {
2738
+ if (err.code === "EEXIST") throw err;
2739
+ return false;
2740
+ }
2741
+ }
2729
2742
  createNew(path, oflags, mode) {
2730
2743
  if (!this.fs.create) {
2731
2744
  this.fs.writeFile(path, new Uint8Array(0));
@@ -5438,7 +5451,7 @@ var KERNEL_VERSION, OS_RELEASE;
5438
5451
  var init_version = __esm({
5439
5452
  "src/version.ts"() {
5440
5453
  "use strict";
5441
- KERNEL_VERSION = true ? "1.124.8" : "0.0.0-dev";
5454
+ KERNEL_VERSION = true ? "1.124.9" : "0.0.0-dev";
5442
5455
  OS_RELEASE = "6.0.0-slicc";
5443
5456
  }
5444
5457
  });
@@ -10293,15 +10306,37 @@ function frozen(bytes) {
10293
10306
  truncate: refuse2
10294
10307
  };
10295
10308
  }
10296
- function procfsBridge(fs, tree) {
10297
- const toProc = (path, follow2) => procPath(fs, path, follow2);
10298
- const shadowing = () => {
10309
+ function physicalProc(fs) {
10310
+ const view = fs.changes;
10311
+ let seen;
10312
+ return () => {
10313
+ if (seen && view && !view.foreign()) {
10314
+ const proc = view.changedSince(seen.gen, "/proc");
10315
+ if (!proc.changed && !view.changedSince(seen.gen, "/").changed) {
10316
+ seen.gen = proc.now;
10317
+ return seen.physical;
10318
+ }
10319
+ }
10320
+ const gen = view?.now();
10321
+ let physical2;
10299
10322
  try {
10300
- return fs.exists("/proc");
10301
- } catch {
10302
- return false;
10323
+ fs.stat("/proc");
10324
+ physical2 = true;
10325
+ } catch (err) {
10326
+ const code2 = err.code;
10327
+ if (code2 !== "ENOENT" && code2 !== "ENOTDIR") {
10328
+ seen = void 0;
10329
+ return false;
10330
+ }
10331
+ physical2 = false;
10303
10332
  }
10333
+ seen = gen === void 0 ? void 0 : { gen, physical: physical2 };
10334
+ return physical2;
10304
10335
  };
10336
+ }
10337
+ function procfsBridge(fs, tree) {
10338
+ const toProc = (path, follow2) => procPath(fs, path, follow2);
10339
+ const shadowing = physicalProc(fs);
10305
10340
  const via = (p, proc, own, follow2 = true) => {
10306
10341
  if (inProc(p)) return proc(p);
10307
10342
  if (shadowing()) {