@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.
package/dist/node.js CHANGED
@@ -7563,7 +7563,7 @@ function satisfies(version, range2) {
7563
7563
  }
7564
7564
 
7565
7565
  // src/version.ts
7566
- var KERNEL_VERSION = true ? "1.195.15" : "0.0.0-dev";
7566
+ var KERNEL_VERSION = true ? "1.195.16" : "0.0.0-dev";
7567
7567
  var OS_RELEASE = "6.0.0-slicc";
7568
7568
  function procVersion() {
7569
7569
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -904,11 +904,11 @@ var init_pages = __esm({
904
904
  runs.push({ offset: start2, bytes });
905
905
  i = j;
906
906
  }
907
- const written2 = capturedMath.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
907
+ const written3 = capturedMath.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
908
908
  return {
909
909
  ...this.shrink !== void 0 ? { shrink: this.shrink } : {},
910
910
  runs,
911
- ...this.length > written2 ? { extend: this.length } : {}
911
+ ...this.length > written3 ? { extend: this.length } : {}
912
912
  };
913
913
  }
914
914
  flushed() {
@@ -3305,7 +3305,7 @@ var init_version = __esm({
3305
3305
  "src/version.ts"() {
3306
3306
  "use strict";
3307
3307
  init_captured_globals();
3308
- KERNEL_VERSION = true ? "1.195.15" : "0.0.0-dev";
3308
+ KERNEL_VERSION = true ? "1.195.16" : "0.0.0-dev";
3309
3309
  OS_RELEASE = "6.0.0-slicc";
3310
3310
  }
3311
3311
  });
@@ -12681,16 +12681,16 @@ var init_wasi_host = __esm({
12681
12681
  return this.fds.cwd() === void 0 ? this.fds.resolve(3, `${this.workingDir()}/${raw}`) : this.fds.resolve(3, raw);
12682
12682
  }
12683
12683
  lookup(dirfd, raw, kind) {
12684
- const written2 = this.fds.written(dirfd, raw);
12685
- return this.looked(this.fds.resolve(dirfd, written2, kind), written2, kind);
12684
+ const written3 = this.fds.written(dirfd, raw);
12685
+ return this.looked(this.fds.resolve(dirfd, written3, kind), written3, kind);
12686
12686
  }
12687
12687
  looked(path, raw, kind) {
12688
12688
  const node = this.lookupNode(path, raw, kind);
12689
12689
  return typeof node === "string" ? node : physical(this.o.fs, this.refPath(node), true, kind);
12690
12690
  }
12691
12691
  nodeAt(dirfd, raw) {
12692
- const written2 = this.fds.written(dirfd, raw);
12693
- return this.lookupNode(this.fds.resolve(dirfd, written2), written2);
12692
+ const written3 = this.fds.written(dirfd, raw);
12693
+ return this.lookupNode(this.fds.resolve(dirfd, written3), written3);
12694
12694
  }
12695
12695
  lookupNode(path, raw, kind) {
12696
12696
  const dot = finalOf(raw) === ".";
@@ -16197,11 +16197,20 @@ function codeOf2(e) {
16197
16197
  return code2;
16198
16198
  }
16199
16199
  function openError(name2, code2) {
16200
+ if (code2 === "EISDIR")
16201
+ return new DlError(`${name2}: cannot read file data: Is a directory`, E.ISDIR);
16200
16202
  return new DlError(
16201
16203
  `${name2}: cannot open shared object file: ${OPEN_ERRORS[code2] ?? code2}`,
16202
16204
  wasiErrnoOf(code2)
16203
16205
  );
16204
16206
  }
16207
+ function fits(path) {
16208
+ return new capturedTextEncoder().encode(path).length < PATH_MAX;
16209
+ }
16210
+ function written2(path, asked) {
16211
+ if (!fits(path)) throw capturedObject.assign(new capturedError("ENAMETOOLONG"), { code: "ENAMETOOLONG" });
16212
+ return asked;
16213
+ }
16205
16214
  function align(n, to) {
16206
16215
  return capturedMath.ceil(n / to) * to;
16207
16216
  }
@@ -16216,7 +16225,7 @@ function call(instance, name2) {
16216
16225
  const fn = instance.exports[name2];
16217
16226
  if (typeof fn === "function") fn();
16218
16227
  }
16219
- var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, OPEN_ERRORS, WasixLinker;
16228
+ var TABLE_BASE2, PAGE2, STACK_SIZE, LIBRARY_DIRS, DlError, OPEN_ERRORS, PASSED, PATH_MAX, WasixLinker;
16220
16229
  var init_wasix_linker = __esm({
16221
16230
  "src/process/wasi/wasix-linker.ts"() {
16222
16231
  "use strict";
@@ -16246,6 +16255,8 @@ var init_wasix_linker = __esm({
16246
16255
  EISDIR: "Is a directory",
16247
16256
  EIO: "Input/output error"
16248
16257
  };
16258
+ PASSED = new capturedSet(["ENOENT", "EACCES", "ENOTDIR"]);
16259
+ PATH_MAX = 4096;
16249
16260
  WasixLinker = class {
16250
16261
  table;
16251
16262
  stackPointer;
@@ -16341,7 +16352,7 @@ var init_wasix_linker = __esm({
16341
16352
  }
16342
16353
  }
16343
16354
  open(name2, cwd, ldPath) {
16344
- const path = this.locate(name2, cwd, ldPath);
16355
+ const path = this.locate(name2, cwd, [ldPath]);
16345
16356
  if (this.isMain(path)) return 0;
16346
16357
  this.indices?.lock();
16347
16358
  try {
@@ -16465,32 +16476,52 @@ var init_wasix_linker = __esm({
16465
16476
  if (!m) throw new DlError(`invalid handle ${handle}`);
16466
16477
  return m;
16467
16478
  }
16468
- locate(name2, cwd, ldPath) {
16479
+ locate(name2, cwd, lists) {
16469
16480
  if (name2.includes("/")) {
16470
16481
  const asked = name2.startsWith("/") ? name2 : `${cwd}/${name2}`;
16471
16482
  let real;
16472
16483
  try {
16473
- real = this.host.resolve(asked);
16484
+ real = this.host.resolve(written2(name2, asked));
16474
16485
  } catch (e) {
16475
16486
  throw openError(name2, codeOf2(e));
16476
16487
  }
16477
16488
  return this.checked(asked, real, name2);
16478
16489
  }
16479
- for (const dir of [...ldPath, ...LIBRARY_DIRS]) {
16480
- const path = this.candidate(`${dir.startsWith("/") ? "" : `${cwd}/`}${dir}/${name2}`, name2);
16481
- if (path !== void 0) return path;
16490
+ let last = "ENOENT";
16491
+ for (const list of [...lists, LIBRARY_DIRS]) {
16492
+ for (const dir of list) {
16493
+ const found = this.candidate(dir, name2, cwd);
16494
+ if ("real" in found) return found.real;
16495
+ last = found.code;
16496
+ if (found.ends) break;
16497
+ }
16482
16498
  }
16483
- throw new DlError(`${name2}: not found`);
16499
+ throw openError(name2, last);
16484
16500
  }
16485
- candidate(asked, name2) {
16501
+ candidate(dir, name2, cwd) {
16502
+ const base = dir.replace(/\/+$/, "");
16503
+ const entry = dir === "" ? name2 : `${base}/${name2}`;
16504
+ const asked = dir.startsWith("/") ? entry : `${cwd}/${entry}`;
16486
16505
  let path;
16487
16506
  try {
16488
- path = this.host.resolve(asked);
16507
+ path = this.host.resolve(written2(entry, asked));
16489
16508
  } catch (e) {
16490
- codeOf2(e);
16491
- return void 0;
16509
+ const code2 = codeOf2(e);
16510
+ return { code: code2, ends: !PASSED.has(code2) && this.existing(base || "/", dir) };
16511
+ }
16512
+ if (!this.byPath.has(path)) {
16513
+ try {
16514
+ this.host.open(path);
16515
+ } catch (e) {
16516
+ const code2 = codeOf2(e);
16517
+ if (PASSED.has(code2)) return { code: code2, ends: false };
16518
+ throw openError(code2 === "EISDIR" ? entry : name2, code2);
16519
+ }
16492
16520
  }
16493
- return this.byPath.has(path) || this.host.read(path) ? this.checked(asked, path, name2) : void 0;
16521
+ return { real: this.checked(asked, path, name2) };
16522
+ }
16523
+ existing(base, dir) {
16524
+ return !dir.startsWith("/") || fits(base) && this.host.isDirectory(base);
16494
16525
  }
16495
16526
  checked(asked, real, name2 = asked) {
16496
16527
  if (!this.host.allowed(asked, real)) throw openError(name2, "EACCES");
@@ -16514,7 +16545,7 @@ var init_wasix_linker = __esm({
16514
16545
  const info = dylinkInfo(module);
16515
16546
  if (!info) throw new DlError(`${path}: not a side module (no dylink.0)`);
16516
16547
  const dir = path.slice(0, path.lastIndexOf("/")) || "/";
16517
- const search = [dir, ...ldPath, ...info.runtimePath.map((p) => expandOrigin(p, dir))];
16548
+ const search = [[dir], ldPath, info.runtimePath.map((p) => expandOrigin(p, dir))];
16518
16549
  const needed = [];
16519
16550
  for (const n of info.needed)
16520
16551
  needed.push(this.load(n, this.locate(n, cwd, search), cwd, ldPath).handle);
@@ -17576,6 +17607,13 @@ function linkerHost(host, imports) {
17576
17607
  },
17577
17608
  real: (path) => physicalPath(host.o.fs, path),
17578
17609
  resolve: (path) => realFile(host.o.fs, path),
17610
+ isDirectory: (path) => {
17611
+ try {
17612
+ return host.o.fs.stat(physical(host.o.fs, path, true)).isDirectory === true;
17613
+ } catch {
17614
+ return false;
17615
+ }
17616
+ },
17579
17617
  allowed: (asked, real) => !host.o.checkedLibraries || host.o.kernel.call({ op: "dl-allowed", asked, real }) === true
17580
17618
  };
17581
17619
  }
@@ -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;