@ai-ecoverse/slicc-kernel 1.125.8 → 1.125.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.
@@ -2655,7 +2655,7 @@ var KERNEL_VERSION, OS_RELEASE;
2655
2655
  var init_version = __esm({
2656
2656
  "src/version.ts"() {
2657
2657
  "use strict";
2658
- KERNEL_VERSION = true ? "1.125.8" : "0.0.0-dev";
2658
+ KERNEL_VERSION = true ? "1.125.9" : "0.0.0-dev";
2659
2659
  OS_RELEASE = "6.0.0-slicc";
2660
2660
  }
2661
2661
  });
@@ -4458,7 +4458,7 @@ var init_kernel_streams = __esm({
4458
4458
  }),
4459
4459
  write: (s, buffer, offset, length) => {
4460
4460
  try {
4461
- const bytes = buffer.slice(offset, offset + length);
4461
+ const bytes = new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length).slice();
4462
4462
  return this.restarting(() => this.sys.write(kfd, bytes, nonblocking(s)));
4463
4463
  } catch (e) {
4464
4464
  if (e instanceof SyscallError && e.code === "EPIPE" && !this.options.sigpipe?.()) {
@@ -5764,6 +5764,10 @@ var init_realm_user = __esm({
5764
5764
  });
5765
5765
 
5766
5766
  // src/process/process-runtime.ts
5767
+ function ownBytes(bytes) {
5768
+ if (bytes.constructor === Uint8Array) return bytes;
5769
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength).slice();
5770
+ }
5767
5771
  function kernelSys(transport) {
5768
5772
  const call2 = (req, label) => {
5769
5773
  const r = transport.call(req, Number.POSITIVE_INFINITY, label);
@@ -5784,7 +5788,7 @@ function kernelSys(transport) {
5784
5788
  const req = {
5785
5789
  op: "fd-write",
5786
5790
  fd,
5787
- body: bytes,
5791
+ body: ownBytes(bytes),
5788
5792
  ...opts?.nonblock ? { nonblock: true } : {}
5789
5793
  };
5790
5794
  const n = json2(call2(req, `fd-write ${fd}`));
@@ -5833,7 +5837,7 @@ function kernelSys(transport) {
5833
5837
  },
5834
5838
  pwrite(fd, bytes, at) {
5835
5839
  return json2(
5836
- call2({ op: "fd-pwrite", fd, offset: at, body: bytes }, `fd-pwrite ${fd}`)
5840
+ call2({ op: "fd-pwrite", fd, offset: at, body: ownBytes(bytes) }, `fd-pwrite ${fd}`)
5837
5841
  );
5838
5842
  },
5839
5843
  isatty(fd) {
@@ -10333,11 +10337,22 @@ var init_wasi_host = __esm({
10333
10337
  }
10334
10338
  if (this.synthetic(path)) return ROOT_IDS;
10335
10339
  if (kernelDev(path)) return devSync(dev, devStat(path, follow3));
10336
- return this.orDev(
10337
- path,
10338
- follow3,
10339
- () => follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path)
10340
- );
10340
+ return this.viaDev(path, follow3, () => this.statOf(path, follow3), pathOwned);
10341
+ };
10342
+ const pathMode = (path, follow3) => {
10343
+ const alias = this.fdAlias(path);
10344
+ if (alias && !follow3) {
10345
+ this.fdTarget(alias);
10346
+ return S_IFLNK2 | 511;
10347
+ }
10348
+ if (alias) {
10349
+ this.openFd(alias.fd);
10350
+ return fdMode(alias.fd);
10351
+ }
10352
+ if (this.synthetic(path) && deviceOf(path) === void 0) return SEALED_MODE;
10353
+ if (kernelDev(path)) return devSync(dev, devStat(path, follow3)).mode ?? DEVICE_MODE;
10354
+ const fileMode = (st) => (st.isFifo ? S_IFIFO2 : 0) | modeOf2(st);
10355
+ return this.viaDev(path, follow3, () => fileMode(this.statOf(path, follow3)), pathMode);
10341
10356
  };
10342
10357
  return wrap({
10343
10358
  fd_chown: (fd, uid, gid) => {
@@ -10401,32 +10416,8 @@ var init_wasi_host = __esm({
10401
10416
  fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
10402
10417
  path_mode: (dirfd, p, l, flags, out) => {
10403
10418
  const path = at(dirfd, p, l);
10404
- const alias = this.fdAlias(path);
10405
- if (alias && flags & AT_SYMLINK_NOFOLLOW2) {
10406
- this.fdTarget(alias);
10407
- return void mem.view().setUint32(out, S_IFLNK2 | 511, true);
10408
- }
10409
- if (alias) {
10410
- this.openFd(alias.fd);
10411
- return void mem.view().setUint32(out, fdMode(alias.fd), true);
10412
- }
10413
- if (this.synthetic(path) && deviceOf(path) === void 0)
10414
- return void mem.view().setUint32(out, SEALED_MODE, true);
10415
- if (kernelDev(path)) {
10416
- const node = devSync(dev, devStat(path, (flags & AT_SYMLINK_NOFOLLOW2) === 0));
10417
- return void mem.view().setUint32(out, node.mode ?? DEVICE_MODE, true);
10418
- }
10419
- const follow3 = (flags & AT_SYMLINK_NOFOLLOW2) === 0;
10420
- let st;
10421
- try {
10422
- st = follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
10423
- } catch (err) {
10424
- const device2 = this.orDev(path, follow3, () => {
10425
- throw err;
10426
- });
10427
- return void mem.view().setUint32(out, device2.mode ?? DEVICE_MODE, true);
10428
- }
10429
- mem.view().setUint32(out, (st.isFifo ? S_IFIFO2 : 0) | modeOf2(st), true);
10419
+ const mode = pathMode(path, (flags & AT_SYMLINK_NOFOLLOW2) === 0);
10420
+ mem.view().setUint32(out, mode, true);
10430
10421
  }
10431
10422
  });
10432
10423
  }
@@ -11140,14 +11131,16 @@ var init_wasi_host = __esm({
11140
11131
  const real = physicalPath(this.o.fs, path);
11141
11132
  return real !== path && kernelDev(real) ? real : void 0;
11142
11133
  }
11143
- orDev(path, follow3, stat) {
11134
+ statOf(path, follow3) {
11135
+ return follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
11136
+ }
11137
+ viaDev(path, follow3, stat, device2) {
11144
11138
  try {
11145
11139
  return stat();
11146
11140
  } catch (err) {
11147
- const device2 = err.code === "ENOENT" && this.linkedDev(path, follow3);
11148
- if (!device2) throw err;
11149
- const json2 = (req) => this.o.kernel.call(req);
11150
- return devSync({ json: json2 }, devStat(device2, true));
11141
+ const linked = err.code === "ENOENT" && this.linkedDev(path, follow3);
11142
+ if (!linked) throw err;
11143
+ return device2(linked, true);
11151
11144
  }
11152
11145
  }
11153
11146
  devChar(path, follow3) {
@@ -11258,6 +11251,8 @@ var init_wasi_host = __esm({
11258
11251
  } catch (err) {
11259
11252
  if (err.code !== "ENOENT") throw err;
11260
11253
  const device2 = kernelDev(path) ? path : this.linkedDev(path, follow3);
11254
+ const alias2 = device2 && device2 !== path ? this.fdAlias(device2) : void 0;
11255
+ if (device2 && alias2) return this.aliasFilestat(device2, alias2, lookup2);
11261
11256
  if (device2 && this.devChar(device2, true)) {
11262
11257
  return this.local({
11263
11258
  filetype: FILETYPE.CHARACTER_DEVICE,