@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.
@@ -2624,7 +2624,7 @@ var KERNEL_VERSION, OS_RELEASE;
2624
2624
  var init_version = __esm({
2625
2625
  "src/version.ts"() {
2626
2626
  "use strict";
2627
- KERNEL_VERSION = true ? "1.124.8" : "0.0.0-dev";
2627
+ KERNEL_VERSION = true ? "1.124.9" : "0.0.0-dev";
2628
2628
  OS_RELEASE = "6.0.0-slicc";
2629
2629
  }
2630
2630
  });
@@ -7983,6 +7983,9 @@ var init_wasi_fds = __esm({
7983
7983
  const alias = stdioAlias(path);
7984
7984
  if (alias !== void 0) return this.reopen(alias);
7985
7985
  const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
7986
+ if (exclusive && this.shared && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
7987
+ return this.kernelFile(path, void 0, oflags, rights, fdflags, mode, true);
7988
+ }
7986
7989
  if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
7987
7990
  const s = this.statOrMissing(path);
7988
7991
  if (exclusive && s) throw new WasiError("EEXIST");
@@ -8082,11 +8085,11 @@ var init_wasi_fds = __esm({
8082
8085
  if (id !== void 0) this.know(buffer, id);
8083
8086
  return buffer;
8084
8087
  }
8085
- kernelFile(path, existing, oflags, rights, fdflags, mode) {
8088
+ kernelFile(path, existing, oflags, rights, fdflags, mode, created = false) {
8086
8089
  const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
8087
8090
  const append = (fdflags & FDFLAGS.APPEND) !== 0;
8088
8091
  const flags = (writable2 ? readable3 ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND2 : 0);
8089
- const made = !existing && this.createNew(path, oflags, mode);
8092
+ const made = created || !existing && this.createNew(path, oflags, mode);
8090
8093
  const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
8091
8094
  const fd = this.kernel.sys.openVfs(path, flags, 0, {
8092
8095
  ...truncate ? { truncate } : {},
@@ -8121,6 +8124,16 @@ var init_wasi_fds = __esm({
8121
8124
  }
8122
8125
  }
8123
8126
  }
8127
+ madeAtOnce(path, mode) {
8128
+ if (!this.fs.create) return false;
8129
+ try {
8130
+ this.fs.create(path, mode, true);
8131
+ return true;
8132
+ } catch (err) {
8133
+ if (err.code === "EEXIST") throw err;
8134
+ return false;
8135
+ }
8136
+ }
8124
8137
  createNew(path, oflags, mode) {
8125
8138
  if (!this.fs.create) {
8126
8139
  this.fs.writeFile(path, new Uint8Array(0));
@@ -10879,15 +10892,37 @@ function frozen(bytes) {
10879
10892
  truncate: refuse2
10880
10893
  };
10881
10894
  }
10882
- function procfsBridge(fs, tree) {
10883
- const toProc = (path, follow2) => procPath(fs, path, follow2);
10884
- const shadowing = () => {
10895
+ function physicalProc(fs) {
10896
+ const view = fs.changes;
10897
+ let seen;
10898
+ return () => {
10899
+ if (seen && view && !view.foreign()) {
10900
+ const proc = view.changedSince(seen.gen, "/proc");
10901
+ if (!proc.changed && !view.changedSince(seen.gen, "/").changed) {
10902
+ seen.gen = proc.now;
10903
+ return seen.physical;
10904
+ }
10905
+ }
10906
+ const gen = view?.now();
10907
+ let physical2;
10885
10908
  try {
10886
- return fs.exists("/proc");
10887
- } catch {
10888
- return false;
10909
+ fs.stat("/proc");
10910
+ physical2 = true;
10911
+ } catch (err) {
10912
+ const code2 = err.code;
10913
+ if (code2 !== "ENOENT" && code2 !== "ENOTDIR") {
10914
+ seen = void 0;
10915
+ return false;
10916
+ }
10917
+ physical2 = false;
10889
10918
  }
10919
+ seen = gen === void 0 ? void 0 : { gen, physical: physical2 };
10920
+ return physical2;
10890
10921
  };
10922
+ }
10923
+ function procfsBridge(fs, tree) {
10924
+ const toProc = (path, follow2) => procPath(fs, path, follow2);
10925
+ const shadowing = physicalProc(fs);
10891
10926
  const via = (p, proc, own, follow2 = true) => {
10892
10927
  if (inProc(p)) return proc(p);
10893
10928
  if (shadowing()) {