@ai-ecoverse/slicc-kernel 1.54.7 → 1.54.8

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.
@@ -4015,13 +4015,13 @@ function netOps(kernel, io) {
4015
4015
  const r = await kernel.raw({ op: "sock-connect", fd, addr, nonblock: true });
4016
4016
  if (!r.ok && r.errno !== "EINPROGRESS") throw new JsCallError(r.errno, "connect");
4017
4017
  await kernel.blocking({ op: "fd-select", read: [], write: [fd], timeoutMs: -1 }, signal);
4018
- const failed4 = await kernel.json({
4018
+ const failed5 = await kernel.json({
4019
4019
  op: "sock-getopt",
4020
4020
  fd,
4021
4021
  level: SOL_SOCKET,
4022
4022
  name: SO_ERROR
4023
4023
  });
4024
- if (failed4 !== 0) throw new JsCallError(errnoName(failed4), "connect");
4024
+ if (failed5 !== 0) throw new JsCallError(errnoName(failed5), "connect");
4025
4025
  return connection(fd);
4026
4026
  });
4027
4027
  }
@@ -8356,12 +8356,12 @@ async function runWasmProcess(init, port3, deps = {}) {
8356
8356
  const say = (fd) => (text) => sys.write(fd, encoder4.encode(`${text}
8357
8357
  `));
8358
8358
  let ready;
8359
- let failed4;
8359
+ let failed5;
8360
8360
  let memory;
8361
8361
  let exports;
8362
8362
  const initialized = new Promise((resolve, reject) => {
8363
8363
  ready = resolve;
8364
- failed4 = reject;
8364
+ failed5 = reject;
8365
8365
  });
8366
8366
  const id = identify(transport, init);
8367
8367
  const module = {
@@ -8414,7 +8414,7 @@ async function runWasmProcess(init, port3, deps = {}) {
8414
8414
  exports = instance.exports;
8415
8415
  publishMemory(init.sab, memory?.buffer.byteLength ?? 0);
8416
8416
  done(instance, init.program.module);
8417
- }, failed4);
8417
+ }, failed5);
8418
8418
  return {};
8419
8419
  },
