@ai-ecoverse/slicc-kernel 1.117.3 → 1.117.5

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.3" : "0.0.0-dev";
2545
+ KERNEL_VERSION = true ? "1.117.5" : "0.0.0-dev";
2546
2546
  OS_RELEASE = "6.0.0-slicc";
2547
2547
  }
2548
2548
  });
@@ -13961,7 +13961,7 @@ function checkOpen(abs, o, existing) {
13961
13961
  function flagsOf(o) {
13962
13962
  const write2 = o.write || o.append || o.truncate;
13963
13963
  const access = write2 ? o.read ? O_RDWR6 : O_WRONLY6 : 0;
13964
- return access | (o.append ? O_APPEND4 : 0);
13964
+ return access | (o.append ? O_APPEND4 : 0) | (o.nonblock ? O_NONBLOCK_OPEN : 0);
13965
13965
  }
13966
13966
  function openRequest2(abs, o) {
13967
13967
  return {
@@ -13977,7 +13977,7 @@ function openRequest2(abs, o) {
13977
13977
  function index2(n, what) {
13978
13978
  if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
13979
13979
  }
13980
- 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;
13981
13981
  var init_js_io = __esm({
13982
13982
  "src/process/js/js-io.ts"() {
13983
13983
  "use strict";
@@ -13989,6 +13989,7 @@ var init_js_io = __esm({
13989
13989
  O_RDWR6 = 2;
13990
13990
  O_APPEND4 = 1024;
13991
13991
  BLOCK = 4096;
13992
+ O_NONBLOCK_OPEN = 2048;
13992
13993
  }
13993
13994
  });
13994
13995
 
@@ -16065,9 +16066,60 @@ async function vfsStat(kernel, abs, op, tryDev) {
16065
16066
  return devAsync(kernel, devStat(devPath, op === "stat"));
16066
16067
  }
16067
16068
  }
16068
- 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;
16069
16118
  const existing = await statOf(isExclusive(options) ? "lstat" : "stat", abs).catch(absent);
16070
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);
16071
16123
  const fd = await kernel.json(openRequest2(abs, options));
16072
16124
  try {
16073
16125
  await kernel.call({ op: "fd-vfs-stat", fd });
@@ -16136,11 +16188,11 @@ function createContext(o) {
16136
16188
  return vfsStat(kernel, abs, op, tryDev);
16137
16189
  };
16138
16190
  const devIo = { infos, handles, read: read2, write: writeAll };
16139
- const open = async (path, options = {}) => {
16191
+ const open = async (path, options = {}, whole = false) => {
16140
16192
  const abs = resolve(path);
16141
16193
  if (inDev(abs)) return openDev(kernel, abs, options, devIo);
16142
16194
  try {
16143
- return await vfsOpen(kernel, abs, options, statOf, infos, handles);
16195
+ return await vfsOpen(kernel, abs, options, statOf, devIo, whole);
16144
16196
  } catch (err) {
16145
16197
  if (!(err instanceof JsCallError) || err.code !== "ENOENT") throw err;
16146
16198
  const devPath = await tryDev(abs);
@@ -16405,12 +16457,11 @@ function pathOps(kernel, resolve, statOf, open, tryDev) {
16405
16457
  },
16406
16458
  async writeFile(path, data, options) {
16407
16459
  const mode = options?.mode;
16408
- const file = await open(path, {
16409
- write: true,
16410
- create: true,
16411
- truncate: true,
16412
- ...mode !== void 0 ? { mode } : {}
16413
- });
16460
+ const file = await open(
16461
+ path,
16462
+ { write: true, create: true, truncate: true, ...mode !== void 0 ? { mode } : {} },
16463
+ true
16464
+ );
16414
16465
  try {
16415
16466
  await file.write(0, typeof data === "string" ? encoder4.encode(data) : data);
16416
16467
  } finally {