@ai-ecoverse/slicc-kernel 1.17.3 → 1.17.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.
package/dist/node.js CHANGED
@@ -2107,7 +2107,8 @@ function statOf(attr, path, mount) {
2107
2107
  ctime: mtime,
2108
2108
  ino: attr.ino ?? inodeOf(path),
2109
2109
  dev: mount.dev,
2110
- ...readonly(mount) ? { readonly: true } : {}
2110
+ ...readonly(mount) ? { readonly: true } : {},
2111
+ ...mount.maxFile > 0 ? { maxFile: mount.maxFile } : {}
2111
2112
  };
2112
2113
  }
2113
2114
  function concat2(chunks2, total) {
@@ -2593,7 +2594,8 @@ function statJson(s) {
2593
2594
  ctimeMs: s.ctime.getTime(),
2594
2595
  ino: s.ino,
2595
2596
  ...s.dev !== void 0 ? { dev: s.dev } : {},
2596
- ...s.readonly ? { readonly: true } : {}
2597
+ ...s.readonly ? { readonly: true } : {},
2598
+ ...s.maxFile ? { maxFile: s.maxFile } : {}
2597
2599
  };
2598
2600
  }
2599
2601
  async function readdirStat(fs, dir) {
@@ -5351,7 +5353,29 @@ var VfsNode = class {
5351
5353
  const n = Math.max(0, Math.min(max, this.length - at));
5352
5354
  return bytes.slice(at, at + n);
5353
5355
  }
5356
+ cap;
5357
+ limit() {
5358
+ if (this.cap !== void 0) return this.cap;
5359
+ const stat = this.fs.stat?.bind(this.fs);
5360
+ if (!stat || this.orphaned) return Promise.resolve(void 0);
5361
+ const parent = this.path.slice(0, this.path.lastIndexOf("/")) || "/";
5362
+ this.cap ??= stat(this.path).catch(() => stat(parent)).then(
5363
+ (st) => st.maxFile,
5364
+ () => void 0
5365
+ );
5366
+ return this.cap;
5367
+ }
5368
+ async fits(end) {
5369
+ const max = await this.limit();
5370
+ if (max !== void 0 && end > max) throw new KernelError("EFBIG");
5371
+ }
5372
+ renamedTo(path) {
5373
+ this.path = path;
5374
+ this.cap = void 0;
5375
+ }
5354
5376
  async pwrite(bytes, at) {
5377
+ if (bytes.length === 0) return 0;
5378
+ await this.fits(at + bytes.length);
5355
5379
  await this.load();
5356
5380
  const buf = this.ensure(at + bytes.length);
5357
5381
  if (at > this.length) buf.fill(0, this.length, at);
@@ -5361,6 +5385,7 @@ var VfsNode = class {
5361
5385
  return bytes.length;
5362
5386
  }
5363
5387
  async truncate(size) {
5388
+ await this.fits(size);
5364
5389
  await this.load();
5365
5390
  const buf = this.ensure(size);
5366
5391
  if (size > this.length) buf.fill(0, this.length, size);
@@ -5437,7 +5462,7 @@ var VfsNodes = class {
5437
5462
  }
5438
5463
  async unlinking(path) {
5439
5464
  const node = this.byPath.get(path);
5440
- if (node) await node.serial(() => node.load());
5465
+ if (node) await node.serial(async () => void await Promise.all([node.load(), node.limit()]));
5441
5466
  }
5442
5467
  revoke(prefix) {
5443
5468
  for (const [path, node] of this.byPath) {
@@ -5464,7 +5489,7 @@ var VfsNodes = class {
5464
5489
  }
5465
5490
  for (const node of moved2) {
5466
5491
  this.byPath.delete(node.path);
5467
- node.path = to + node.path.slice(from.length);
5492
+ node.renamedTo(to + node.path.slice(from.length));
5468
5493
  this.byPath.set(node.path, node);
5469
5494
  }
5470
5495
  }