@ai-ecoverse/slicc-kernel 1.125.0 → 1.125.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/README.md +12 -3
- package/dist/kernel-worker.js +219 -81
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +130 -66
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +222 -84
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +130 -66
- package/dist/process-worker.js.map +3 -3
- package/dist/types/kernel/net/tls-chain.d.ts +2 -0
- package/dist/types/kernel/net/tls-client.d.ts +1 -0
- package/dist/types/kernel/net/tls-engine.d.ts +2 -1
- package/dist/types/kernel/net/tls-uplink.d.ts +1 -0
- package/dist/types/process/js/js-net.d.ts +1 -0
- package/dist/types/process/js/js-sync.d.ts +2 -1
- package/dist/types/process/wasi/wasi-fds.d.ts +3 -0
- package/dist/types/realm/sync-fs-token-registry.d.ts +3 -0
- package/dist/types/realm/sync-fs-wire.d.ts +7 -1
- package/dist/types/realm/sync-sab-bridge.d.ts +1 -0
- package/package.json +2 -2
package/dist/process-worker.js
CHANGED
|
@@ -135,7 +135,8 @@ function decodeSabResult(status2, payload) {
|
|
|
135
135
|
try {
|
|
136
136
|
const parsed = JSON.parse(decoder.decode(payload));
|
|
137
137
|
const errno2 = typeof parsed.errno === "string" && /^E[A-Z]+$|^EAI_[A-Z]+$/.test(parsed.errno) ? parsed.errno : "EIO";
|
|
138
|
-
|
|
138
|
+
const message2 = String(parsed.message ?? errno2);
|
|
139
|
+
return parsed.direct === true ? { ok: false, errno: errno2, message: message2, direct: true } : { ok: false, errno: errno2, message: message2 };
|
|
139
140
|
} catch {
|
|
140
141
|
return { ok: false, errno: "EIO", message: "sync-sab: malformed errno payload" };
|
|
141
142
|
}
|
|
@@ -973,7 +974,7 @@ function parseSyncFsStat(json2) {
|
|
|
973
974
|
...typeof s.gid === "number" ? { gid: s.gid } : {}
|
|
974
975
|
};
|
|
975
976
|
}
|
|
976
|
-
var SYNC_FS_OPS, HOLD_READ, HOLD_WRITE, HOLD_CREATED, SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
977
|
+
var SYNC_FS_OPS, HOLD_READ, HOLD_WRITE, HOLD_CREATED, SYNC_FS_REQUEST_TIMEOUT_MS, SYNC_FS_READ_ONLY;
|
|
977
978
|
var init_sync_fs_wire = __esm({
|
|
978
979
|
"src/realm/sync-fs-wire.ts"() {
|
|
979
980
|
"use strict";
|
|
@@ -1013,6 +1014,19 @@ var init_sync_fs_wire = __esm({
|
|
|
1013
1014
|
HOLD_WRITE = 8;
|
|
1014
1015
|
HOLD_CREATED = 16;
|
|
1015
1016
|
SYNC_FS_REQUEST_TIMEOUT_MS = 25e3;
|
|
1017
|
+
SYNC_FS_READ_ONLY = /* @__PURE__ */ new Set([
|
|
1018
|
+
"read",
|
|
1019
|
+
"pread",
|
|
1020
|
+
"exists",
|
|
1021
|
+
"stat",
|
|
1022
|
+
"lstat",
|
|
1023
|
+
"readdir",
|
|
1024
|
+
"readdir-stat",
|
|
1025
|
+
"readlink",
|
|
1026
|
+
"statfs",
|
|
1027
|
+
"kept",
|
|
1028
|
+
"access"
|
|
1029
|
+
]);
|
|
1016
1030
|
}
|
|
1017
1031
|
});
|
|
1018
1032
|
|
|
@@ -1167,19 +1181,21 @@ function createSyncSabTransport(sab, port2, deps = {}) {
|
|
|
1167
1181
|
}
|
|
1168
1182
|
};
|
|
1169
1183
|
}
|
|
1170
|
-
function errnoError(code2, path) {
|
|
1171
|
-
|
|
1184
|
+
function errnoError(code2, path, direct) {
|
|
1185
|
+
const err = syncError(code2, `sync-sab bridge, '${path}'`);
|
|
1186
|
+
return direct ? Object.assign(err, { direct }) : err;
|
|
1172
1187
|
}
|
|
1173
1188
|
function createSyncFsSabBridge(transport, opts = {}) {
|
|
1189
|
+
const direct = opts.direct ? { direct: true } : {};
|
|
1174
1190
|
const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
1175
1191
|
let identity = {};
|
|
1176
1192
|
let once = false;
|
|
1177
1193
|
let last = null;
|
|
1178
1194
|
function run(req, path, transfer) {
|
|
1179
1195
|
last = null;
|
|
1180
|
-
const silence =
|
|
1196
|
+
const silence = SYNC_FS_READ_ONLY.has(req.op) ? timeoutMs2 : Number.POSITIVE_INFINITY;
|
|
1181
1197
|
const result = transport.call(req, silence, `sync-sab bridge, '${path}'`, transfer);
|
|
1182
|
-
if (!result.ok) throw errnoError(result.errno, path);
|
|
1198
|
+
if (!result.ok) throw errnoError(result.errno, path, result.direct);
|
|
1183
1199
|
return result;
|
|
1184
1200
|
}
|
|
1185
1201
|
function bytes(req, path) {
|
|
@@ -1225,12 +1241,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1225
1241
|
return s;
|
|
1226
1242
|
},
|
|
1227
1243
|
stat: (path) => {
|
|
1228
|
-
const s = parseSyncFsStat(json2({ op: "stat", path }, path));
|
|
1244
|
+
const s = parseSyncFsStat(json2({ op: "stat", path, ...direct }, path));
|
|
1229
1245
|
if (!s) throw errnoError("EIO", path);
|
|
1230
1246
|
return s;
|
|
1231
1247
|
},
|
|
1232
1248
|
lstat: (path) => {
|
|
1233
|
-
const s = parseSyncFsStat(json2({ op: "lstat", path }, path));
|
|
1249
|
+
const s = parseSyncFsStat(json2({ op: "lstat", path, ...direct }, path));
|
|
1234
1250
|
if (!s) throw errnoError("EIO", path);
|
|
1235
1251
|
return s;
|
|
1236
1252
|
},
|
|
@@ -1308,7 +1324,12 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1308
1324
|
},
|
|
1309
1325
|
create: (path, mode, opening2) => {
|
|
1310
1326
|
const flags = { ...mode !== void 0 ? { mode } : {}, ...opening2 ? { opening: opening2 } : {} };
|
|
1311
|
-
run({ op: "create", path, ...flags }, path);
|
|
1327
|
+
const r = run({ op: "create", path, ...flags, identity: true }, path);
|
|
1328
|
+
if (!r.ok || r.kind !== "json") return void 0;
|
|
1329
|
+
const st = parseSyncFsStat(r.json);
|
|
1330
|
+
if (!st) return void 0;
|
|
1331
|
+
const { seen } = r.json;
|
|
1332
|
+
return typeof seen === "number" ? { ...st, seen } : st;
|
|
1312
1333
|
},
|
|
1313
1334
|
chown: (path, uid, gid, follow3, handle) => {
|
|
1314
1335
|
const ids = { ...uid !== void 0 ? { uid } : {}, ...gid !== void 0 ? { gid } : {} };
|
|
@@ -1340,7 +1361,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1340
1361
|
statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
|
|
1341
1362
|
};
|
|
1342
1363
|
}
|
|
1343
|
-
var PATH_OPS,
|
|
1364
|
+
var PATH_OPS, calls, looks, SPIN_MS, SPIN_STRIDE, SPIN_STRIDES, SPIN_CORES, spinning, SPIN_CAP_MS;
|
|
1344
1365
|
var init_sync_sab_bridge = __esm({
|
|
1345
1366
|
"src/realm/sync-sab-bridge.ts"() {
|
|
1346
1367
|
"use strict";
|
|
@@ -1349,19 +1370,6 @@ var init_sync_sab_bridge = __esm({
|
|
|
1349
1370
|
init_sync_fs_wire();
|
|
1350
1371
|
init_sync_sab_wire();
|
|
1351
1372
|
PATH_OPS = new Set(SYNC_FS_OPS);
|
|
1352
|
-
READ_ONLY = /* @__PURE__ */ new Set([
|
|
1353
|
-
"read",
|
|
1354
|
-
"pread",
|
|
1355
|
-
"exists",
|
|
1356
|
-
"stat",
|
|
1357
|
-
"lstat",
|
|
1358
|
-
"readdir",
|
|
1359
|
-
"readdir-stat",
|
|
1360
|
-
"readlink",
|
|
1361
|
-
"statfs",
|
|
1362
|
-
"kept",
|
|
1363
|
-
"access"
|
|
1364
|
-
]);
|
|
1365
1373
|
calls = 0;
|
|
1366
1374
|
looks = 0;
|
|
1367
1375
|
SPIN_MS = 0.06;
|
|
@@ -2647,7 +2655,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2647
2655
|
var init_version = __esm({
|
|
2648
2656
|
"src/version.ts"() {
|
|
2649
2657
|
"use strict";
|
|
2650
|
-
KERNEL_VERSION = true ? "1.125.
|
|
2658
|
+
KERNEL_VERSION = true ? "1.125.2" : "0.0.0-dev";
|
|
2651
2659
|
OS_RELEASE = "6.0.0-slicc";
|
|
2652
2660
|
}
|
|
2653
2661
|
});
|
|
@@ -5590,15 +5598,15 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
5590
5598
|
};
|
|
5591
5599
|
const track = (stream, names) => {
|
|
5592
5600
|
let current = names;
|
|
5593
|
-
const
|
|
5594
|
-
|
|
5601
|
+
const remember2 = (list) => scans.set(stream, new Set(list.filter((n) => /^[1-9]\d*$/.test(n)).map(Number)));
|
|
5602
|
+
remember2(current ?? []);
|
|
5595
5603
|
Object.defineProperty(stream, "getdents", {
|
|
5596
5604
|
configurable: true,
|
|
5597
5605
|
enumerable: true,
|
|
5598
5606
|
get: () => current,
|
|
5599
5607
|
set: (next2) => {
|
|
5600
5608
|
current = next2;
|
|
5601
|
-
if (next2)
|
|
5609
|
+
if (next2) remember2(next2);
|
|
5602
5610
|
}
|
|
5603
5611
|
});
|
|
5604
5612
|
};
|
|
@@ -6617,6 +6625,17 @@ function index(map, key, path) {
|
|
|
6617
6625
|
paths.add(path);
|
|
6618
6626
|
map.set(key, paths);
|
|
6619
6627
|
}
|
|
6628
|
+
function goneAbove(maps, live, path) {
|
|
6629
|
+
for (let at = path.lastIndexOf("/"); at > 0; at = path.lastIndexOf("/", at - 1)) {
|
|
6630
|
+
const up = path.slice(0, at);
|
|
6631
|
+
for (const map of maps) {
|
|
6632
|
+
const hit = map.get(up);
|
|
6633
|
+
const code2 = hit && "until" in hit ? hit.error.code : void 0;
|
|
6634
|
+
if (hit && "until" in hit && code2 === "ENOENT" && live(hit, up)) return hit;
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
return void 0;
|
|
6638
|
+
}
|
|
6620
6639
|
function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
6621
6640
|
const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
|
|
6622
6641
|
const cache = new StatCache(blind ? void 0 : shared);
|
|
@@ -6624,17 +6643,8 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
6624
6643
|
const view = bridge.changes;
|
|
6625
6644
|
const live = (miss, path) => miss.until > now() && (view === void 0 || miss.gen === void 0 || !view.changedSince(miss.gen, path).changed);
|
|
6626
6645
|
const seen = new SeenAt(view, lstats);
|
|
6627
|
-
const
|
|
6628
|
-
|
|
6629
|
-
const up = path.slice(0, at);
|
|
6630
|
-
for (const map of [lstats, stats]) {
|
|
6631
|
-
const hit = map.get(up);
|
|
6632
|
-
const code2 = hit && "until" in hit ? hit.error.code : void 0;
|
|
6633
|
-
if (hit && "until" in hit && code2 === "ENOENT" && live(hit, up)) return hit;
|
|
6634
|
-
}
|
|
6635
|
-
}
|
|
6636
|
-
return void 0;
|
|
6637
|
-
};
|
|
6646
|
+
const kept = remember(cache, seen, blind);
|
|
6647
|
+
const gone = (path) => goneAbove([lstats, stats], live, path);
|
|
6638
6648
|
const cached = (map, path, get) => {
|
|
6639
6649
|
if (blind || view?.foreign()) return get();
|
|
6640
6650
|
cache.fresh();
|
|
@@ -6760,7 +6770,10 @@ function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
|
6760
6770
|
...bridge.keptStat ? { keptStat: bridge.keptStat.bind(bridge) } : {},
|
|
6761
6771
|
...bridge.pinned ? { pinned: (handle) => pinnedIo2(bridge, handle, rewriting) } : {},
|
|
6762
6772
|
...bridge.create ? {
|
|
6763
|
-
create: (p, mode, opening2) =>
|
|
6773
|
+
create: (p, mode, opening2) => kept(
|
|
6774
|
+
p,
|
|
6775
|
+
mutating(() => bridge.create?.(p, mode, opening2), ...entry(p))
|
|
6776
|
+
)
|
|
6764
6777
|
} : {},
|
|
6765
6778
|
...bridge.mkfifo ? {
|
|
6766
6779
|
mkfifo: (p, mode) => mutating(() => bridge.mkfifo?.(p, mode), ...entry(p))
|
|
@@ -6797,7 +6810,7 @@ function pinnedIo2(bridge, handle, rewriting) {
|
|
|
6797
6810
|
} : {}
|
|
6798
6811
|
};
|
|
6799
6812
|
}
|
|
6800
|
-
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt;
|
|
6813
|
+
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache, SEEN_CAP, SeenAt, remember;
|
|
6801
6814
|
var init_wasi_files = __esm({
|
|
6802
6815
|
"src/process/wasi/wasi-files.ts"() {
|
|
6803
6816
|
"use strict";
|
|
@@ -7187,6 +7200,13 @@ var init_wasi_files = __esm({
|
|
|
7187
7200
|
return since.changed;
|
|
7188
7201
|
}
|
|
7189
7202
|
};
|
|
7203
|
+
remember = (cache, seen, blind) => (path, made) => {
|
|
7204
|
+
if (!made || blind) return made;
|
|
7205
|
+
const { seen: at, ...st } = made;
|
|
7206
|
+
cache.put(cache.stats, path, st);
|
|
7207
|
+
if (at !== void 0) seen.saw(cache.stats, path, at);
|
|
7208
|
+
return made;
|
|
7209
|
+
};
|
|
7190
7210
|
}
|
|
7191
7211
|
});
|
|
7192
7212
|
|
|
@@ -8847,6 +8867,8 @@ var init_wasi_fds = __esm({
|
|
|
8847
8867
|
return openDevice2.call(this.kernel.sys, flags);
|
|
8848
8868
|
}
|
|
8849
8869
|
open(path, oflags, rights, fdflags, mode) {
|
|
8870
|
+
this.made = void 0;
|
|
8871
|
+
this.created = false;
|
|
8850
8872
|
const device2 = deviceOf(path);
|
|
8851
8873
|
if (device2) return this.install({ type: "device", device: device2 });
|
|
8852
8874
|
const kernelDevice = this.openKernelDevice(path, oflags, fdflags, rights);
|
|
@@ -8854,8 +8876,8 @@ var init_wasi_fds = __esm({
|
|
|
8854
8876
|
const alias = stdioAlias(path);
|
|
8855
8877
|
if (alias !== void 0) return this.reopen(alias);
|
|
8856
8878
|
const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
|
|
8857
|
-
if (exclusive &&
|
|
8858
|
-
return this.
|
|
8879
|
+
if (exclusive && !(oflags & OFLAGS.DIRECTORY) && this.madeAtOnce(path, mode)) {
|
|
8880
|
+
return this.regular(path, void 0, oflags, rights, fdflags, mode, true);
|
|
8859
8881
|
}
|
|
8860
8882
|
if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
|
|
8861
8883
|
const s = this.statOrMissing(path);
|
|
@@ -8872,15 +8894,15 @@ var init_wasi_fds = __esm({
|
|
|
8872
8894
|
refuseWrite(s, oflags, rights);
|
|
8873
8895
|
return this.regular(path, s, oflags, rights, fdflags, mode);
|
|
8874
8896
|
}
|
|
8875
|
-
regular(path, s, oflags, rights, fdflags, mode) {
|
|
8897
|
+
regular(path, s, oflags, rights, fdflags, mode, created = false) {
|
|
8876
8898
|
if (s?.isFifo) return this.kernelFifo(path, s, oflags, rights, fdflags);
|
|
8877
8899
|
if (s?.isSocket) throw new WasiError("ENXIO");
|
|
8878
8900
|
if (this.shared || this.kernelHolds(path, s)) {
|
|
8879
|
-
return this.kernelFile(path, s, oflags, rights, fdflags, mode);
|
|
8901
|
+
return this.kernelFile(path, s, oflags, rights, fdflags, mode, created);
|
|
8880
8902
|
}
|
|
8881
8903
|
return this.install({
|
|
8882
8904
|
type: "file",
|
|
8883
|
-
file: this.file(path, s, oflags, rights, fdflags, mode)
|
|
8905
|
+
file: this.file(path, s, oflags, rights, fdflags, mode, created)
|
|
8884
8906
|
});
|
|
8885
8907
|
}
|
|
8886
8908
|
kernelHolds(path, st) {
|
|
@@ -8903,9 +8925,9 @@ var init_wasi_fds = __esm({
|
|
|
8903
8925
|
} catch {
|
|
8904
8926
|
}
|
|
8905
8927
|
}
|
|
8906
|
-
file(path, existing, oflags, rights, fdflags, mode) {
|
|
8928
|
+
file(path, existing, oflags, rights, fdflags, mode, created = false) {
|
|
8907
8929
|
const { readable: readable3, writable: writable2 } = openAccess(existing, oflags, rights);
|
|
8908
|
-
let buffer = this.buffers.get(path);
|
|
8930
|
+
let buffer = created ? void 0 : this.buffers.get(path);
|
|
8909
8931
|
if (buffer?.handle !== void 0 && this.fs.kept?.(buffer.handle)) {
|
|
8910
8932
|
this.buffers.delete(path);
|
|
8911
8933
|
buffer = void 0;
|
|
@@ -8916,19 +8938,21 @@ var init_wasi_fds = __esm({
|
|
|
8916
8938
|
if (this.fs.owners) this.fs.access?.(path, want, "open");
|
|
8917
8939
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
8918
8940
|
} else {
|
|
8919
|
-
buffer = this.freshBuffer(path, existing, oflags, want, mode);
|
|
8941
|
+
buffer = this.freshBuffer(path, existing, oflags, want, mode, created);
|
|
8920
8942
|
}
|
|
8921
8943
|
buffer.opens++;
|
|
8922
8944
|
const file = new LocalFile(buffer, readable3, writable2, (fdflags & FDFLAGS.APPEND) !== 0);
|
|
8923
8945
|
file.ino = existing?.ino;
|
|
8924
8946
|
return file;
|
|
8925
8947
|
}
|
|
8926
|
-
freshBuffer(path, existing, oflags, want, mode) {
|
|
8927
|
-
const made = !existing && this.createNew(path, oflags, mode);
|
|
8948
|
+
freshBuffer(path, existing, oflags, want, mode, created = false) {
|
|
8949
|
+
const made = created || !existing && this.createNew(path, oflags, mode);
|
|
8950
|
+
const reply = made ? this.made : void 0;
|
|
8951
|
+
this.made = void 0;
|
|
8928
8952
|
const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
8929
8953
|
if (existing?.ranged) this.fs.invalidate?.();
|
|
8930
|
-
const seen = this.fs.changes?.now();
|
|
8931
|
-
const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
|
|
8954
|
+
const seen = reply ? reply.seen : this.fs.changes?.now();
|
|
8955
|
+
const st = reply?.st ?? (existing?.ranged || !existing ? this.fs.stat(path) : existing);
|
|
8932
8956
|
const ranged = st.ranged ? st.size : void 0;
|
|
8933
8957
|
const asked = (want & 4 ? HOLD_READ : 0) | (want & 2 ? HOLD_WRITE : 0) | (made ? HOLD_CREATED : 0);
|
|
8934
8958
|
const handle = this.fs.hold?.(path, true, true, void 0, this.fs.owners ? asked : 0, {
|
|
@@ -8995,10 +9019,17 @@ var init_wasi_fds = __esm({
|
|
|
8995
9019
|
}
|
|
8996
9020
|
}
|
|
8997
9021
|
}
|
|
9022
|
+
created = false;
|
|
9023
|
+
made;
|
|
9024
|
+
creating(path, mode) {
|
|
9025
|
+
const st = this.fs.create?.(path, mode, true);
|
|
9026
|
+
this.made = st ? { st, seen: st.seen } : void 0;
|
|
9027
|
+
this.created = true;
|
|
9028
|
+
}
|
|
8998
9029
|
madeAtOnce(path, mode) {
|
|
8999
9030
|
if (!this.fs.create) return false;
|
|
9000
9031
|
try {
|
|
9001
|
-
this.
|
|
9032
|
+
this.creating(path, mode);
|
|
9002
9033
|
return true;
|
|
9003
9034
|
} catch (err) {
|
|
9004
9035
|
if (err.code === "EEXIST") throw err;
|
|
@@ -9008,10 +9039,11 @@ var init_wasi_fds = __esm({
|
|
|
9008
9039
|
createNew(path, oflags, mode) {
|
|
9009
9040
|
if (!this.fs.create) {
|
|
9010
9041
|
this.fs.writeFile(path, new Uint8Array(0));
|
|
9042
|
+
this.created = true;
|
|
9011
9043
|
return true;
|
|
9012
9044
|
}
|
|
9013
9045
|
try {
|
|
9014
|
-
this.
|
|
9046
|
+
this.creating(path, mode);
|
|
9015
9047
|
return true;
|
|
9016
9048
|
} catch (err) {
|
|
9017
9049
|
if (oflags & OFLAGS.EXCL || err.code !== "EEXIST") throw err;
|
|
@@ -10577,9 +10609,8 @@ var init_wasi_host = __esm({
|
|
|
10577
10609
|
if (alias && !alias.stdio) this.openFd(alias.fd);
|
|
10578
10610
|
const path = alias && !alias.stdio ? `/dev/fd/${alias.fd}` : asked;
|
|
10579
10611
|
if (deviceOf(path)) this.interrupted?.();
|
|
10580
|
-
const fresh = (oflags & OFLAGS.CREAT) !== 0 && !this.synthetic(path) && !o.fs.exists(path);
|
|
10581
10612
|
mem.view().setUint32(out, fds.open(path, oflags, rights, fdflags), true);
|
|
10582
|
-
if (
|
|
10613
|
+
if (fds.created) this.created(path, 438);
|
|
10583
10614
|
} catch (err) {
|
|
10584
10615
|
if (err.code !== "ENOENT") throw err;
|
|
10585
10616
|
const raw = mem.string(p, l);
|
|
@@ -11830,6 +11861,10 @@ function physicalProc(fs) {
|
|
|
11830
11861
|
return physical2;
|
|
11831
11862
|
};
|
|
11832
11863
|
}
|
|
11864
|
+
function directMiss(err, path) {
|
|
11865
|
+
if (err?.direct !== true) return false;
|
|
11866
|
+
return !path.split("/").some((part) => part === "." || part === "..");
|
|
11867
|
+
}
|
|
11833
11868
|
function procfsBridge(fs, tree) {
|
|
11834
11869
|
const toProc = (path, follow3) => procPath(fs, path, follow3);
|
|
11835
11870
|
const shadowing = physicalProc(fs);
|
|
@@ -11842,6 +11877,7 @@ function procfsBridge(fs, tree) {
|
|
|
11842
11877
|
try {
|
|
11843
11878
|
return own();
|
|
11844
11879
|
} catch (err) {
|
|
11880
|
+
if (directMiss(err, p)) throw err;
|
|
11845
11881
|
const real = toProc(p, follow3);
|
|
11846
11882
|
if (real === void 0) throw err;
|
|
11847
11883
|
return proc(real);
|
|
@@ -11902,7 +11938,12 @@ function procfsBridge(fs, tree) {
|
|
|
11902
11938
|
const real = shadowing() ? probe() : void 0;
|
|
11903
11939
|
if (real === null) return false;
|
|
11904
11940
|
if (real !== void 0) return tree.exists(real);
|
|
11905
|
-
|
|
11941
|
+
try {
|
|
11942
|
+
fs.stat(p);
|
|
11943
|
+
return true;
|
|
11944
|
+
} catch (err) {
|
|
11945
|
+
if (directMiss(err, p)) return false;
|
|
11946
|
+
}
|
|
11906
11947
|
const late2 = probe();
|
|
11907
11948
|
return typeof late2 === "string" && tree.exists(late2);
|
|
11908
11949
|
},
|
|
@@ -14311,7 +14352,7 @@ async function runWasiProcess(init, port2) {
|
|
|
14311
14352
|
kernel: { sys: traced(stats, "kernel", sys), call: call2 },
|
|
14312
14353
|
fs: procfsBridge(
|
|
14313
14354
|
cachingBridge(
|
|
14314
|
-
traced(stats, "fs", createSyncFsSabBridge(transport, ownersOf(init))),
|
|
14355
|
+
traced(stats, "fs", createSyncFsSabBridge(transport, { ...ownersOf(init), direct: true })),
|
|
14315
14356
|
void 0,
|
|
14316
14357
|
threads?.ids
|
|
14317
14358
|
),
|
|
@@ -14416,7 +14457,11 @@ async function runWasiThread(init, port2) {
|
|
|
14416
14457
|
parent: () => identify(transport, init).ppid,
|
|
14417
14458
|
kernel: { sys, call: call2 },
|
|
14418
14459
|
fs: procfsBridge(
|
|
14419
|
-
cachingBridge(
|
|
14460
|
+
cachingBridge(
|
|
14461
|
+
createSyncFsSabBridge(transport, { ...ownersOf(init), direct: true }),
|
|
14462
|
+
void 0,
|
|
14463
|
+
threads.ids
|
|
14464
|
+
),
|
|
14420
14465
|
procTree(call2, id.pid)
|
|
14421
14466
|
),
|
|
14422
14467
|
shared: threads.ids
|
|
@@ -15453,7 +15498,8 @@ function controlsOf(r) {
|
|
|
15453
15498
|
clientCertificate: r.clientCertificate === true,
|
|
15454
15499
|
sni: r.sni !== false,
|
|
15455
15500
|
hostnameChecked: r.hostnameChecked === true,
|
|
15456
|
-
...r.hostnameMatches === void 0 ? {} : { hostnameMatches: r.hostnameMatches }
|
|
15501
|
+
...r.hostnameMatches === void 0 ? {} : { hostnameMatches: r.hostnameMatches },
|
|
15502
|
+
...r.chainError ? { chainError: r.chainError } : {}
|
|
15457
15503
|
};
|
|
15458
15504
|
}
|
|
15459
15505
|
function sessionOf(r) {
|
|
@@ -15479,13 +15525,17 @@ function sessionOf(r) {
|
|
|
15479
15525
|
...controlsOf(r)
|
|
15480
15526
|
});
|
|
15481
15527
|
}
|
|
15528
|
+
function withAlert(err) {
|
|
15529
|
+
const alert = ALERT.exec(err.detail ?? "")?.[1];
|
|
15530
|
+
return alert === void 0 ? err : Object.assign(err, { alert: Number(alert) });
|
|
15531
|
+
}
|
|
15482
15532
|
async function secureCall(call2, what = "connect") {
|
|
15483
15533
|
try {
|
|
15484
15534
|
return await call2();
|
|
15485
15535
|
} catch (err) {
|
|
15486
15536
|
const e = err;
|
|
15487
15537
|
const code2 = e.code === "EPROTO" && e.detail ? TLS_CODE.exec(e.detail)?.[1] : void 0;
|
|
15488
|
-
if (code2) throw new JsCallError(code2, what, e.detail);
|
|
15538
|
+
if (code2) throw withAlert(new JsCallError(code2, what, e.detail));
|
|
15489
15539
|
throw err;
|
|
15490
15540
|
}
|
|
15491
15541
|
}
|
|
@@ -15653,7 +15703,7 @@ function netOps(kernel, io) {
|
|
|
15653
15703
|
}
|
|
15654
15704
|
};
|
|
15655
15705
|
}
|
|
15656
|
-
var PEM, TLS_CODE, SHUT_RD, SHUT_WR, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2;
|
|
15706
|
+
var PEM, TLS_CODE, ALERT, SHUT_RD, SHUT_WR, IPV4, NEVER, SOL_SOCKET2, SO_ERROR2;
|
|
15657
15707
|
var init_js_net = __esm({
|
|
15658
15708
|
"src/process/js/js-net.ts"() {
|
|
15659
15709
|
"use strict";
|
|
@@ -15661,6 +15711,7 @@ var init_js_net = __esm({
|
|
|
15661
15711
|
init_js_kernel();
|
|
15662
15712
|
PEM = /-----BEGIN CERTIFICATE-----([\s\S]*?)-----END CERTIFICATE-----/g;
|
|
15663
15713
|
TLS_CODE = /^([A-Z][A-Z0-9_]+): /;
|
|
15714
|
+
ALERT = / \(alert (\d+)\)$/;
|
|
15664
15715
|
SHUT_RD = 0;
|
|
15665
15716
|
SHUT_WR = 1;
|
|
15666
15717
|
IPV4 = /^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/;
|
|
@@ -15889,10 +15940,22 @@ var init_js_run = __esm({
|
|
|
15889
15940
|
});
|
|
15890
15941
|
|
|
15891
15942
|
// src/process/js/js-sync.ts
|
|
15892
|
-
function laneOf(lane) {
|
|
15943
|
+
function laneOf(lane, silence = SYNC_FS_REQUEST_TIMEOUT_MS, open = createSyncSabTransport) {
|
|
15893
15944
|
if (!lane) return noLane;
|
|
15894
|
-
const transport =
|
|
15895
|
-
return (req) =>
|
|
15945
|
+
const transport = open(lane.sab, lane.port);
|
|
15946
|
+
return (req) => {
|
|
15947
|
+
if (!READ_ONLY.has(req.op)) return transport.call(req, Number.POSITIVE_INFINITY, req.op);
|
|
15948
|
+
try {
|
|
15949
|
+
return transport.call(req, silence, req.op);
|
|
15950
|
+
} catch (err) {
|
|
15951
|
+
const errno2 = err?.code;
|
|
15952
|
+
return {
|
|
15953
|
+
ok: false,
|
|
15954
|
+
errno: typeof errno2 === "string" ? errno2 : "EIO",
|
|
15955
|
+
message: err instanceof Error ? err.message : String(err)
|
|
15956
|
+
};
|
|
15957
|
+
}
|
|
15958
|
+
};
|
|
15896
15959
|
}
|
|
15897
15960
|
function syncOps(kernel, shared) {
|
|
15898
15961
|
const { infos, handles, resolve } = shared;
|
|
@@ -16159,7 +16222,7 @@ function syncPathOps(kernel, resolve, statOf, open, tryDev) {
|
|
|
16159
16222
|
}
|
|
16160
16223
|
};
|
|
16161
16224
|
}
|
|
16162
|
-
var encoder3, noLane, JsSyncKernel;
|
|
16225
|
+
var encoder3, noLane, READ_ONLY, JsSyncKernel;
|
|
16163
16226
|
var init_js_sync = __esm({
|
|
16164
16227
|
"src/process/js/js-sync.ts"() {
|
|
16165
16228
|
"use strict";
|
|
@@ -16173,6 +16236,7 @@ var init_js_sync = __esm({
|
|
|
16173
16236
|
init_js_proc();
|
|
16174
16237
|
encoder3 = new TextEncoder();
|
|
16175
16238
|
noLane = () => ({ ok: false, errno: "ENOSYS", message: "no sync lane" });
|
|
16239
|
+
READ_ONLY = /* @__PURE__ */ new Set([...SYNC_FS_READ_ONLY, "fd-path-flush"]);
|
|
16176
16240
|
JsSyncKernel = class {
|
|
16177
16241
|
lane;
|
|
16178
16242
|
kernel;
|