@ai-ecoverse/slicc-kernel 1.144.0 → 1.144.1

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.
@@ -3735,23 +3735,21 @@ var init_wasi_fds = __esm({
3735
3735
  const flags = want === 6 ? O_RDWR2 : want === 2 ? O_WRONLY2 : 0;
3736
3736
  return openDevice2.call(this.kernel.sys, flags);
3737
3737
  }
3738
- open(path, oflags, rights, fdflags, mode) {
3738
+ open(path, oflags, rights, fdflags, mode, nofollow = false) {
3739
3739
  this.made = void 0;
3740
3740
  this.created = false;
3741
+ this.nofollow = nofollow;
3741
3742
  const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
3742
- if (exclusive && namedDevice(path)) throw new WasiError("EEXIST");
3743
- const device2 = deviceOf(path);
3744
- if (device2) return this.install({ type: "device", device: device2 });
3745
- const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
3746
- if (kernelDevice !== void 0) return kernelDevice;
3747
- const alias = stdioAlias(path);
3748
- if (alias !== void 0) return this.reopen(alias);
3743
+ const special = this.openSpecial(path, oflags, rights, fdflags, exclusive);
3744
+ if (special !== void 0) return special;
3749
3745
  const outside = this.escaped(path, oflags, rights);
3750
3746
  if (outside !== void 0) return this.open(outside, oflags, rights, fdflags, mode);
3751
3747
  if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
3752
3748
  return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
3753
3749
  }
3754
- if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
3750
+ if ((exclusive || nofollow) && this.isLink(path)) {
3751
+ throw new WasiError(exclusive ? "EEXIST" : "ELOOP");
3752
+ }
3755
3753
  const s = this.statOrMissing(path);
3756
3754
  if (exclusive && s) throw new WasiError("EEXIST");
3757
3755
  if (s?.escape !== void 0) {
@@ -3770,6 +3768,18 @@ var init_wasi_fds = __esm({
3770
3768
  refuseWrite(s, oflags, rights);
3771
3769
  return this.regular(path, s, oflags, rights, fdflags, mode);
3772
3770
  }
3771
+ nofollow = false;
3772
+ openSpecial(path, oflags, rights, fdflags, exclusive) {
3773
+ if (exclusive && namedDevice(path)) throw new WasiError("EEXIST");
3774
+ const device2 = deviceOf(path);
3775
+ if (device2) return this.install({ type: "device", device: device2 });
3776
+ const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
3777
+ if (kernelDevice !== void 0) return kernelDevice;
3778
+ const alias = stdioAlias(path);
3779
+ if (alias === void 0) return void 0;
3780
+ if (this.nofollow) throw new WasiError("ELOOP");
3781
+ return this.reopen(alias);
3782
+ }
3773
3783
  escaped(path, oflags, rights) {
3774
3784
  const outside = this.fs.escape?.(path);
3775
3785
  if (outside === void 0) return void 0;
@@ -3839,7 +3849,8 @@ var init_wasi_fds = __esm({
3839
3849
  const ranged = st.ranged ? st.size : void 0;
3840
3850
  const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
3841
3851
  const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0, {
3842
- gen: st.gen
3852
+ gen: st.gen,
3853
+ ...this.nofollow ? { nofollow: true } : {}
3843
3854
  });
3844
3855
  const io = handle !== void 0 && this.fs.pinned ? this.fs.pinned(handle) : this.fs;
3845
3856
  const view = this.fs.changes;
@@ -5614,7 +5625,7 @@ var init_wasi_host = __esm({
5614
5625
  if (alias && !alias.stdio) this.openFd(alias.fd);
5615
5626
  const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
5616
5627
  if (deviceOf(path)) this.interrupted?.();
5617
- mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
5628
+ mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags, void 0, !follow3), true);
5618
5629
  if (fds.created) this.created(path, 438);
5619
5630
  } catch (err) {
5620
5631
  if (err.code !== "ENOENT") throw err;
@@ -5622,7 +5633,7 @@ var init_wasi_host = __esm({
5622
5633
  const joined2 = raw.startsWith("/") ? raw : `${fds.dir(dirfd).path}/${raw}`;
5623
5634
  const resolved2 = this.resolveForDev(joined2, follow3);
5624
5635
  if (!resolved2) throw err;
5625
- mem.view().setUint32(out, fds.open(resolved2, oflags, rights, fdflags), true);
5636
+ mem.view().setUint32(out, fds.open(resolved2, oflags, rights, fdflags, void 0, !follow3), true);
5626
5637
  }
5627
5638
  },
5628
5639
  path_filestat_get: (dirfd, lookup2, p, l, out) => {
@@ -6498,13 +6509,18 @@ function importsContext({
6498
6509
  open(path, o = {}) {
6499
6510
  const abs = host.fds.resolve(3, path);
6500
6511
  const fresh = o.create === true && o.exclusive === true && owners && fs.create !== void 0;
6501
- if (!fresh && o.nofollow && fs.exists(abs) && fs.lstat(abs).isSymbolicLink)
6502
- throw new WasiError("ELOOP");
6503
6512
  const existed = !fresh && fs.exists(abs);
6504
6513
  const oflags = (o.create ? OFLAGS.CREAT : 0) | (o.exclusive ? OFLAGS.EXCL : 0) | (o.truncate ? OFLAGS.TRUNC : 0) | (o.directory ? OFLAGS.DIRECTORY : 0);
6505
6514
  const rights = (o.write ? RIGHTS.FD_WRITE : 0n) | (o.read || !o.write ? RIGHTS.FD_READ : 0n);
6506
6515
  const flags = o.append ? FDFLAGS.APPEND : 0;
6507
- const fd = host.fds.open(abs, oflags, rights, flags, fresh ? o.mode : void 0);
6516
+ const fd = host.fds.open(
6517
+ abs,
6518
+ oflags,
6519
+ rights,
6520
+ flags,
6521
+ fresh ? o.mode : void 0,
6522
+ o.nofollow === true
6523
+ );
6508
6524
  if (o.mode !== void 0 && !existed && !fresh) fs.chmod(abs, o.mode);
6509
6525
  return fd;
6510
6526
  },
@@ -6784,7 +6800,7 @@ var KERNEL_VERSION, OS_RELEASE;
6784
6800
  var init_version = __esm({
6785
6801
  "src/version.ts"() {
6786
6802
  "use strict";
6787
- KERNEL_VERSION = true ? "1.144.0" : "0.0.0-dev";
6803
+ KERNEL_VERSION = true ? "1.144.1" : "0.0.0-dev";
6788
6804
  OS_RELEASE = "6.0.0-slicc";
6789
6805
  }
6790
6806
  });
@@ -8212,7 +8228,8 @@ function createSyncFsSabBridge(transport, opts = {}) {
8212
8228
  const mode = (held2 ? 1 : 0) | (open ? 2 : 0);
8213
8229
  if (mode === 3) {
8214
8230
  const at = seen.gen !== void 0 ? { gen: seen.gen } : {};
8215
- return json2({ op: "hold", path, mode: mode | want, ...at }, path);
8231
+ const link = seen.nofollow ? { nofollow: true } : {};
8232
+ return json2({ op: "hold", path, mode: mode | want, ...at, ...link }, path);
8216
8233
  }
8217
8234
  run({ op: "hold", path, mode, ...handle !== void 0 ? { handle } : {} }, path);
8218
8235
  return void 0;