@ai-ecoverse/slicc-kernel 1.167.0 → 1.167.2

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
@@ -3684,7 +3684,7 @@ function satisfies(version, range2) {
3684
3684
  }
3685
3685
 
3686
3686
  // src/version.ts
3687
- var KERNEL_VERSION = true ? "1.167.0" : "0.0.0-dev";
3687
+ var KERNEL_VERSION = true ? "1.167.2" : "0.0.0-dev";
3688
3688
  var OS_RELEASE = "6.0.0-slicc";
3689
3689
  function procVersion() {
3690
3690
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -11064,7 +11064,7 @@ async function heldOpen(entry, path, real, req, fid) {
11064
11064
  const handle = entry.hold?.(path, true, true, real, void 0, req.ino, fid);
11065
11065
  if (handle === void 0) return null;
11066
11066
  await entry.announceHold?.(real ?? path, fid, ((req.mode ?? 0) & HOLD_CREATED) !== 0);
11067
- return handle;
11067
+ return real !== void 0 && real !== path ? { handle, real } : handle;
11068
11068
  }
11069
11069
  async function idOf(entry, path) {
11070
11070
  return await entry.fileId?.(path)?.catch(() => void 0) ?? void 0;
@@ -12025,6 +12025,10 @@ var AsyncRangedFile = class {
12025
12025
  truncate(size) {
12026
12026
  this.pages.truncate(size);
12027
12027
  }
12028
+ wrote(at, length2) {
12029
+ this.pages.landed(at, length2);
12030
+ this.version = void 0;
12031
+ }
12028
12032
  async flush() {
12029
12033
  if (this.pinned || !this.pages.changed) return;
12030
12034
  const plan = this.pages.plan();
@@ -20150,6 +20154,7 @@ var VfsNode = class {
20150
20154
  ino;
20151
20155
  onDirty;
20152
20156
  onDirtyState;
20157
+ crowded;
20153
20158
  counted = false;
20154
20159
  recount() {
20155
20160
  if (!this.onDirtyState) return;
@@ -20267,9 +20272,48 @@ var VfsNode = class {
20267
20272
  if (!this.dirty) this.data = void 0;
20268
20273
  }
20269
20274
  async size() {
20275
+ if (this.peerHeld()) {
20276
+ const known = await this.exact();
20277
+ if (known !== void 0) return known;
20278
+ }
20270
20279
  const ranged2 = await this.prepare();
20271
20280
  return ranged2 ? ranged2.size() : this.length;
20272
20281
  }
20282
+ peered = false;
20283
+ peerHeld() {
20284
+ if (this.orphaned || this.revoked || this.pin) return false;
20285
+ if (this.crowded?.(this.path) === true) this.peered = true;
20286
+ return this.peered;
20287
+ }
20288
+ async exact() {
20289
+ await this.flush();
20290
+ const { stat } = this.fs;
20291
+ const io = rangedOps(this.fs);
20292
+ if (!stat || !io) return void 0;
20293
+ const st = await this.followed(() => stat.call(this.fs, this.path));
20294
+ this.peered = this.crowded?.(this.path) === true;
20295
+ const size = st.size ?? 0;
20296
+ if (this.ranged) {
20297
+ if (size !== this.ranged.size()) {
20298
+ this.ranged = new AsyncRangedFile(io, this.path, size, st.version);
20299
+ }
20300
+ return void 0;
20301
+ }
20302
+ if (this.data && size !== this.length) this.data = void 0;
20303
+ return this.data ? void 0 : size;
20304
+ }
20305
+ landed(at, bytes) {
20306
+ if (this.ranged) {
20307
+ this.ranged.wrote(at, bytes.length);
20308
+ return;
20309
+ }
20310
+ if (!this.data) return;
20311
+ const end = at + bytes.length;
20312
+ const buf = this.ensure(end);
20313
+ if (at > this.length) buf.fill(0, this.length, at);
20314
+ buf.set(bytes, at);
20315
+ this.length = Math.max(this.length, end);
20316
+ }
20273
20317
  async pread(max, at) {
20274
20318
  const ranged2 = await this.prepare();
20275
20319
  if (ranged2) return this.followed(() => ranged2.read(at, max));
@@ -20341,6 +20385,13 @@ var VfsNode = class {
20341
20385
  if (bytes.length === 0) return 0;
20342
20386
  await this.settled();
20343
20387
  await this.fits(at + bytes.length);
20388
+ const io = this.peerHeld() ? rangedOps(this.fs) : void 0;
20389
+ if (io && at + bytes.length > await this.size()) {
20390
+ const copy = bytes.slice();
20391
+ await this.followed(() => io.pwrite(this.path, at, copy, true));
20392
+ this.landed(at, bytes);
20393
+ return bytes.length;
20394
+ }
20344
20395
  const ranged2 = await this.prepare();
20345
20396
  if (ranged2) {
20346
20397
  await this.followed(() => ranged2.write(at, bytes));
@@ -20437,6 +20488,7 @@ var VfsNodes = class {
20437
20488
  movedAway;
20438
20489
  opened;
20439
20490
  dirtied;
20491
+ crowded;
20440
20492
  fs;
20441
20493
  entries;
20442
20494
  onClosed;
@@ -20582,6 +20634,7 @@ var VfsNodes = class {
20582
20634
  this.reshaped();
20583
20635
  node.onDirty = () => this.changed?.(node.path);
20584
20636
  node.onDirtyState = (on) => this.dirtied?.(on ? 1 : -1);
20637
+ node.crowded = (at) => this.crowded?.(at) === true;
20585
20638
  node.recount();
20586
20639
  this.byPath.set(path, node);
20587
20640
  if (id2 !== void 0) this.know(node, id2);
@@ -26618,6 +26671,15 @@ var OpfsFs = class {
26618
26671
  }
26619
26672
  async pread(path, offset, length2) {
26620
26673
  return this.reading(path, async (handle) => {
26674
+ const seen = this.glanced(handle);
26675
+ if (seen && length2 > 0 && offset + length2 <= seen.size) {
26676
+ const bytes = await this.io(seen.slice(offset, offset + length2).arrayBuffer()).then(
26677
+ (buffer) => new Uint8Array(buffer),
26678
+ () => void 0
26679
+ );
26680
+ if (bytes?.length === length2) return bytes;
26681
+ this.glances.delete(handle);
26682
+ }
26621
26683
  const file = await this.io(handle.getFile());
26622
26684
  await this.refuseNode(path, file.size === 0);
26623
26685
  return new Uint8Array(await file.slice(offset, offset + length2).arrayBuffer());
@@ -30586,6 +30648,7 @@ var Launcher = class {
30586
30648
  hostname;
30587
30649
  watchers = new FsWatchers();
30588
30650
  changes = new FileChanges();
30651
+ peerHeldPaths = /* @__PURE__ */ new Set();
30589
30652
  renameLog = new RenameLog(this.changes);
30590
30653
  cwds = new CwdTable(async (path) => {
30591
30654
  const { dev, ino } = await this.base.stat(path);
@@ -32858,6 +32921,7 @@ var Launcher = class {
32858
32921
  openNodes(fs, entries) {
32859
32922
  const nodes = new VfsNodes(fs, (path) => this.released(path), entries);
32860
32923
  nodes.opened = (node) => this.nodeOpened(node);
32924
+ nodes.crowded = (path) => this.peerHeldPaths.has(path);
32861
32925
  return nodes;
32862
32926
  }
32863
32927
  nodeOpened(node) {
@@ -32879,7 +32943,10 @@ var Launcher = class {
32879
32943
  return this.mounts.locate(path) === void 0 ? this.rootFs.bindId?.(path) : void 0;
32880
32944
  }
32881
32945
  flushingPeers(fs) {
32882
- fs.peerHolds?.((paths) => this.changes.peerHeld(paths));
32946
+ fs.peerHolds?.((paths) => {
32947
+ this.peerHeldPaths = new Set(paths);
32948
+ this.changes.peerHeld(paths);
32949
+ });
32883
32950
  const peers = fs.peers?.();
32884
32951
  if (!peers) return void 0;
32885
32952
  peers.watch((crowded) => {