@ai-ecoverse/slicc-kernel 1.68.0 → 1.69.0

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.
package/dist/node.js CHANGED
@@ -838,6 +838,16 @@ function written(device, bytes) {
838
838
  if (device === "full" && bytes.length > 0) throw new KernelError("ENOSPC");
839
839
  return bytes.length;
840
840
  }
841
+ var DEVICE_PATHS = /* @__PURE__ */ new Map([
842
+ ["/dev/null", "null"],
843
+ ["/dev/zero", "zero"],
844
+ ["/dev/full", "full"],
845
+ ["/dev/urandom", "urandom"],
846
+ ["/dev/random", "urandom"]
847
+ ]);
848
+ function deviceAt(path) {
849
+ return DEVICE_PATHS.get(path);
850
+ }
841
851
  function deviceFile(device, access2) {
842
852
  const read = async (max) => {
843
853
  if (device === "null") return new Uint8Array(0);
@@ -11476,6 +11486,8 @@ var WasmProcess = class {
11476
11486
  }
11477
11487
  async openVfs(req) {
11478
11488
  if (inProc(req.path)) return this.openProc(req, req.path);
11489
+ const device = req.orphan ? void 0 : deviceAt(req.path);
11490
+ if (device) return this.openDevice(req, device);
11479
11491
  const alias = req.orphan ? void 0 : await procAlias(this.options.fs, req.path, !req.exclusive);
11480
11492
  if (typeof alias === "object")
11481
11493
  throw Object.assign(new Error(alias.refused), { code: alias.refused });
@@ -11513,6 +11525,14 @@ var WasmProcess = class {
11513
11525
  }
11514
11526
  return fd;
11515
11527
  }
11528
+ openDevice(req, device) {
11529
+ if (req.exclusive) throw Object.assign(new Error(req.path), { code: "EEXIST" });
11530
+ const access2 = req.flags & WRITE_ACCESS;
11531
+ return this.fds.install(
11532
+ deviceFile(device, access2 === 0 ? "read" : access2 === 1 ? "write" : void 0),
11533
+ 3
11534
+ );
11535
+ }
11516
11536
  async identified(stat, known) {
11517
11537
  const first = await stat();
11518
11538
  if (first.orphan) return first;