@ai-ecoverse/slicc-kernel 1.195.15 → 1.195.16

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.
@@ -593,11 +593,11 @@ var init_pages = __esm({
593
593
  runs.push({ offset: start2, bytes });
594
594
  i = j;
595
595
  }
596
- const written2 = capturedMath.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
596
+ const written3 = capturedMath.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
597
597
  return {
598
598
  ...this.shrink !== void 0 ? { shrink: this.shrink } : {},
599
599
  runs,
600
- ...this.length > written2 ? { extend: this.length } : {}
600
+ ...this.length > written3 ? { extend: this.length } : {}
601
601
  };
602
602
  }
603
603
  flushed() {
@@ -6520,16 +6520,16 @@ var init_wasi_host = __esm({
6520
6520
  return this.fds.cwd() === void 0 ? this.fds.resolve(3, `${this.workingDir()}/${raw}`) : this.fds.resolve(3, raw);
6521
6521
  }
6522
6522
  lookup(dirfd, raw, kind) {
6523
- const written2 = this.fds.written(dirfd, raw);
6524
- return this.looked(this.fds.resolve(dirfd, written2, kind), written2, kind);
6523
+ const written3 = this.fds.written(dirfd, raw);
6524
+ return this.looked(this.fds.resolve(dirfd, written3, kind), written3, kind);
6525
6525
  }
6526
6526
  looked(path, raw, kind) {
6527
6527
  const node = this.lookupNode(path, raw, kind);
6528
6528
  return typeof node === "string" ? node : physical(this.o.fs, this.refPath(node), true, kind);
6529
6529
  }
6530
6530
  nodeAt(dirfd, raw) {
6531
- const written2 = this.fds.written(dirfd, raw);
6532
- return this.lookupNode(this.fds.resolve(dirfd, written2), written2);
6531
+ const written3 = this.fds.written(dirfd, raw);
6532
+ return this.lookupNode(this.fds.resolve(dirfd, written3), written3);
6533
6533
  }
6534
6534
  lookupNode(path, raw, kind) {
6535
6535
  const dot = finalOf(raw) === ".";
@@ -8486,7 +8486,7 @@ var init_version = __esm({
8486
8486
  "src/version.ts"() {
8487
8487
  "use strict";
8488
8488
  init_captured_globals();
8489
- KERNEL_VERSION = true ? "1.195.15" : "0.0.0-dev";
8489
+ KERNEL_VERSION = true ? "1.195.16" : "0.0.0-dev";
8490
8490
  OS_RELEASE = "6.0.0-slicc";
8491
8491
  }
8492
8492
  });
@@ -19910,11 +19910,20 @@ function codeOf2(e) {
19910
19910
  return code2;
19911
19911
  }
19912
19912
  function openError2(name2, code2) {
19913
+ if (code2 === "EISDIR")
19914
+ return new DlError(`${name2}: cannot read file data: Is a directory`, E.ISDIR);
19913
19915
  return new DlError(
19914
19916
  `${name2}: cannot open shared object file: ${OPEN_ERRORS[code2] ?? code2}`,
19915
19917
  wasiErrnoOf(code2)
19916
19918
  );
19917
19919
  }
19920
+ function fits(path) {
19921
+ return new capturedTextEncoder().encode(path).length < PATH_MAX;
19922
+ }
19923
+ function written2(path, asked) {
19924
+ if (!fits(path)) throw capturedObject.assign(new capturedError("ENAMETOOLONG"), { code: "ENAMETOOLONG" });
19925
+ return asked;
19926
+ }
19918
19927
  function align(n, to) {
19919
19928
  return capturedMath.ceil(n / to) * to;
19920
19929
  }
@@ -19929,7 +19938,7 @@ function call2(instance, name2) {
19929
19938
  const fn2 = instance.exports[name2];
19930
19939
  if (typeof fn2 === "function") fn2();
19931
19940
  }
19932
- var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, OPEN_ERRORS, WasixLinker;
19941
+ var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, OPEN_ERRORS, PASSED, PATH_MAX, WasixLinker;
19933
19942
  var init_wasix_linker = __esm({
19934
19943
  "src/process/wasi/wasix-linker.ts"() {
19935
19944
  "use strict";
@@ -19959,6 +19968,8 @@ var init_wasix_linker = __esm({
19959
19968
  EISDIR: "Is a directory",
19960
19969
  EIO: "Input/output error"
19961
19970
  };
19971
+ PASSED = new capturedSet(["ENOENT", "EACCES", "ENOTDIR"]);
19972
+ PATH_MAX = 4096;
19962
19973
  WasixLinker = class {
19963
19974
  table;
19964
19975
  stackPointer;
@@ -20054,7 +20065,7 @@ var init_wasix_linker = __esm({
20054
20065
  }
20055
20066
  }
20056
20067
  open(name2, cwd, ldPath) {
20057
- const path = this.locate(name2, cwd, ldPath);
20068
+ const path = this.locate(name2, cwd, [ldPath]);
20058
20069
  if (this.isMain(path)) return 0;
20059
20070
  this.indices?.lock();
20060
20071
  try {
@@ -20178,32 +20189,52 @@ var init_wasix_linker = __esm({
20178
20189
  if (!m) throw new DlError(`invalid handle ${handle}`);
20179
20190
  return m;
20180
20191
  }
20181
- locate(name2, cwd, ldPath) {
20192
+ locate(name2, cwd, lists) {
20182
20193
  if (name2.includes("/")) {
20183
20194
  const asked = name2.startsWith("/") ? name2 : `${cwd}/${name2}`;
20184
20195
  let real;
20185
20196
  try {
20186
- real = this.host.resolve(asked);
20197
+ real = this.host.resolve(written2(name2, asked));
20187
20198
  } catch (e) {
20188
20199
  throw openError2(name2, codeOf2(e));
20189
20200
  }
20190
20201
  return this.checked(asked, real, name2);
20191
20202
  }
20192
- for (const dir of [...ldPath, ...LIBRARY_DIRS]) {
20193
- const path = this.candidate(`${dir.startsWith("/") ? "" : `${cwd}/`}${dir}/${name2}`, name2);
20194
- if (path !== void 0) return path;
20203
+ let last = "ENOENT";
20204
+ for (const list of [...lists, LIBRARY_DIRS]) {
20205
+ for (const dir of list) {
20206
+ const found2 = this.candidate(dir, name2, cwd);
20207
+ if ("real" in found2) return found2.real;
20208
+ last = found2.code;
20209
+ if (found2.ends) break;
20210
+ }
20195
20211
  }
20196
- throw new DlError(`${name2}: not found`);
20212
+ throw openError2(name2, last);
20197
20213
  }
20198
- candidate(asked, name2) {
20214
+ candidate(dir, name2, cwd) {
20215
+ const base = dir.replace(/\/+$/, "");
20216
+ const entry = dir === "" ? name2 : `${base}/${name2}`;
20217
+ const asked = dir.startsWith("/") ? entry : `${cwd}/${entry}`;
20199
20218
  let path;
20200
20219
  try {
20201
- path = this.host.resolve(asked);
20220
+ path = this.host.resolve(written2(entry, asked));
20202
20221
  } catch (e) {
20203
- codeOf2(e);
20204
- return void 0;
20222
+ const code2 = codeOf2(e);
20223
+ return { code: code2, ends: !PASSED.has(code2) && this.existing(base || "/", dir) };
20224
+ }
20225
+ if (!this.byPath.has(path)) {
20226
+ try {
20227
+ this.host.open(path);
20228
+ } catch (e) {
20229
+ const code2 = codeOf2(e);
20230
+ if (PASSED.has(code2)) return { code: code2, ends: false };
20231
+ throw openError2(code2 === "EISDIR" ? entry : name2, code2);
20232
+ }
20205
20233
  }
20206
- return this.byPath.has(path) || this.host.read(path) ? this.checked(asked, path, name2) : void 0;
20234
+ return { real: this.checked(asked, path, name2) };
20235
+ }
20236
+ existing(base, dir) {
20237
+ return !dir.startsWith("/") || fits(base) && this.host.isDirectory(base);
20207
20238
  }
20208
20239
  checked(asked, real, name2 = asked) {
20209
20240
  if (!this.host.allowed(asked, real)) throw openError2(name2, "EACCES");
@@ -20227,7 +20258,7 @@ var init_wasix_linker = __esm({
20227
20258
  const info = dylinkInfo(module);
20228
20259
  if (!info) throw new DlError(`${path}: not a side module (no dylink.0)`);
20229
20260
  const dir = path.slice(0, path.lastIndexOf("/")) || "/";
20230
- const search = [dir, ...ldPath, ...info.runtimePath.map((p) => expandOrigin(p, dir))];
20261
+ const search = [[dir], ldPath, info.runtimePath.map((p) => expandOrigin(p, dir))];
20231
20262
  const needed = [];
20232
20263
  for (const n of info.needed)
20233
20264
  needed.push(this.load(n, this.locate(n, cwd, search), cwd, ldPath).handle);
@@ -21289,6 +21320,13 @@ function linkerHost(host, imports) {
21289
21320
  },
21290
21321
  real: (path) => physicalPath(host.o.fs, path),
21291
21322
  resolve: (path) => realFile(host.o.fs, path),
21323
+ isDirectory: (path) => {
21324
+ try {
21325
+ return host.o.fs.stat(physical(host.o.fs, path, true)).isDirectory === true;
21326
+ } catch {
21327
+ return false;
21328
+ }
21329
+ },
21292
21330
  allowed: (asked, real) => !host.o.checkedLibraries || host.o.kernel.call({ op: "dl-allowed", asked, real }) === true
21293
21331
  };
21294
21332
  }
@@ -23348,16 +23386,16 @@ function streamWrite(ctx) {
23348
23386
  return positive((fd, iov, n, out) => {
23349
23387
  const e = ctx.host.fds.get(fd);
23350
23388
  const nonblock = e.type === "kernel" && e.nonblock;
23351
- let written2;
23389
+ let written3;
23352
23390
  try {
23353
- written2 = ctx.sys.write(fd, ctx.mem.gather(iov, n), { nonblock });
23391
+ written3 = ctx.sys.write(fd, ctx.mem.gather(iov, n), { nonblock });
23354
23392
  } catch (err) {
23355
23393
  if (err.code === "EPIPE" && !sigpipeSpared2(ctx)) {
23356
23394
  throw new WasiExit(KILLED_BY_SIGPIPE4);
23357
23395
  }
23358
23396
  throw err;
23359
23397
  }
23360
- ctx.mem.view().setUint32(out, written2, true);
23398
+ ctx.mem.view().setUint32(out, written3, true);
23361
23399
  });
23362
23400
  }
23363
23401
  function wasiImports(ctx, state) {
@@ -24612,9 +24650,9 @@ function dayOf(num, name2, at) {
24612
24650
  if (day !== void 0) return { month: at.month, day };
24613
24651
  const ofYear = num("j");
24614
24652
  if (ofYear !== void 0) {
24615
- const fits = ofYear <= (leap(at.year) ? 366 : 365);
24653
+ const fits2 = ofYear <= (leap(at.year) ? 366 : 365);
24616
24654
  const december = (leap(at.year) ? LEAP : REGULAR)[11];
24617
- return { month: at.month, day: fits ? ofYear - december : at.day };
24655
+ return { month: at.month, day: fits2 ? ofYear - december : at.day };
24618
24656
  }
24619
24657
  const date = name2 ? weekDay(num, name2, at.year) : void 0;
24620
24658
  return date ? { month: date.getMonth(), day: date.getDate() } : at;