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