@ai-ecoverse/slicc-kernel 1.117.2 → 1.117.4

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.
@@ -2542,7 +2542,7 @@ var KERNEL_VERSION, OS_RELEASE;
2542
2542
  var init_version = __esm({
2543
2543
  "src/version.ts"() {
2544
2544
  "use strict";
2545
- KERNEL_VERSION = true ? "1.117.2" : "0.0.0-dev";
2545
+ KERNEL_VERSION = true ? "1.117.4" : "0.0.0-dev";
2546
2546
  OS_RELEASE = "6.0.0-slicc";
2547
2547
  }
2548
2548
  });
@@ -9156,15 +9156,19 @@ var init_wasi_host = __esm({
9156
9156
  locked: () => this.fds.holdLocks(),
9157
9157
  promote: (fd) => this.fds.promote(fd),
9158
9158
  calls: {
9159
- flock: (fd, kind, wait2) => void this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} }),
9160
- set: (target, kind, start2, len, wait2) => void this.o.kernel.call({
9161
- op: "lk-set",
9162
- ...target,
9163
- kind,
9164
- start: start2,
9165
- len,
9166
- ...wait2 ? { wait: wait2 } : {}
9167
- }),
9159
+ flock: (fd, kind, wait2) => void this.fds.restarting(
9160
+ () => this.o.kernel.call({ op: "flock", fd, kind, ...wait2 ? { wait: wait2 } : {} })
9161
+ ),
9162
+ set: (target, kind, start2, len, wait2) => void this.fds.restarting(
9163
+ () => this.o.kernel.call({
9164
+ op: "lk-set",
9165
+ ...target,
9166
+ kind,
9167
+ start: start2,
9168
+ len,
9169
+ ...wait2 ? { wait: wait2 } : {}
9170
+ })
9171
+ ),
9168
9172
  get: (target, kind, start2, len) => this.o.kernel.call({ op: "lk-get", ...target, kind, start: start2, len })
9169
9173
  }
9170
9174
  }),
@@ -13957,7 +13961,7 @@ function checkOpen(abs, o, existing) {
13957
13961
  function flagsOf(o) {
13958
13962
  const write2 = o.write || o.append || o.truncate;
13959
13963
  const access = write2 ? o.read ? O_RDWR6 : O_WRONLY6 : 0;
13960
- return access | (o.append ? O_APPEND4 : 0);
13964
+ return access | (o.append ? O_APPEND4 : 0) | (o.nonblock ? O_NONBLOCK_OPEN : 0);
13961
13965
  }
13962
13966
  function openRequest2(abs, o) {
13963
13967
  return {
@@ -13973,7 +13977,7 @@ function openRequest2(abs, o) {
13973
13977
  function index2(n, what) {
13974
13978
  if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
13975
13979
  }
13976
- var CHUNK, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND4, BLOCK;
13980
+ var CHUNK, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND4, BLOCK, O_NONBLOCK_OPEN;
13977
13981
  var init_js_io = __esm({
13978
13982
  "src/process/js/js-io.ts"() {
13979
13983
  "use strict";
@@ -13985,6 +13989,7 @@ var init_js_io = __esm({
13985
13989
  O_RDWR6 = 2;
13986
13990
  O_APPEND4 = 1024;
13987
13991
  BLOCK = 4096;
13992
+ O_NONBLOCK_OPEN = 2048;
13988
13993
  }
13989
13994
  });
13990
13995
 
@@ -16061,9 +16066,60 @@ async function vfsStat(kernel, abs, op, tryDev) {
16061
16066
  return devAsync(kernel, devStat(devPath, op === "stat"));
16062
16067
  }
16063
16068
  }
16064
- async function vfsOpen(kernel, abs, options, statOf, infos, handles) {
16069
+ async function fifoOpen(kernel, abs, options, io) {
16070
+ options.signal?.throwIfAborted();
16071
+ const req = { ...openRequest2(abs, { ...options, create: false }), fifo: true };
16072
+ const r = await kernel.blocking(req, options.signal);
16073
+ const fd = r.ok && r.kind === "json" ? r.json : -1;
16074
+ io.infos.set(fd, { kind: "stream" });
16075
+ let open = true;
16076
+ const live = () => {
16077
+ if (!open) throw new JsCallError("EBADF", abs);
16078
+ };
16079
+ const seekless = (position, what) => {
16080
+ live();
16081
+ if (position !== 0) throw new JsCallError("ESPIPE", what);
16082
+ };
16083
+ io.handles.set(fd, () => {
16084
+ open = false;
16085
+ });
16086
+ return {
16087
+ fd,
16088
+ path: abs,
16089
+ async size() {
16090
+ live();
16091
+ return 0;
16092
+ },
16093
+ async read(position, length) {
16094
+ seekless(position, "read");
16095
+ return io.read(fd, length);
16096
+ },
16097
+ async write(position, data) {
16098
+ seekless(position, "write");
16099
+ await io.write(fd, data);
16100
+ return data.length;
16101
+ },
16102
+ async truncate() {
16103
+ live();
16104
+ throw new JsCallError("EINVAL", "truncate");
16105
+ },
16106
+ sync: async () => live(),
16107
+ async close() {
16108
+ if (!open) return;
16109
+ open = false;
16110
+ io.infos.delete(fd);
16111
+ io.handles.delete(fd);
16112
+ await kernel.raw({ op: "fd-close", fd });
16113
+ }
16114
+ };
16115
+ }
16116
+ async function vfsOpen(kernel, abs, options, statOf, io, whole) {
16117
+ const { infos, handles } = io;
16065
16118
  const existing = await statOf(isExclusive(options) ? "lstat" : "stat", abs).catch(absent);
16066
16119
  checkOpen(abs, options, existing);
16120
+ const special = existing?.isSocket || whole && existing?.isFifo;
16121
+ if (special && !isExclusive(options)) throw new JsCallError("ENXIO", abs);
16122
+ if (existing?.isFifo && !isExclusive(options)) return fifoOpen(kernel, abs, options, io);
16067
16123
  const fd = await kernel.json(openRequest2(abs, options));
16068
16124
  try {
16069
16125
  await kernel.call({ op: "fd-vfs-stat", fd });
@@ -16132,11 +16188,11 @@ function createContext(o) {
16132
16188
  return vfsStat(kernel, abs, op, tryDev);
16133
16189
  };
16134
16190
  const devIo = { infos, handles, read: read2, write: writeAll };
16135
- const open = async (path, options = {}) => {
16191
+ const open = async (path, options = {}, whole = false) => {
16136
16192
  const abs = resolve(path);
16137
16193
  if (inDev(abs)) return openDev(kernel, abs, options, devIo);
16138
16194
  try {
16139
- return await vfsOpen(kernel, abs, options, statOf, infos, handles);
16195
+ return await vfsOpen(kernel, abs, options, statOf, devIo, whole);
16140
16196
  } catch (err) {
16141
16197
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
16142
16198
  const devPath = await tryDev(abs);
@@ -16401,12 +16457,11 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
16401
16457
  },
16402
16458
  async writeFile(path, data, options) {
16403
16459
  const mode = options?.mode;
16404
- const file = await open(path, {
16405
- write: true,
16406
- create: true,
16407
- truncate: true,
16408
- ...mode !== void 0 ? { mode } : {}
16409
- });
16460
+ const file = await open(
16461
+ path,
16462
+ { write: true, create: true, truncate: true, ...mode !== void 0 ? { mode } : {} },
16463
+ true
16464
+ );
16410
16465
  try {
16411
16466
  await file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
16412
16467
  } finally {