8420
8420
  preRun: [
@@ -8715,6 +8715,7 @@ function* procWalk(path, follow2) {
8715
8715
  let done = [];
8716
8716
  let todo = path.split("/").filter((part) => part !== "");
8717
8717
  let hops = 0;
8718
+ let broken;
8718
8719
  while (todo.length > 0) {
8719
8720
  const part = todo.shift();
8720
8721
  if (part === ".") continue;
@@ -8724,32 +8725,48 @@ function* procWalk(path, follow2) {
8724
8725
  }
8725
8726
  const at = `/${[...done, part].join("/")}`;
8726
8727
  const whole = normalize(`/${[...done, part, ...todo].join("/")}`);
8727
- if (inProc(at) && inProc(whole)) return whole;
8728
+ if (inProc(at) && inProc(whole)) return broken ?? whole;
8728
8729
  if (!follow2 && todo.length === 0) return void 0;
8729
- const target = yield at;
8730
- if (target === null) return void 0;
8731
- if (target === void 0) done.push(part);
8732
- else {
8730
+ const target = yield { at, check: todo.find((next2) => next2 !== ".") === ".." };
8731
+ if (typeof target === "string") {
8733
8732
  if (++hops > MAX_HOPS2) return void 0;
8734
- if (target.startsWith("/")) done = [];
8735
- todo = [...target.split("/").filter((part2) => part2 !== ""), ...todo];
8733
+ [done, todo] = throughLink(target, done, todo);
8734
+ } else {
8735
+ broken ??= refusalOf(target);
8736
+ done.push(part);
8736
8737
  }
8737
8738
  }
8738
8739
  return void 0;
8739
8740
  }
8741
+ function failed4(err) {
8742
+ const code2 = err?.code;
8743
+ return { refused: typeof code2 === "string" ? code2 : "ENOENT" };
8744
+ }
8745
+ function refusalOf(found) {
8746
+ if (found === true) return void 0;
8747
+ return found === false ? { refused: "ENOTDIR" } : found;
8748
+ }
8749
+ function throughLink(target, done, todo) {
8750
+ const parts = target.split("/").filter((part) => part !== "");
8751
+ return [target.startsWith("/") ? [] : done, [...parts, ...todo]];
8752
+ }
8740
8753
  function procPath(fs, path, follow2) {
8741
8754
  const walk = procWalk(path, follow2);
8742
8755
  let step = walk.next();
8743
8756
  while (!step.done) {
8757
+ const { at, check } = step.value;
8744
8758
  let target;
8745
8759
  try {
8746
- target = fs.lstat(step.value).isSymbolicLink ? fs.readlink(step.value) : void 0;
8747
- } catch {
8748
- target = null;
8760
+ const st = fs.lstat(at);
8761
+ target = st.isSymbolicLink ? fs.readlink(at) : !check || st.isDirectory;
8762
+ } catch (err) {
8763
+ target = failed4(err);
8749
8764
  }
8750
8765
  step = walk.next(target);
8751
8766
  }
8752
- return step.value;
8767
+ const result = step.value;
8768
+ if (typeof result === "object") throw syncError(result.refused, path);
8769
+ return result;
8753
8770
  }
8754
8771
  function frozen(bytes) {
8755
8772
  const refuse = () => {
@@ -8831,11 +8848,19 @@ function procfsBridge(fs, tree) {
8831
8848
  ),
8832
8849
  exists: (p) => {
8833
8850
  if (inProc(p)) return tree.exists(p);
8834
- const real = shadowing() ? toProc(p, true) : void 0;
8851
+ const probe = () => {
8852
+ try {
8853
+ return toProc(p, true);
8854
+ } catch {
8855
+ return null;
8856
+ }
8857
+ };
8858
+ const real = shadowing() ? probe() : void 0;
8859
+ if (real === null) return false;
8835
8860
  if (real !== void 0) return tree.exists(real);
8836
8861
  if (fs.exists(p)) return true;
8837
- const late2 = toProc(p, true);
8838
- return late2 !== void 0 && tree.exists(late2);
8862
+ const late2 = probe();
8863
+ return typeof late2 === "string" && tree.exists(late2);
8839
8864
  },
8840
8865
  readlink: (p) => via(
8841
8866
  p,
@@ -10769,7 +10794,7 @@ var init_wasix_host = __esm({
10769
10794
  }
10770
10795
  dlImports() {
10771
10796
  const { mem, host } = this;
10772
- const failed4 = (message2, buf, len) => {
10797
+ const failed5 = (message2, buf, len) => {
10773
10798
  if (len > 0) {
10774
10799
  const bytes = new TextEncoder().encode(message2).subarray(0, len - 1);
10775
10800
  mem.bytes(buf, bytes.length).set(bytes);
@@ -10778,19 +10803,19 @@ var init_wasix_host = __esm({
10778
10803
  return E.NOEXEC;
10779
10804
  };
10780
10805
  const linked = (buf, len, op, out) => {
10781
- if (!this.linker) return failed4("not a dynamically-linked program", buf, len);
10806
+ if (!this.linker) return failed5("not a dynamically-linked program", buf, len);
10782
10807
  try {
10783
10808
  out(op(this.linker));
10784
10809
  return E.SUCCESS;
10785
10810
  } catch (e) {
10786
- if (e instanceof DlError) return failed4(e.message, buf, len);
10811
+ if (e instanceof DlError) return failed5(e.message, buf, len);
10787
10812
  throw e;
10788
10813
  }
10789
10814
  };
10790
10815
  return {
10791
10816
  dlopen: (p, pl, _flags, buf, len, lp, ll, out) => {
10792
10817
  if (p === 0) {
10793
- if (!this.linker) return failed4("not a dynamically-linked program", buf, len);
10818
+ if (!this.linker) return failed5("not a dynamically-linked program", buf, len);
10794
10819
  mem.view().setUint32(out, MAIN_HANDLE, true);
10795
10820
  return E.SUCCESS;
10796
10821
  }
@@ -11605,20 +11630,20 @@ function started(init, port3, run, wasi, js) {
11605
11630
  return run(wasmInit, port3);
11606
11631
  }
11607
11632
  function processEntry(port3, run = runWasmProcess, wasi = loadWasi, js = loadJs) {
11608
- const failed4 = (err) => port3.postMessage({
11633
+ const failed5 = (err) => port3.postMessage({
11609
11634
  type: WASM_PROCESS_ERROR,
11610
11635
  message: err instanceof Error ? err.stack ?? err.message : String(err)
11611
11636
  });
11612
11637
  return (data) => {
11613
11638
  const type = data?.type;
11614
11639
  if (type === WASM_THREAD_INIT) {
11615
- wasi().then((m) => m.runWasiThread(data, port3)).catch(failed4);
11640
+ wasi().then((m) => m.runWasiThread(data, port3)).catch(failed5);
11616
11641
  return;
11617
11642
  }
11618
11643
  if (type !== WASM_PROCESS_INIT) return;
11619
11644
  started(data, port3, run, wasi, js).then(
11620
11645
  (code2) => port3.postMessage({ type: WASM_PROCESS_EXIT, code: code2 }),
11621
- failed4
11646
+ failed5
11622
11647
  );
11623
11648
  };
11624
11649
  }