@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.
@@ -4906,11 +4906,22 @@ var init_wasi_host = __esm({
4906
4906
  }
4907
4907
  if (this.synthetic(path)) return ROOT_IDS;
4908
4908
  if (kernelDev(path)) return devSync(dev, devStat(path, follow3));
4909
- return this.orDev(
4910
- path,
4911
- follow3,
4912
- () => follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path)
4913
- );
4909
+ return this.viaDev(path, follow3, () => this.statOf(path, follow3), pathOwned);
4910
+ };
4911
+ const pathMode = (path, follow3) => {
4912
+ const alias = this.fdAlias(path);
4913
+ if (alias && !follow3) {
4914
+ this.fdTarget(alias);
4915
+ return S_IFLNK | 511;
4916
+ }
4917
+ if (alias) {
4918
+ this.openFd(alias.fd);
4919
+ return fdMode(alias.fd);
4920
+ }
4921
+ if (this.synthetic(path) && deviceOf(path) === void 0) return SEALED_MODE;
4922
+ if (kernelDev(path)) return devSync(dev, devStat(path, follow3)).mode ?? DEVICE_MODE;
4923
+ const fileMode = (st) => (st.isFifo ? S_IFIFO : 0) | modeOf2(st);
4924
+ return this.viaDev(path, follow3, () => fileMode(this.statOf(path, follow3)), pathMode);
4914
4925
  };
