@ai-ecoverse/slicc-kernel 1.133.2 → 1.133.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/README.md +1 -1
- package/dist/kernel-worker.js +98 -18
- package/dist/kernel-worker.js.map +3 -3
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.js +157 -128
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +98 -18
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +145 -116
- package/dist/process-worker.js.map +4 -4
- package/dist/types/fs/changes.d.ts +1 -0
- package/dist/types/fs/meta.d.ts +7 -0
- package/dist/types/fs/opfs.d.ts +3 -0
- package/dist/types/fs/remote.d.ts +1 -0
- package/dist/types/kernel/net/tls-uplink.d.ts +12 -1
- package/dist/types/process/wasi/wasi-files.d.ts +2 -1
- package/dist/types/realm/live-vfs-fs.d.ts +4 -0
- package/package.json +1 -1
|
@@ -265,6 +265,70 @@ var init_wasi_abi = __esm({
|
|
|
265
265
|
}
|
|
266
266
|
});
|
|
267
267
|
|
|
268
|
+
// src/fs/changes.ts
|
|
269
|
+
function changeHash(path) {
|
|
270
|
+
let h = 2166136261;
|
|
271
|
+
for (let i = 0; i < path.length; i++) {
|
|
272
|
+
h ^= path.charCodeAt(i);
|
|
273
|
+
h = Math.imul(h, 16777619);
|
|
274
|
+
}
|
|
275
|
+
return h === 0 ? 1 : h;
|
|
276
|
+
}
|
|
277
|
+
function normal(path) {
|
|
278
|
+
const parts = [];
|
|
279
|
+
for (const part of path.split("/")) {
|
|
280
|
+
if (part === "" || part === ".") continue;
|
|
281
|
+
if (part === "..") parts.pop();
|
|
282
|
+
else parts.push(part);
|
|
283
|
+
}
|
|
284
|
+
return `/${parts.join("/")}`;
|
|
285
|
+
}
|
|
286
|
+
var GEN, RING, RING_SIZE, SLOT, SHARED_TTL_MS, DIRTY, FOREIGN, CHANGES_BYTES, ChangeView;
|
|
287
|
+
var init_changes = __esm({
|
|
288
|
+
"src/fs/changes.ts"() {
|
|
289
|
+
"use strict";
|
|
290
|
+
GEN = 0;
|
|
291
|
+
RING = 1;
|
|
292
|
+
RING_SIZE = 4096;
|
|
293
|
+
SLOT = 2;
|
|
294
|
+
SHARED_TTL_MS = 100;
|
|
295
|
+
DIRTY = RING + RING_SIZE * SLOT;
|
|
296
|
+
FOREIGN = DIRTY + 1;
|
|
297
|
+
CHANGES_BYTES = (FOREIGN + 1) * 4;
|
|
298
|
+
ChangeView = class {
|
|
299
|
+
view;
|
|
300
|
+
constructor(sab) {
|
|
301
|
+
this.view = new Int32Array(sab);
|
|
302
|
+
}
|
|
303
|
+
now() {
|
|
304
|
+
return Atomics.load(this.view, GEN);
|
|
305
|
+
}
|
|
306
|
+
clean() {
|
|
307
|
+
return this.view.length > DIRTY && Atomics.load(this.view, DIRTY) === 0;
|
|
308
|
+
}
|
|
309
|
+
foreign() {
|
|
310
|
+
return this.view.length > FOREIGN && Atomics.load(this.view, FOREIGN) === 1;
|
|
311
|
+
}
|
|
312
|
+
changedSince(seen, path) {
|
|
313
|
+
const now = Atomics.load(this.view, GEN);
|
|
314
|
+
const distance = now - seen >>> 0;
|
|
315
|
+
if (distance === 0) return { now, changed: false };
|
|
316
|
+
if (distance > RING_SIZE) return { now, changed: true };
|
|
317
|
+
const hash = changeHash(normal(path));
|
|
318
|
+
for (let i = 1; i <= distance; i++) {
|
|
319
|
+
const g = seen + i | 0;
|
|
320
|
+
const at = RING + (g & RING_SIZE - 1) * SLOT;
|
|
321
|
+
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
322
|
+
const hit = Atomics.load(this.view, at + 1) === hash;
|
|
323
|
+
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
324
|
+
if (hit) return { now, changed: true };
|
|
325
|
+
}
|
|
326
|
+
return { now, changed: false };
|
|
327
|
+
}
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
268
332
|
// src/fs/pages.ts
|
|
269
333
|
var PAGE, READAHEAD, CLEAN_LIMIT, WRITEBACK, RUN, Pages;
|
|
270
334
|
var init_pages = __esm({
|
|
@@ -788,11 +852,11 @@ function copying(bridge, mutating, entry) {
|
|
|
788
852
|
copy: (from, to, mode, exclusive) => mutating(() => copy2.call(bridge, from, to, mode, exclusive), ...entry(to))
|
|
789
853
|
};
|
|
790
854
|
}
|
|
791
|
-
function listed({ cache, seen, filled }, p, list, gen, asked) {
|
|
855
|
+
function listed({ cache, seen, filled: filled2 }, p, list, gen, asked) {
|
|
792
856
|
const base = p === "/" ? "" : p;
|
|
793
857
|
for (const [name2, st] of list) {
|
|
794
858
|
if (!st) continue;
|
|
795
|
-
|
|
859
|
+
filled2.set(st, asked);
|
|
796
860
|
const at = `${base}/${name2}`;
|
|
797
861
|
cache.put(cache.lstats, at, st);
|
|
798
862
|
if (gen !== void 0) seen.saw(cache.lstats, at, gen);
|
|
@@ -805,7 +869,7 @@ function fetched({
|
|
|
805
869
|
view,
|
|
806
870
|
now,
|
|
807
871
|
seen,
|
|
808
|
-
filled,
|
|
872
|
+
filled: filled2,
|
|
809
873
|
cache
|
|
810
874
|
}, map, path, get) {
|
|
811
875
|
const gen = view?.now();
|
|
@@ -817,7 +881,7 @@ function fetched({
|
|
|
817
881
|
} catch (e) {
|
|
818
882
|
hit = { error: e, until: asked + MISS_TTL_MS, ...gen !== void 0 ? { gen } : {} };
|
|
819
883
|
}
|
|
820
|
-
|
|
884
|
+
filled2.set(hit, asked);
|
|
821
885
|
cache.put(map, path, hit);
|
|
822
886
|
return hit;
|
|
823
887
|
}
|
|
@@ -826,17 +890,17 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
826
890
|
const cache = new StatCache(blind ? void 0 : shared);
|
|
827
891
|
const { stats, lstats } = cache;
|
|
828
892
|
const view = bridge.changes;
|
|
829
|
-
const
|
|
830
|
-
const
|
|
831
|
-
const live = (miss, path) => miss.until > now() &&
|
|
893
|
+
const filled2 = new Fills(view, now);
|
|
894
|
+
const young2 = (entry2) => filled2.young(entry2);
|
|
895
|
+
const live = (miss, path) => miss.until > now() && young2(miss) && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
|
|
832
896
|
const seen = new SeenAt(view, lstats);
|
|
833
|
-
const kept = remember(cache, seen, blind, (entry2) =>
|
|
897
|
+
const kept = remember(cache, seen, blind, (entry2) => filled2.set(entry2));
|
|
834
898
|
const gone = (path) => goneAbove([lstats, stats], live, path);
|
|
835
899
|
const usable = (map, path) => {
|
|
836
900
|
const hit = map.get(path);
|
|
837
901
|
if (hit === void 0) return void 0;
|
|
838
902
|
if ("until" in hit) return live(hit, path) ? hit : void 0;
|
|
839
|
-
return
|
|
903
|
+
return young2(hit) && !seen.changed(map, path) ? hit : void 0;
|
|
840
904
|
};
|
|
841
905
|
const cached = (map, path, get) => {
|
|
842
906
|
if (blind) return get();
|
|
@@ -845,7 +909,7 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
845
909
|
if (hit === void 0) {
|
|
846
910
|
const missing2 = gone(path);
|
|
847
911
|
if (missing2) throw missing2.error;
|
|
848
|
-
hit = fetched({ view, now, seen, filled, cache }, map, path, get);
|
|
912
|
+
hit = fetched({ view, now, seen, filled: filled2, cache }, map, path, get);
|
|
849
913
|
}
|
|
850
914
|
if ("until" in hit) throw hit.error;
|
|
851
915
|
return hit;
|
|
@@ -904,14 +968,14 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
904
968
|
const gen = view?.now();
|
|
905
969
|
const asked = now();
|
|
906
970
|
const list = bridge.readdirStat(p);
|
|
907
|
-
if (!blind) listed({ cache, seen, filled }, p, list, gen, asked);
|
|
971
|
+
if (!blind) listed({ cache, seen, filled: filled2 }, p, list, gen, asked);
|
|
908
972
|
return list;
|
|
909
973
|
},
|
|
910
974
|
readlink: (p) => {
|
|
911
975
|
const known = blind ? void 0 : (cache.fresh(), lstats.get(p));
|
|
912
976
|
const gen = seen.lstat(p);
|
|
913
977
|
const current = view !== void 0 && gen !== void 0 && !view.changedSince(gen, p).changed;
|
|
914
|
-
if (known && current && !("until" in known) &&
|
|
978
|
+
if (known && current && !("until" in known) && young2(known) && !known.isSymbolicLink) {
|
|
915
979
|
throw syncError("EINVAL", `'${p}' is not a symbolic link`);
|
|
916
980
|
}
|
|
917
981
|
return bridge.readlink(p);
|
|
@@ -984,10 +1048,11 @@ function pinnedIo(bridge, handle, rewriting) {
|
|
|
984
1048
|
} : {}
|
|
985
1049
|
};
|
|
986
1050
|
}
|
|
987
|
-
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS,
|
|
1051
|
+
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, UMASK, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember, Fills;
|
|
988
1052
|
var init_wasi_files = __esm({
|
|
989
1053
|
"src/process/wasi/wasi-files.ts"() {
|
|
990
1054
|
"use strict";
|
|
1055
|
+
init_changes();
|
|
991
1056
|
init_ranged();
|
|
992
1057
|
init_sync_fs_wire();
|
|
993
1058
|
WasiError = class extends Error {
|
|
@@ -1211,15 +1276,14 @@ var init_wasi_files = __esm({
|
|
|
1211
1276
|
};
|
|
1212
1277
|
MAX_LINKS = 40;
|
|
1213
1278
|
MISS_TTL_MS = 20;
|
|
1214
|
-
SHARED_TTL_MS = 100;
|
|
1215
1279
|
CACHE_CAP = 8192;
|
|
1216
1280
|
FS_GEN = 4;
|
|
1217
1281
|
CRED_GEN = 5;
|
|
1218
1282
|
UMASK = 6;
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
FD_RING =
|
|
1283
|
+
RING2 = 8;
|
|
1284
|
+
RING_SIZE2 = 64;
|
|
1285
|
+
SLOT2 = 3;
|
|
1286
|
+
FD_RING = RING2 + RING_SIZE2 * SLOT2;
|
|
1223
1287
|
FD_RING_SIZE = 64;
|
|
1224
1288
|
SHARED_IDS_BYTES = (FD_RING + FD_RING_SIZE * 2) * 4;
|
|
1225
1289
|
StatCache = class {
|
|
@@ -1298,7 +1362,7 @@ var init_wasi_files = __esm({
|
|
|
1298
1362
|
}
|
|
1299
1363
|
publish(shared, hash, ino) {
|
|
1300
1364
|
const g = Atomics.add(shared, FS_GEN, 1) + 1;
|
|
1301
|
-
const at =
|
|
1365
|
+
const at = RING2 + g % RING_SIZE2 * SLOT2;
|
|
1302
1366
|
Atomics.store(shared, at, 0);
|
|
1303
1367
|
Atomics.store(shared, at + 1, hash);
|
|
1304
1368
|
Atomics.store(shared, at + 2, ino);
|
|
@@ -1308,8 +1372,8 @@ var init_wasi_files = __esm({
|
|
|
1308
1372
|
replay(upTo) {
|
|
1309
1373
|
const shared = this.shared;
|
|
1310
1374
|
const missed = [];
|
|
1311
|
-
for (let g = this.seen + 1; g <= upTo && upTo - this.seen <=
|
|
1312
|
-
const at =
|
|
1375
|
+
for (let g = this.seen + 1; g <= upTo && upTo - this.seen <= RING_SIZE2; g++) {
|
|
1376
|
+
const at = RING2 + g % RING_SIZE2 * SLOT2;
|
|
1313
1377
|
const tag = Atomics.load(shared, at);
|
|
1314
1378
|
const hash = Atomics.load(shared, at + 1);
|
|
1315
1379
|
const ino = Atomics.load(shared, at + 2);
|
|
@@ -2989,7 +3053,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
2989
3053
|
...f.buffer.handle !== void 0 && f.ino !== void 0 ? { ino: f.ino } : {}
|
|
2990
3054
|
};
|
|
2991
3055
|
}
|
|
2992
|
-
var SYNTHETIC_DIRS, O_NONBLOCK, O_WRONLY2, O_RDWR2, O_APPEND2, SEALED_PATH, CLIPBOARD_PATH, WasiFds,
|
|
3056
|
+
var SYNTHETIC_DIRS, O_NONBLOCK, O_WRONLY2, O_RDWR2, O_APPEND2, SEALED_PATH, CLIPBOARD_PATH, WasiFds, GEN2;
|
|
2993
3057
|
var init_wasi_fds = __esm({
|
|
2994
3058
|
"src/process/wasi/wasi-fds.ts"() {
|
|
2995
3059
|
"use strict";
|
|
@@ -3100,11 +3164,11 @@ var init_wasi_fds = __esm({
|
|
|
3100
3164
|
}
|
|
3101
3165
|
this.shared = ids;
|
|
3102
3166
|
this.fs.threaded?.();
|
|
3103
|
-
this.seen = Atomics.load(ids,
|
|
3167
|
+
this.seen = Atomics.load(ids, GEN2);
|
|
3104
3168
|
}
|
|
3105
3169
|
sync() {
|
|
3106
3170
|
const shared = this.shared;
|
|
3107
|
-
const gen = Atomics.load(shared,
|
|
3171
|
+
const gen = Atomics.load(shared, GEN2);
|
|
3108
3172
|
if (gen === this.seen) return;
|
|
3109
3173
|
if (!this.replay(shared, gen)) {
|
|
3110
3174
|
this.table.clear();
|
|
@@ -3132,7 +3196,7 @@ var init_wasi_fds = __esm({
|
|
|
3132
3196
|
if (!this.shared) return;
|
|
3133
3197
|
const shared = this.shared;
|
|
3134
3198
|
for (const fd of fds.length > 0 ? fds : [-1]) {
|
|
3135
|
-
const gen = Atomics.add(shared,
|
|
3199
|
+
const gen = Atomics.add(shared, GEN2, 1) + 1;
|
|
3136
3200
|
if (ringed(shared)) {
|
|
3137
3201
|
const at = FD_RING + gen % FD_RING_SIZE * 2;
|
|
3138
3202
|
Atomics.store(shared, at, 0);
|
|
@@ -3811,7 +3875,7 @@ var init_wasi_fds = __esm({
|
|
|
3811
3875
|
return this.install(e.type === "file" ? e : { ...e });
|
|
3812
3876
|
}
|
|
3813
3877
|
};
|
|
3814
|
-
|
|
3878
|
+
GEN2 = 2;
|
|
3815
3879
|
}
|
|
3816
3880
|
});
|
|
3817
3881
|
|
|
@@ -5865,13 +5929,13 @@ var init_wasi_host = __esm({
|
|
|
5865
5929
|
const view = this.mem.view();
|
|
5866
5930
|
const size = Math.min(view.getUint32(at, true), SIGINFO_BYTES);
|
|
5867
5931
|
const fields = [sig, info.code, info.pid, info.uid, info.status];
|
|
5868
|
-
let
|
|
5932
|
+
let filled2 = 4;
|
|
5869
5933
|
for (const [i, value2] of fields.entries()) {
|
|
5870
5934
|
if (4 + (i + 1) * 4 > size) break;
|
|
5871
5935
|
view.setInt32(4 + at + i * 4, value2, true);
|
|
5872
|
-
|
|
5936
|
+
filled2 = 4 + (i + 1) * 4;
|
|
5873
5937
|
}
|
|
5874
|
-
view.setUint32(at,
|
|
5938
|
+
view.setUint32(at, filled2, true);
|
|
5875
5939
|
return true;
|
|
5876
5940
|
}
|
|
5877
5941
|
fdAlias(path) {
|
|
@@ -6520,7 +6584,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
6520
6584
|
var init_version = __esm({
|
|
6521
6585
|
"src/version.ts"() {
|
|
6522
6586
|
"use strict";
|
|
6523
|
-
KERNEL_VERSION = true ? "1.133.
|
|
6587
|
+
KERNEL_VERSION = true ? "1.133.4" : "0.0.0-dev";
|
|
6524
6588
|
OS_RELEASE = "6.0.0-slicc";
|
|
6525
6589
|
}
|
|
6526
6590
|
});
|
|
@@ -7662,69 +7726,6 @@ var init_wasi_errno = __esm({
|
|
|
7662
7726
|
}
|
|
7663
7727
|
});
|
|
7664
7728
|
|
|
7665
|
-
// src/fs/changes.ts
|
|
7666
|
-
function changeHash(path) {
|
|
7667
|
-
let h = 2166136261;
|
|
7668
|
-
for (let i = 0; i < path.length; i++) {
|
|
7669
|
-
h ^= path.charCodeAt(i);
|
|
7670
|
-
h = Math.imul(h, 16777619);
|
|
7671
|
-
}
|
|
7672
|
-
return h === 0 ? 1 : h;
|
|
7673
|
-
}
|
|
7674
|
-
function normal(path) {
|
|
7675
|
-
const parts = [];
|
|
7676
|
-
for (const part of path.split("/")) {
|
|
7677
|
-
if (part === "" || part === ".") continue;
|
|
7678
|
-
if (part === "..") parts.pop();
|
|
7679
|
-
else parts.push(part);
|
|
7680
|
-
}
|
|
7681
|
-
return `/${parts.join("/")}`;
|
|
7682
|
-
}
|
|
7683
|
-
var GEN2, RING2, RING_SIZE2, SLOT2, DIRTY, FOREIGN, CHANGES_BYTES, ChangeView;
|
|
7684
|
-
var init_changes = __esm({
|
|
7685
|
-
"src/fs/changes.ts"() {
|
|
7686
|
-
"use strict";
|
|
7687
|
-
GEN2 = 0;
|
|
7688
|
-
RING2 = 1;
|
|
7689
|
-
RING_SIZE2 = 4096;
|
|
7690
|
-
SLOT2 = 2;
|
|
7691
|
-
DIRTY = RING2 + RING_SIZE2 * SLOT2;
|
|
7692
|
-
FOREIGN = DIRTY + 1;
|
|
7693
|
-
CHANGES_BYTES = (FOREIGN + 1) * 4;
|
|
7694
|
-
ChangeView = class {
|
|
7695
|
-
view;
|
|
7696
|
-
constructor(sab) {
|
|
7697
|
-
this.view = new Int32Array(sab);
|
|
7698
|
-
}
|
|
7699
|
-
now() {
|
|
7700
|
-
return Atomics.load(this.view, GEN2);
|
|
7701
|
-
}
|
|
7702
|
-
clean() {
|
|
7703
|
-
return this.view.length > DIRTY && Atomics.load(this.view, DIRTY) === 0;
|
|
7704
|
-
}
|
|
7705
|
-
foreign() {
|
|
7706
|
-
return this.view.length > FOREIGN && Atomics.load(this.view, FOREIGN) === 1;
|
|
7707
|
-
}
|
|
7708
|
-
changedSince(seen, path) {
|
|
7709
|
-
const now = Atomics.load(this.view, GEN2);
|
|
7710
|
-
const distance = now - seen >>> 0;
|
|
7711
|
-
if (distance === 0) return { now, changed: false };
|
|
7712
|
-
if (distance > RING_SIZE2) return { now, changed: true };
|
|
7713
|
-
const hash = changeHash(normal(path));
|
|
7714
|
-
for (let i = 1; i <= distance; i++) {
|
|
7715
|
-
const g = seen + i | 0;
|
|
7716
|
-
const at = RING2 + (g & RING_SIZE2 - 1) * SLOT2;
|
|
7717
|
-
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
7718
|
-
const hit = Atomics.load(this.view, at + 1) === hash;
|
|
7719
|
-
if (Atomics.load(this.view, at) !== g) return { now, changed: true };
|
|
7720
|
-
if (hit) return { now, changed: true };
|
|
7721
|
-
}
|
|
7722
|
-
return { now, changed: false };
|
|
7723
|
-
}
|
|
7724
|
-
};
|
|
7725
|
-
}
|
|
7726
|
-
});
|
|
7727
|
-
|
|
7728
7729
|
// src/realm/sync-sab-bridge.ts
|
|
7729
7730
|
function syncCallCount() {
|
|
7730
7731
|
return calls;
|
|
@@ -8095,8 +8096,16 @@ function refusal(err) {
|
|
|
8095
8096
|
const code2 = err?.code;
|
|
8096
8097
|
return code2 === "EACCES" || code2 === "EPERM";
|
|
8097
8098
|
}
|
|
8098
|
-
function
|
|
8099
|
-
|
|
8099
|
+
function young(s) {
|
|
8100
|
+
return performance.now() - (s.filledAt ?? Number.NEGATIVE_INFINITY) < SHARED_TTL_MS;
|
|
8101
|
+
}
|
|
8102
|
+
function cachedStat(node, dir, view) {
|
|
8103
|
+
const s = node.live;
|
|
8104
|
+
if (view?.foreign() && !s.dirty) {
|
|
8105
|
+
const gen = s.statGen ?? s.named;
|
|
8106
|
+
if (s.openCount > 0 || !young(s) || gen === void 0) return false;
|
|
8107
|
+
if (view.changedSince(gen, liveNodePath(node)).changed) return false;
|
|
8108
|
+
}
|
|
8100
8109
|
return s.stat !== void 0 && (!dir || s.statAt === syncCallCount());
|
|
8101
8110
|
}
|
|
8102
8111
|
function searchParents(Fs, node, bridge, call2) {
|
|
@@ -8162,9 +8171,22 @@ function linkedStates(bridgeOf) {
|
|
|
8162
8171
|
const holder = (node) => opens.get(node.live) ?? node;
|
|
8163
8172
|
return { opening: opening2, sharedWith, know, idOf: idOf4, holder };
|
|
8164
8173
|
}
|
|
8174
|
+
function filled(s, stat, asked) {
|
|
8175
|
+
Object.assign(s, { stat, statAt: syncCallCount(), seenAt: syncEpoch(), ...asked });
|
|
8176
|
+
}
|
|
8177
|
+
function asking(bridge) {
|
|
8178
|
+
return { filledAt: performance.now(), statGen: bridge.changes?.now() };
|
|
8179
|
+
}
|
|
8180
|
+
function listing(s) {
|
|
8181
|
+
return { filledAt: s.listedAt ?? Number.NEGATIVE_INFINITY, statGen: s.listedGen };
|
|
8182
|
+
}
|
|
8183
|
+
function answeredAt(node, asked) {
|
|
8184
|
+
Object.assign(node.live, asked);
|
|
8185
|
+
return node;
|
|
8186
|
+
}
|
|
8165
8187
|
function freshState(stat) {
|
|
8166
8188
|
const base = { len: 0, loaded: false, dirty: false, openCount: 0 };
|
|
8167
|
-
return stat ? { stat, statAt: syncCallCount(), seenAt: syncEpoch(), ...base } : base;
|
|
8189
|
+
return stat ? { stat, statAt: syncCallCount(), filledAt: performance.now(), seenAt: syncEpoch(), ...base } : base;
|
|
8168
8190
|
}
|
|
8169
8191
|
function createHelpers(Fs, ops) {
|
|
8170
8192
|
const bridgeOf = (node) => node.mount.opts.bridge;
|
|
@@ -8217,9 +8239,11 @@ function createHelpers(Fs, ops) {
|
|
|
8217
8239
|
const size = node.live.ranged?.size() ?? node.live.len;
|
|
8218
8240
|
return { ...node.live.stat, size };
|
|
8219
8241
|
}
|
|
8220
|
-
|
|
8242
|
+
const view = bridgeOf(node).changes;
|
|
8243
|
+
if (!cachedStat(node, Fs.isDir(node.mode), view)) {
|
|
8244
|
+
const asked = { statGen: view?.now(), filledAt: performance.now() };
|
|
8221
8245
|
const st = call2(() => bridgeOf(node).lstat(liveNodePath(linked.holder(node))));
|
|
8222
|
-
|
|
8246
|
+
filled(node.live, st, asked);
|
|
8223
8247
|
node.mode = modeFromStat(st, exactIn(node));
|
|
8224
8248
|
}
|
|
8225
8249
|
return node.live.stat;
|
|
@@ -8381,7 +8405,7 @@ function createNodeOps(h) {
|
|
|
8381
8405
|
const owned = bridgeOf(node).owners === true;
|
|
8382
8406
|
if (owned && Fs.isLink(node.mode) && statOf(node).uid === void 0)
|
|
8383
8407
|
node.live.stat = void 0;
|
|
8384
|
-
const cached = owned && cachedStat(node
|
|
8408
|
+
const cached = owned && cachedStat(node, Fs.isDir(node.mode), bridgeOf(node).changes);
|
|
8385
8409
|
const st = statOf(node);
|
|
8386
8410
|
if (cached) searchParents(Fs, node, bridgeOf(node), call2);
|
|
8387
8411
|
const s = node.live;
|
|
@@ -8430,8 +8454,9 @@ function createNodeOps(h) {
|
|
|
8430
8454
|
lookup(parent, name2) {
|
|
8431
8455
|
const listed2 = parent.live.listed?.get(name2);
|
|
8432
8456
|
parent.live.listed?.delete(name2);
|
|
8457
|
+
const asked = listed2 ? listing(parent.live) : asking(bridgeOf(parent));
|
|
8433
8458
|
const st = listed2 ?? call2(() => bridgeOf(parent).lstat(childPath(parent, name2)));
|
|
8434
|
-
return makeNode(parent, name2, st);
|
|
8459
|
+
return answeredAt(makeNode(parent, name2, st), asked);
|
|
8435
8460
|
},
|
|
8436
8461
|
mknod(parent, name2, mode) {
|
|
8437
8462
|
parent.live.listed = void 0;
|
|
@@ -8504,8 +8529,11 @@ function createNodeOps(h) {
|
|
|
8504
8529
|
call2(() => bridgeOf(parent).rmdir(childPath(parent, name2)));
|
|
8505
8530
|
},
|
|
8506
8531
|
readdir(node) {
|
|
8532
|
+
const listedAt = performance.now();
|
|
8533
|
+
const listedGen = bridgeOf(node).changes?.now();
|
|
8507
8534
|
const listed2 = call2(() => bridgeOf(node).readdirStat(liveNodePath(node)));
|
|
8508
8535
|
node.live.listed = /* @__PURE__ */ new Map();
|
|
8536
|
+
Object.assign(node.live, { listedAt, listedGen });
|
|
8509
8537
|
for (const [name2, st] of listed2) if (st) node.live.listed.set(name2, st);
|
|
8510
8538
|
return [".", "..", ...listed2.map(([name2]) => name2)];
|
|
8511
8539
|
},
|
|
@@ -9137,6 +9165,7 @@ var init_live_vfs_fs = __esm({
|
|
|
9137
9165
|
"src/realm/live-vfs-fs.ts"() {
|
|
9138
9166
|
"use strict";
|
|
9139
9167
|
init_access();
|
|
9168
|
+
init_changes();
|
|
9140
9169
|
init_ranged();
|
|
9141
9170
|
init_types();
|
|
9142
9171
|
init_wasi_errno();
|
|
@@ -10273,8 +10302,8 @@ function sysEntry(parts) {
|
|
|
10273
10302
|
}
|
|
10274
10303
|
return at;
|
|
10275
10304
|
}
|
|
10276
|
-
function sysText(file,
|
|
10277
|
-
return typeof file === "string" ? file : file(
|
|
10305
|
+
function sysText(file, listing2) {
|
|
10306
|
+
return typeof file === "string" ? file : file(listing2());
|
|
10278
10307
|
}
|
|
10279
10308
|
function commOf(info) {
|
|
10280
10309
|
const name2 = info.argv[0] ?? "";
|
|
@@ -10402,35 +10431,35 @@ function memoryInfo(source, used = 0) {
|
|
|
10402
10431
|
["SwapFree", kb(0)]
|
|
10403
10432
|
].map(([key, value2]) => `${`${key}:`.padEnd(16)}${value2.padStart(12)}`).concat("").join("\n");
|
|
10404
10433
|
}
|
|
10405
|
-
function systemFile(name2,
|
|
10434
|
+
function systemFile(name2, listing2, now, memory) {
|
|
10406
10435
|
if (name2 === "version") return procVersion();
|
|
10407
|
-
const up = Math.max(0, now -
|
|
10436
|
+
const up = Math.max(0, now - listing2.boot) / 1e3;
|
|
10408
10437
|
if (name2 === "uptime") return `${up.toFixed(2)} ${up.toFixed(2)}
|
|
10409
10438
|
`;
|
|
10410
10439
|
if (name2 === "meminfo") {
|
|
10411
10440
|
return memoryInfo(
|
|
10412
10441
|
memory,
|
|
10413
|
-
|
|
10442
|
+
listing2.processes.reduce((sum2, p) => sum2 + p.memory, 0)
|
|
10414
10443
|
);
|
|
10415
10444
|
}
|
|
10416
|
-
const live =
|
|
10445
|
+
const live = listing2.processes.filter((p) => p.state !== "Z");
|
|
10417
10446
|
if (name2 === "loadavg") {
|
|
10418
|
-
const last = Math.max(0, ...
|
|
10419
|
-
const [one, five, fifteen] = (
|
|
10447
|
+
const last = Math.max(0, ...listing2.processes.map((p) => p.pid));
|
|
10448
|
+
const [one, five, fifteen] = (listing2.load ?? [0, 0, 0]).map((n) => n.toFixed(2));
|
|
10420
10449
|
return `${one} ${five} ${fifteen} 1/${live.length} ${last}
|
|
10421
10450
|
`;
|
|
10422
10451
|
}
|
|
10423
|
-
const sum = (key) =>
|
|
10452
|
+
const sum = (key) => listing2.cpu?.[key] ?? listing2.processes.reduce((n, p) => n + (p[key] ?? 0), 0);
|
|
10424
10453
|
const user = ticks(sum("utime"));
|
|
10425
10454
|
const system = ticks(sum("stime"));
|
|
10426
|
-
const idle =
|
|
10455
|
+
const idle = listing2.cpu ? ticks(listing2.cpu.idle) : Math.max(0, ticks(now - listing2.boot) - user - system);
|
|
10427
10456
|
return [
|
|
10428
10457
|
`cpu ${user} 0 ${system} ${idle} 0 0 0 0 0 0`,
|
|
10429
10458
|
`cpu0 ${user} 0 ${system} ${idle} 0 0 0 0 0 0`,
|
|
10430
10459
|
"intr 0",
|
|
10431
10460
|
"ctxt 0",
|
|
10432
|
-
`btime ${Math.floor(
|
|
10433
|
-
`processes ${
|
|
10461
|
+
`btime ${Math.floor(listing2.boot / 1e3)}`,
|
|
10462
|
+
`processes ${listing2.processes.length}`,
|
|
10434
10463
|
"procs_running 1",
|
|
10435
10464
|
"procs_blocked 0",
|
|
10436
10465
|
""
|
|
@@ -10515,10 +10544,10 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
10515
10544
|
const find = (processes2, target, own) => (own ? processes2.find((p) => p.tid === target) : void 0) ?? processes2.find((p) => p.pid === target || p.tid === target);
|
|
10516
10545
|
const infoOf = (target) => find(procList().processes, target, false);
|
|
10517
10546
|
const pidContent = (target, name2, own = false) => () => {
|
|
10518
|
-
const
|
|
10519
|
-
const info = find(
|
|
10547
|
+
const listing2 = procList();
|
|
10548
|
+
const info = find(listing2.processes, target, own);
|
|
10520
10549
|
if (!info) throw error();
|
|
10521
|
-
return pidFile(name2, info,
|
|
10550
|
+
return pidFile(name2, info, listing2.boot);
|
|
10522
10551
|
};
|
|
10523
10552
|
const sysDir = (parent, name2, tree) => {
|
|
10524
10553
|
const dir = fresh(parent, name2, DIR_MODE2);
|
|
@@ -10653,15 +10682,15 @@ var init_procfs = __esm({
|
|
|
10653
10682
|
osrelease: `${OS_RELEASE}
|
|
10654
10683
|
`,
|
|
10655
10684
|
ostype: "Linux\n",
|
|
10656
|
-
slicc_wasm_memories: (
|
|
10685
|
+
slicc_wasm_memories: (listing2) => `${listing2.wasm?.live ?? 0} ${listing2.wasm?.ceiling ?? 0} ${listing2.wasm?.source ?? "none"}
|
|
10657
10686
|
`,
|
|
10658
|
-
slicc_shared_root: (
|
|
10687
|
+
slicc_shared_root: (listing2) => `${listing2.peers ?? 0}
|
|
10659
10688
|
`,
|
|
10660
|
-
slicc_fs_calls: (
|
|
10689
|
+
slicc_fs_calls: (listing2) => `${listing2.fsCalls ?? 0}
|
|
10661
10690
|
`,
|
|
10662
|
-
slicc_opfs_calls: (
|
|
10691
|
+
slicc_opfs_calls: (listing2) => `${listing2.opfsCalls ?? 0}
|
|
10663
10692
|
`,
|
|
10664
|
-
slicc_opfs_ops: (
|
|
10693
|
+
slicc_opfs_ops: (listing2) => `${listing2.opfsOps ?? 0}
|
|
10665
10694
|
`
|
|
10666
10695
|
}
|
|
10667
10696
|
};
|
|
@@ -11003,10 +11032,10 @@ var init_wasi_procfs = __esm({
|
|
|
11003
11032
|
return {
|
|
11004
11033
|
kind: "file",
|
|
11005
11034
|
content: () => {
|
|
11006
|
-
const
|
|
11007
|
-
const info =
|
|
11035
|
+
const listing2 = this.listing();
|
|
11036
|
+
const info = listing2.processes.find((p) => p.pid === Number(top));
|
|
11008
11037
|
if (!info) throw syncError("ENOENT", `/proc/${top}/${leaf}`);
|
|
11009
|
-
return pidFile(leaf, info,
|
|
11038
|
+
return pidFile(leaf, info, listing2.boot);
|
|
11010
11039
|
}
|
|
11011
11040
|
};
|
|
11012
11041
|
}
|
|
@@ -11024,9 +11053,9 @@ var init_wasi_procfs = __esm({
|
|
|
11024
11053
|
return {
|
|
11025
11054
|
kind: "file",
|
|
11026
11055
|
content: () => {
|
|
11027
|
-
const
|
|
11028
|
-
const info =
|
|
11029
|
-
const line = info && taskStat(info, Number(tid),
|
|
11056
|
+
const listing2 = this.listing();
|
|
11057
|
+
const info = listing2.processes.find((p) => p.pid === pid);
|
|
11058
|
+
const line = info && taskStat(info, Number(tid), listing2.boot);
|
|
11030
11059
|
if (line === void 0) throw syncError("ENOENT", `/proc/${pid}/task/${tid}/stat`);
|
|
11031
11060
|
return line;
|
|
11032
11061
|
}
|
|
@@ -11092,10 +11121,10 @@ var init_wasi_procfs = __esm({
|
|
|
11092
11121
|
|
|
11093
11122
|
// src/process/js/js-proc.ts
|
|
11094
11123
|
function* procStep(abs, pid, run) {
|
|
11095
|
-
const
|
|
11124
|
+
const listing2 = yield { op: "proc-list" };
|
|
11096
11125
|
const mounts = abs === "/proc/mounts" ? yield { op: "mount-list" } : [];
|
|
11097
11126
|
const tree = new ProcTree(
|
|
11098
|
-
{ procList: () =>
|
|
11127
|
+
{ procList: () => listing2, mountList: () => mounts },
|
|
11099
11128
|
pid,
|
|
11100
11129
|
memorySource()
|
|
11101
11130
|
);
|