@ai-ecoverse/slicc-kernel 1.8.10 → 1.8.12
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/kernel-worker.js +7 -0
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +83 -13
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +7 -0
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +83 -13
- package/dist/process-worker.js.map +3 -3
- package/package.json +3 -3
|
@@ -265,7 +265,7 @@ function createNodeOps(h) {
|
|
|
265
265
|
mtime,
|
|
266
266
|
ctime: new Date(st.ctimeMs ?? mtime.getTime()),
|
|
267
267
|
blksize: 4096,
|
|
268
|
-
blocks: Math.ceil(size / 4096)
|
|
268
|
+
blocks: Math.ceil(size / 4096) * 8
|
|
269
269
|
};
|
|
270
270
|
},
|
|
271
271
|
setattr(node, attr) {
|
|
@@ -524,6 +524,7 @@ function mountLiveVfsDirs(Fs, bridge, dirs, warn) {
|
|
|
524
524
|
}
|
|
525
525
|
const plugin = Fs.filesystems.SLICC_LIVE_FS ?? createLiveVfsPlugin(Fs);
|
|
526
526
|
Fs.filesystems.SLICC_LIVE_FS = plugin;
|
|
527
|
+
guardStatfs(Fs);
|
|
527
528
|
const mounted = [];
|
|
528
529
|
for (const dir of outermostDirs(dirs)) {
|
|
529
530
|
if (dir === "/") continue;
|
|
@@ -546,6 +547,7 @@ function liveRoot(Fs, bridge) {
|
|
|
546
547
|
plugin.mounts.add(root.mount);
|
|
547
548
|
invalidateLiveVfs(Fs, plugin);
|
|
548
549
|
guardRenames(Fs);
|
|
550
|
+
guardStatfs(Fs);
|
|
549
551
|
const memfs = root.memfs ?? root.node_ops;
|
|
550
552
|
const live = plugin.node_ops;
|
|
551
553
|
root.memfs = memfs;
|
|
@@ -577,6 +579,30 @@ function crosses(Fs, from, to) {
|
|
|
577
579
|
return false;
|
|
578
580
|
}
|
|
579
581
|
}
|
|
582
|
+
function guardStatfs(Fs) {
|
|
583
|
+
const statfsNode = Fs.statfsNode?.bind(Fs);
|
|
584
|
+
if (!statfsNode || Fs.sliccStatfs) return;
|
|
585
|
+
Fs.sliccStatfs = true;
|
|
586
|
+
Fs.statfsNode = (node) => {
|
|
587
|
+
const defaults = statfsNode(node);
|
|
588
|
+
let usage;
|
|
589
|
+
try {
|
|
590
|
+
usage = node.live ? node.mount?.opts?.bridge?.statfs?.() : void 0;
|
|
591
|
+
} catch {
|
|
592
|
+
return defaults;
|
|
593
|
+
}
|
|
594
|
+
if (!usage) return defaults;
|
|
595
|
+
const free = Math.max(0, Math.floor((usage.quota - usage.usage) / 4096));
|
|
596
|
+
return {
|
|
597
|
+
...defaults,
|
|
598
|
+
bsize: 4096,
|
|
599
|
+
frsize: 4096,
|
|
600
|
+
blocks: Math.ceil(usage.quota / 4096),
|
|
601
|
+
bfree: free,
|
|
602
|
+
bavail: free
|
|
603
|
+
};
|
|
604
|
+
};
|
|
605
|
+
}
|
|
580
606
|
function guardRenames(Fs) {
|
|
581
607
|
const rename = Fs.rename?.bind(Fs);
|
|
582
608
|
if (!rename || Fs.sliccRename) return;
|
|
@@ -670,6 +696,11 @@ var init_emscripten_vfs_hook = __esm({
|
|
|
670
696
|
});
|
|
671
697
|
|
|
672
698
|
// src/realm/sync-fs-wire.ts
|
|
699
|
+
function parseSyncFsUsage(json) {
|
|
700
|
+
const u = json;
|
|
701
|
+
if (!u || typeof u.quota !== "number" || typeof u.usage !== "number") return null;
|
|
702
|
+
return { quota: u.quota, usage: u.usage };
|
|
703
|
+
}
|
|
673
704
|
function syncError(code2, label) {
|
|
674
705
|
return Object.assign(new Error(`${code2}: ${label}`), { code: code2 });
|
|
675
706
|
}
|
|
@@ -911,7 +942,8 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
911
942
|
},
|
|
912
943
|
utimes: (path, atimeMs, mtimeMs) => {
|
|
913
944
|
run({ op: "utimes", path, atimeMs, mtimeMs }, path);
|
|
914
|
-
}
|
|
945
|
+
},
|
|
946
|
+
statfs: () => parseSyncFsUsage(json({ op: "statfs", path: "/" }, "/"))
|
|
915
947
|
};
|
|
916
948
|
}
|
|
917
949
|
var init_sync_sab_bridge = __esm({
|
|
@@ -993,7 +1025,7 @@ function ptyStat(path) {
|
|
|
993
1025
|
function nonblocking(stream) {
|
|
994
1026
|
return (stream.flags & O_NONBLOCK) !== 0 ? { nonblock: true } : void 0;
|
|
995
1027
|
}
|
|
996
|
-
var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, O_NONBLOCK, SOCKET_MODE, PTY_PATH, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
|
|
1028
|
+
var POLLIN, POLLOUT, POLLERR, POLLHUP, POLLRDNORM, POLLWRNORM, O_NONBLOCK, SOCKET_MODE, PTY_PATH, TTY_PATH, O_CREAT, O_EXCL, O_NOCTTY, O_TRUNC, KILLED_BY_SIGPIPE, ProcessExit, SyscallError, KernelStreams;
|
|
997
1029
|
var init_kernel_streams = __esm({
|
|
998
1030
|
"src/process/kernel-streams.ts"() {
|
|
999
1031
|
"use strict";
|
|
@@ -1007,6 +1039,7 @@ var init_kernel_streams = __esm({
|
|
|
1007
1039
|
O_NONBLOCK = 2048;
|
|
1008
1040
|
SOCKET_MODE = 49663;
|
|
1009
1041
|
PTY_PATH = /^\/dev\/(?:ptmx|pts\/(\d+))$/;
|
|
1042
|
+
TTY_PATH = /^\/dev\/tty\d+$/;
|
|
1010
1043
|
O_CREAT = 64;
|
|
1011
1044
|
O_EXCL = 128;
|
|
1012
1045
|
O_NOCTTY = 256;
|
|
@@ -1074,9 +1107,16 @@ var init_kernel_streams = __esm({
|
|
|
1074
1107
|
}
|
|
1075
1108
|
nameStream(stream, name) {
|
|
1076
1109
|
stream.path = name;
|
|
1110
|
+
this.ttyNode(name);
|
|
1077
1111
|
if (typeof this.Fs.stat !== "function") return;
|
|
1078
1112
|
stream.stream_ops = { ...stream.stream_ops, getattr: () => this.Fs.stat?.(name) ?? {} };
|
|
1079
1113
|
}
|
|
1114
|
+
ttyNode(name) {
|
|
1115
|
+
const { analyzePath, mkdev, makedev } = this.Fs;
|
|
1116
|
+
if (!TTY_PATH.test(name) || !analyzePath || !mkdev || !makedev) return;
|
|
1117
|
+
if (!analyzePath.call(this.Fs, name).exists)
|
|
1118
|
+
mkdev.call(this.Fs, name, makedev.call(this.Fs, 6, 0));
|
|
1119
|
+
}
|
|
1080
1120
|
ttyOps(kfd) {
|
|
1081
1121
|
return {
|
|
1082
1122
|
ops: {
|
|
@@ -1870,7 +1910,34 @@ function useDevFd(Fs) {
|
|
|
1870
1910
|
return fstat.call(Fs, fd);
|
|
1871
1911
|
};
|
|
1872
1912
|
}
|
|
1873
|
-
|
|
1913
|
+
function mountTable() {
|
|
1914
|
+
const root = globalThis.navigator?.storage ? "opfs" : "memory";
|
|
1915
|
+
return [`${root} / ${root} rw 0 0`, "devfs /dev devfs rw 0 0", "proc /proc proc rw 0 0", ""].join(
|
|
1916
|
+
"\n"
|
|
1917
|
+
);
|
|
1918
|
+
}
|
|
1919
|
+
function useMounts(Fs) {
|
|
1920
|
+
const { writeFile } = Fs;
|
|
1921
|
+
if (typeof Fs.open !== "function" || typeof writeFile !== "function") return;
|
|
1922
|
+
try {
|
|
1923
|
+
writeFile.call(Fs, "/proc/mounts", mountTable());
|
|
1924
|
+
} catch {
|
|
1925
|
+
return;
|
|
1926
|
+
}
|
|
1927
|
+
const open = Fs.open.bind(Fs);
|
|
1928
|
+
Fs.open = (path, flags, mode) => {
|
|
1929
|
+
if (path !== "/etc/mtab" || (flags & (O_ACCMODE | O_CREAT2)) !== 0) {
|
|
1930
|
+
return open(path, flags, mode);
|
|
1931
|
+
}
|
|
1932
|
+
try {
|
|
1933
|
+
return open(path, flags, mode);
|
|
1934
|
+
} catch (e) {
|
|
1935
|
+
if (e?.errno !== wasiErrno("ENOENT")) throw e;
|
|
1936
|
+
return open("/proc/mounts", flags, mode);
|
|
1937
|
+
}
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1940
|
+
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, DIR_MODE, LINK_MODE, O_ACCMODE, O_CREAT2;
|
|
1874
1941
|
var init_process_fds = __esm({
|
|
1875
1942
|
"src/process/process-fds.ts"() {
|
|
1876
1943
|
"use strict";
|
|
@@ -1896,6 +1963,8 @@ var init_process_fds = __esm({
|
|
|
1896
1963
|
EBADF = 8;
|
|
1897
1964
|
DIR_MODE = 16749;
|
|
1898
1965
|
LINK_MODE = 41408;
|
|
1966
|
+
O_ACCMODE = 3;
|
|
1967
|
+
O_CREAT2 = 64;
|
|
1899
1968
|
}
|
|
1900
1969
|
});
|
|
1901
1970
|
|
|
@@ -1978,7 +2047,7 @@ function inheritedSlot(fd, stream) {
|
|
|
1978
2047
|
if (stream.sliccKernelFd === void 0) {
|
|
1979
2048
|
const device = stream.path === void 0 ? void 0 : DEVICES[stream.path];
|
|
1980
2049
|
if (!device) return void 0;
|
|
1981
|
-
const access = ACCESS[stream.flags &
|
|
2050
|
+
const access = ACCESS[stream.flags & O_ACCMODE2];
|
|
1982
2051
|
return { fd, device, ...access ? { access } : {} };
|
|
1983
2052
|
}
|
|
1984
2053
|
const flags = stream.sliccKernelSocket ? { flags: stream.flags } : {};
|
|
@@ -1995,7 +2064,7 @@ function placeholder(Fs, streams, entry) {
|
|
|
1995
2064
|
if (entry.kind === "tty") return Fs.open("/dev/tty", O_RDWR);
|
|
1996
2065
|
if (entry.kind === "stream") return Fs.open("/dev/null", O_RDWR);
|
|
1997
2066
|
Fs.mkdirTree(PLACEHOLDER_DIR);
|
|
1998
|
-
return Fs.open(`${PLACEHOLDER_DIR}/${entry.fd}`, O_RDWR |
|
|
2067
|
+
return Fs.open(`${PLACEHOLDER_DIR}/${entry.fd}`, O_RDWR | O_CREAT3);
|
|
1999
2068
|
}
|
|
2000
2069
|
function asFifo(stream, streams, identity) {
|
|
2001
2070
|
const inos = streamInos.get(streams) ?? /* @__PURE__ */ new Map();
|
|
@@ -2029,7 +2098,7 @@ function restoreForkedStreams(Fs, streams, table) {
|
|
|
2029
2098
|
} else {
|
|
2030
2099
|
const placed = place(
|
|
2031
2100
|
Fs,
|
|
2032
|
-
Fs.open(entry.path, entry.flags & ~(
|
|
2101
|
+
Fs.open(entry.path, entry.flags & ~(O_CREAT3 | O_EXCL2 | O_TRUNC2)),
|
|
2033
2102
|
entry.fd
|
|
2034
2103
|
);
|
|
2035
2104
|
setCloseOnExec(placed, (entry.flags & O_CLOEXEC) !== 0);
|
|
@@ -2038,14 +2107,14 @@ function restoreForkedStreams(Fs, streams, table) {
|
|
|
2038
2107
|
}
|
|
2039
2108
|
}
|
|
2040
2109
|
}
|
|
2041
|
-
var O_RDWR,
|
|
2110
|
+
var O_RDWR, O_ACCMODE2, O_CREAT3, O_EXCL2, O_TRUNC2, PLACEHOLDER_DIR, ACCESS, DEVICES, FIFO_MODE, nextStreamIno, streamInos;
|
|
2042
2111
|
var init_process_fork = __esm({
|
|
2043
2112
|
"src/process/process-fork.ts"() {
|
|
2044
2113
|
"use strict";
|
|
2045
2114
|
init_process_fds();
|
|
2046
2115
|
O_RDWR = 2;
|
|
2047
|
-
|
|
2048
|
-
|
|
2116
|
+
O_ACCMODE2 = 3;
|
|
2117
|
+
O_CREAT3 = 64;
|
|
2049
2118
|
O_EXCL2 = 128;
|
|
2050
2119
|
O_TRUNC2 = 512;
|
|
2051
2120
|
PLACEHOLDER_DIR = "/dev/slicc-fd";
|
|
@@ -2189,7 +2258,7 @@ function socketNode(Fs, addr) {
|
|
|
2189
2258
|
const fs = Fs;
|
|
2190
2259
|
let stream;
|
|
2191
2260
|
try {
|
|
2192
|
-
stream = Fs.open(addr.path, O_WRONLY |
|
|
2261
|
+
stream = Fs.open(addr.path, O_WRONLY | O_CREAT4 | O_EXCL3, 493);
|
|
2193
2262
|
} catch (e) {
|
|
2194
2263
|
if (e?.errno === wasiErrno("EEXIST")) {
|
|
2195
2264
|
throw new SyscallError("EADDRINUSE");
|
|
@@ -2320,7 +2389,7 @@ function createSocketKernel(deps) {
|
|
|
2320
2389
|
})
|
|
2321
2390
|
};
|
|
2322
2391
|
}
|
|
2323
|
-
var O_RDWR2, KILLED_BY_SIGPIPE2, O_WRONLY,
|
|
2392
|
+
var O_RDWR2, KILLED_BY_SIGPIPE2, O_WRONLY, O_CREAT4, O_EXCL3;
|
|
2324
2393
|
var init_process_sockets = __esm({
|
|
2325
2394
|
"src/process/process-sockets.ts"() {
|
|
2326
2395
|
"use strict";
|
|
@@ -2331,7 +2400,7 @@ var init_process_sockets = __esm({
|
|
|
2331
2400
|
O_RDWR2 = 2;
|
|
2332
2401
|
KILLED_BY_SIGPIPE2 = 128 + 13;
|
|
2333
2402
|
O_WRONLY = 1;
|
|
2334
|
-
|
|
2403
|
+
O_CREAT4 = 64;
|
|
2335
2404
|
O_EXCL3 = 128;
|
|
2336
2405
|
}
|
|
2337
2406
|
});
|
|
@@ -2610,6 +2679,7 @@ async function runWasmProcess(init, port2, deps = {}) {
|
|
|
2610
2679
|
if (pipefs) streams.usePipes(pipefs);
|
|
2611
2680
|
streams.useControllingTerminal();
|
|
2612
2681
|
useDevFd(running.FS);
|
|
2682
|
+
useMounts(running.FS);
|
|
2613
2683
|
ownByRealmUser(running.FS);
|
|
2614
2684
|
const livePath = (s) => liveNodePath(s.node);
|
|
2615
2685
|
running.sliccKernel = createProcessKernel({
|