4915
4926
  return wrap({
4916
4927
  fd_chown: (fd, uid, gid) => {
@@ -4974,32 +4985,8 @@ var init_wasi_host = __esm({
4974
4985
  fd_mode: (fd, out) => void mem.view().setUint32(out, fdMode(fd), true),
4975
4986
  path_mode: (dirfd, p, l, flags, out) => {
4976
4987
  const path = at(dirfd, p, l);
4977
- const alias = this.fdAlias(path);
4978
- if (alias && flags & AT_SYMLINK_NOFOLLOW) {
4979
- this.fdTarget(alias);
4980
- return void mem.view().setUint32(out, S_IFLNK | 511, true);
4981
- }
4982
- if (alias) {
4983
- this.openFd(alias.fd);
4984
- return void mem.view().setUint32(out, fdMode(alias.fd), true);
4985
- }
4986
- if (this.synthetic(path) && deviceOf(path) === void 0)
4987
- return void mem.view().setUint32(out, SEALED_MODE, true);
4988
- if (kernelDev(path)) {
4989
- const node = devSync(dev, devStat(path, (flags & AT_SYMLINK_NOFOLLOW) === 0));
4990
- return void mem.view().setUint32(out, node.mode ?? DEVICE_MODE, true);
4991
- }
4992
- const follow3 = (flags & AT_SYMLINK_NOFOLLOW) === 0;
4993
- let st;
4994
- try {
4995
- st = follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
4996
- } catch (err) {
4997
- const device2 = this.orDev(path, follow3, () => {
4998
- throw err;
4999
- });
5000
- return void mem.view().setUint32(out, device2.mode ?? DEVICE_MODE, true);
5001
- }
5002
- mem.view().setUint32(out, (st.isFifo ? S_IFIFO : 0) | modeOf2(st), true);
4988
+ const mode = pathMode(path, (flags & AT_SYMLINK_NOFOLLOW) === 0);
4989
+ mem.view().setUint32(out, mode, true);
5003
4990
  }
5004
4991
  });
5005
4992
  }
@@ -5713,14 +5700,16 @@ var init_wasi_host = __esm({
5713
5700
  const real = physicalPath(this.o.fs, path);
5714
5701
  return real !== path && kernelDev(real) ? real : void 0;
5715
5702
  }
5716
- orDev(path, follow3, stat) {
5703
+ statOf(path, follow3) {
5704
+ return follow3 ? this.o.fs.stat(path) : this.o.fs.lstat(path);
5705
+ }
5706
+ viaDev(path, follow3, stat, device2) {
5717
5707
  try {
5718
5708
  return stat();
5719
5709
  } catch (err) {
5720
- const device2 = err.code === "ENOENT" && this.linkedDev(path, follow3);
5721
- if (!device2) throw err;
5722
- const json2 = (req) => this.o.kernel.call(req);
5723
- return devSync({ json: json2 }, devStat(device2, true));
5710
+ const linked = err.code === "ENOENT" && this.linkedDev(path, follow3);
5711
+ if (!linked) throw err;
5712
+ return device2(linked, true);
5724
5713
  }
5725
5714
  }
5726
5715
  devChar(path, follow3) {
@@ -5831,6 +5820,8 @@ var init_wasi_host = __esm({
5831
5820
  } catch (err) {
5832
5821
  if (err.code !== "ENOENT") throw err;
5833
5822
  const device2 = kernelDev(path) ? path : this.linkedDev(path, follow3);
5823
+ const alias2 = device2 && device2 !== path ? this.fdAlias(device2) : void 0;
5824
+ if (device2 && alias2) return this.aliasFilestat(device2, alias2, lookup2);
5834
5825
  if (device2 && this.devChar(device2, true)) {
5835
5826
  return this.local({
5836
5827
  filetype: FILETYPE.CHARACTER_DEVICE,
@@ -6401,7 +6392,7 @@ var KERNEL_VERSION, OS_RELEASE;
6401
6392
  var init_version = __esm({
6402
6393
  "src/version.ts"() {
6403
6394
  "use strict";
6404
- KERNEL_VERSION = true ? "1.125.8" : "0.0.0-dev";
6395
+ KERNEL_VERSION = true ? "1.125.9" : "0.0.0-dev";
6405
6396
  OS_RELEASE = "6.0.0-slicc";
6406
6397
  }
6407
6398
  });
@@ -13297,7 +13288,7 @@ var init_kernel_streams = __esm({
13297
13288
  }),
13298
13289
  write: (s, buffer, offset, length) => {
13299
13290
  try {
13300
- const bytes = buffer.slice(offset, offset + length);
13291
+ const bytes = new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length).slice();
13301
13292
  return this.restarting(() => this.sys.write(kfd, bytes, nonblocking(s)));
13302
13293
  } catch (e) {
13303
13294
  if (e instanceof SyscallError && e.code === "EPIPE" && !this.options.sigpipe?.()) {
@@ -14172,6 +14163,10 @@ var init_realm_user = __esm({
14172
14163
  });
14173
14164
 
14174
14165
  // src/process/process-runtime.ts
14166
+ function ownBytes(bytes) {
14167
+ if (bytes.constructor === Uint8Array) return bytes;
14168
+ return new Uint8Array(bytes.buffer, bytes.byteOffset, bytes.byteLength).slice();
14169
+ }
14175
14170
  function kernelSys(transport) {
14176
14171
  const call2 = (req, label) => {
14177
14172
  const r = transport.call(req, Number.POSITIVE_INFINITY, label);
@@ -14192,7 +14187,7 @@ function kernelSys(transport) {
14192
14187
  const req = {
14193
14188
  op: "fd-write",
14194
14189
  fd,
14195
- body: bytes,
14190
+ body: ownBytes(bytes),
14196
14191
  ...opts?.nonblock ? { nonblock: true } : {}
14197
14192
  };
14198
14193
  const n = json2(call2(req, `fd-write ${fd}`));
@@ -14241,7 +14236,7 @@ function kernelSys(transport) {
14241
14236
  },
14242
14237
  pwrite(fd, bytes, at) {
14243
14238
  return json2(
14244
- call2({ op: "fd-pwrite", fd, offset: at, body: bytes }, `fd-pwrite ${fd}`)
14239
+ call2({ op: "fd-pwrite", fd, offset: at, body: ownBytes(bytes) }, `fd-pwrite ${fd}`)
14245
14240
  );
14246
14241
  },
14247
14242
  isatty(fd) {