@ai-ecoverse/slicc-kernel 1.17.3 → 1.17.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.
package/README.md CHANGED
@@ -201,7 +201,7 @@ Directories are renamed with `FileSystemHandle.move()` where available, else by
201
201
  - `df` reports each mount from its driver's `statfs`;
202
202
  - each mount has its own device number;
203
203
  - without `chmod` support, `chmod` succeeds and changes nothing;
204
- - a file over `maxFile` is `EFBIG`, and `options.maxfile` (`"2G"`, or `"0"` for none) changes that limit for one mount;
204
+ - a write or truncate that would make a file larger than `maxFile` fails with `EFBIG` at once and changes nothing, and `options.maxfile` (`"2G"`, or `"0"` for none) changes that limit for one mount;
205
205
  - `options.ro` makes any mount read-only: writes fail with `EROFS`;
206
206
  - a driver that crashes or doesn't answer within 30 s makes its mount's calls fail with `EIO`, and the mount is listed as `failed`.
207
207
 
@@ -3648,7 +3648,8 @@ function statOf(attr, path, mount) {
3648
3648
  ctime: mtime,
3649
3649
  ino: attr.ino ?? inodeOf(path),
3650
3650
  dev: mount.dev,
3651
- ...readonly(mount) ? { readonly: true } : {}
3651
+ ...readonly(mount) ? { readonly: true } : {},
3652
+ ...mount.maxFile > 0 ? { maxFile: mount.maxFile } : {}
3652
3653
  };
3653
3654
  }
3654
3655
  function concat4(chunks, total) {
@@ -4134,7 +4135,8 @@ function statJson(s) {
4134
4135
  ctimeMs: s.ctime.getTime(),
4135
4136
  ino: s.ino,
4136
4137
  ...s.dev !== void 0 ? { dev: s.dev } : {},
4137
- ...s.readonly ? { readonly: true } : {}
4138
+ ...s.readonly ? { readonly: true } : {},
4139
+ ...s.maxFile ? { maxFile: s.maxFile } : {}
4138
4140
  };
4139
4141
  }
4140
4142
  async function readdirStat(fs, dir) {
@@ -5599,7 +5601,29 @@ var VfsNode = class {
5599
5601
  const n = Math.max(0, Math.min(max, this.length - at));
5600
5602
  return bytes.slice(at, at + n);
5601
5603
  }
5604
+ cap;
5605
+ limit() {
5606
+ if (this.cap !== void 0) return this.cap;
5607
+ const stat = this.fs.stat?.bind(this.fs);
5608
+ if (!stat || this.orphaned) return Promise.resolve(void 0);
5609
+ const parent = this.path.slice(0, this.path.lastIndexOf("/")) || "/";
5610
+ this.cap ??= stat(this.path).catch(() => stat(parent)).then(
5611
+ (st) => st.maxFile,
5612
+ () => void 0
5613
+ );
5614
+ return this.cap;
5615
+ }
5616
+ async fits(end) {
5617
+ const max = await this.limit();
5618
+ if (max !== void 0 && end > max) throw new KernelError("EFBIG");
5619
+ }
5620
+ renamedTo(path) {
5621
+ this.path = path;
5622
+ this.cap = void 0;
5623
+ }
5602
5624
  async pwrite(bytes, at) {
5625
+ if (bytes.length === 0) return 0;
5626
+ await this.fits(at + bytes.length);
5603
5627
  await this.load();
5604
5628
  const buf = this.ensure(at + bytes.length);
5605
5629
  if (at > this.length) buf.fill(0, this.length, at);
@@ -5609,6 +5633,7 @@ var VfsNode = class {
5609
5633
  return bytes.length;
5610
5634
  }
5611
5635
  async truncate(size) {
5636
+ await this.fits(size);
5612
5637
  await this.load();
5613
5638
  const buf = this.ensure(size);
5614
5639
  if (size > this.length) buf.fill(0, this.length, size);
@@ -5685,7 +5710,7 @@ var VfsNodes = class {
5685
5710
  }
5686
5711
  async unlinking(path) {
5687
5712
  const node = this.byPath.get(path);
5688
- if (node) await node.serial(() => node.load());
5713
+ if (node) await node.serial(async () => void await Promise.all([node.load(), node.limit()]));
5689
5714
  }
5690
5715
  revoke(prefix) {
5691
5716
  for (const [path, node] of this.byPath) {
@@ -5712,7 +5737,7 @@ var VfsNodes = class {
5712
5737
  }
5713
5738
  for (const node of moved2) {
5714
5739
  this.byPath.delete(node.path);
5715
- node.path = to + node.path.slice(from.length);
5740
+ node.renamedTo(to + node.path.slice(from.length));
5716
5741
  this.byPath.set(node.path, node);
5717
5742
  }
5718
5743
  }
@@ -6415,6 +6440,7 @@ var WasmProcess = class {
6415
6440
  if (this.exited) return;
6416
6441
  this.exited = true;
6417
6442
  this.clearAlarm();
6443
+ this.interrupt.abort();
6418
6444
  this.options.locks?.release(this.pid);
6419
6445
  this.asyncOps.close();
6420
6446
  for (const pid of this.children.pids()) this.options.onReap?.(pid);
@@ -8241,6 +8267,10 @@ var Launcher = class {
8241
8267
  for (const nodes of this.openFiles) nodes.revoke(at);
8242
8268
  for (const holds of this.held) holds.revoke(at);
8243
8269
  }
8270
+ unmountAll() {
8271
+ const targets = this.mounts.list().map((m) => m.target);
8272
+ for (const target of targets.sort((a, b) => b.length - a.length)) this.umount(target, true);
8273
+ }
8244
8274
  async permit(req) {
8245
8275
  const policy = this.processMounts;
8246
8276
  const allowed = typeof policy === "function" ? await policy(req) : policy;