@ai-ecoverse/slicc-kernel 1.33.0 → 1.34.1
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 +4 -2
- package/dist/kernel-worker.js +61 -29
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +157 -27
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +66 -33
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +157 -27
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -1
package/dist/process-worker.js
CHANGED
|
@@ -594,6 +594,26 @@ function toMs(v) {
|
|
|
594
594
|
}
|
|
595
595
|
function createHelpers(Fs, ops) {
|
|
596
596
|
const bridgeOf = (node) => node.mount.opts.bridge;
|
|
597
|
+
const dirty = /* @__PURE__ */ new Set();
|
|
598
|
+
function markDirty(node) {
|
|
599
|
+
node.live.dirty = true;
|
|
600
|
+
dirty.add(node);
|
|
601
|
+
}
|
|
602
|
+
function flushDirty() {
|
|
603
|
+
for (const node of [...dirty]) {
|
|
604
|
+
const s = node.live;
|
|
605
|
+
if (!s.dirty || s.orphan) {
|
|
606
|
+
dirty.delete(node);
|
|
607
|
+
continue;
|
|
608
|
+
}
|
|
609
|
+
if (!s.ranged && s.len > EARLY_WHOLE_FILE) continue;
|
|
610
|
+
try {
|
|
611
|
+
flushNode(node);
|
|
612
|
+
dirty.delete(node);
|
|
613
|
+
} catch {
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
}
|
|
597
617
|
function call2(fn) {
|
|
598
618
|
try {
|
|
599
619
|
return fn();
|
|
@@ -688,7 +708,7 @@ function createHelpers(Fs, ops) {
|
|
|
688
708
|
const ranged = s.openCount > 0 ? rangedOf(node) : void 0;
|
|
689
709
|
if (ranged) {
|
|
690
710
|
ranged.truncate(size);
|
|
691
|
-
|
|
711
|
+
markDirty(node);
|
|
692
712
|
return;
|
|
693
713
|
}
|
|
694
714
|
if (s.openCount > 0) {
|
|
@@ -697,7 +717,7 @@ function createHelpers(Fs, ops) {
|
|
|
697
717
|
const buf = ensureCapacity(node, size);
|
|
698
718
|
if (size > s.len) buf.fill(0, s.len, size);
|
|
699
719
|
s.len = size;
|
|
700
|
-
|
|
720
|
+
markDirty(node);
|
|
701
721
|
return;
|
|
702
722
|
}
|
|
703
723
|
const path = liveNodePath(node);
|
|
@@ -727,6 +747,8 @@ function createHelpers(Fs, ops) {
|
|
|
727
747
|
ensureCapacity,
|
|
728
748
|
rangedOf,
|
|
729
749
|
flushNode,
|
|
750
|
+
markDirty,
|
|
751
|
+
flushDirty,
|
|
730
752
|
truncate
|
|
731
753
|
};
|
|
732
754
|
}
|
|
@@ -971,7 +993,7 @@ function createStreamOps(h) {
|
|
|
971
993
|
if (ranged) {
|
|
972
994
|
const bytes = new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length);
|
|
973
995
|
h.call(() => ranged.write(position, bytes));
|
|
974
|
-
|
|
996
|
+
h.markDirty(node);
|
|
975
997
|
return length;
|
|
976
998
|
}
|
|
977
999
|
ensureLoaded(node);
|
|
@@ -979,7 +1001,7 @@ function createStreamOps(h) {
|
|
|
979
1001
|
if (position > s.len) buf.fill(0, s.len, position);
|
|
980
1002
|
buf.set(new Uint8Array(buffer.buffer, buffer.byteOffset + offset, length), position);
|
|
981
1003
|
s.len = Math.max(s.len, end);
|
|
982
|
-
|
|
1004
|
+
h.markDirty(node);
|
|
983
1005
|
return length;
|
|
984
1006
|
},
|
|
985
1007
|
llseek(stream, offset, whence) {
|
|
@@ -1009,6 +1031,7 @@ function createLiveVfsPlugin(Fs) {
|
|
|
1009
1031
|
mounts,
|
|
1010
1032
|
node_ops: nodeOps,
|
|
1011
1033
|
stream_ops: streamOps,
|
|
1034
|
+
flushDirty: () => h.flushDirty(),
|
|
1012
1035
|
mount(mount) {
|
|
1013
1036
|
const st = h.call(() => mount.opts.bridge.stat(mount.opts.root));
|
|
1014
1037
|
if (!st.isDirectory) throw new Fs.ErrnoError(wasiErrno("ENOTDIR"));
|
|
@@ -1173,7 +1196,7 @@ function guardRenames(Fs) {
|
|
|
1173
1196
|
rename(from, to);
|
|
1174
1197
|
};
|
|
1175
1198
|
}
|
|
1176
|
-
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END;
|
|
1199
|
+
var S_IFDIR, S_IFREG, S_IFLNK, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END, EARLY_WHOLE_FILE;
|
|
1177
1200
|
var init_live_vfs_fs = __esm({
|
|
1178
1201
|
"src/realm/live-vfs-fs.ts"() {
|
|
1179
1202
|
"use strict";
|
|
@@ -1188,6 +1211,7 @@ var init_live_vfs_fs = __esm({
|
|
|
1188
1211
|
UMASK = 18;
|
|
1189
1212
|
SEEK_CUR = 1;
|
|
1190
1213
|
SEEK_END = 2;
|
|
1214
|
+
EARLY_WHOLE_FILE = 64 * 1024;
|
|
1191
1215
|
}
|
|
1192
1216
|
});
|
|
1193
1217
|
|
|
@@ -1224,6 +1248,7 @@ function mountVfsIntoEmscripten(Fs, deps) {
|
|
|
1224
1248
|
return {
|
|
1225
1249
|
mounted,
|
|
1226
1250
|
flush: () => flushLiveVfs(Fs, plugin),
|
|
1251
|
+
flushDirty: () => plugin.flushDirty(),
|
|
1227
1252
|
invalidate: () => invalidateLiveVfs(Fs, plugin)
|
|
1228
1253
|
};
|
|
1229
1254
|
}
|
|
@@ -1268,10 +1293,34 @@ function parseSyncFsStat(json) {
|
|
|
1268
1293
|
...typeof s.version === "string" ? { version: s.version } : {}
|
|
1269
1294
|
};
|
|
1270
1295
|
}
|
|
1271
|
-
var SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
1296
|
+
var SYNC_FS_OPS, SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
1272
1297
|
var init_sync_fs_wire = __esm({
|
|
1273
1298
|
"src/realm/sync-fs-wire.ts"() {
|
|
1274
1299
|
"use strict";
|
|
1300
|
+
SYNC_FS_OPS = [
|
|
1301
|
+
"read",
|
|
1302
|
+
"write",
|
|
1303
|
+
"exists",
|
|
1304
|
+
"stat",
|
|
1305
|
+
"lstat",
|
|
1306
|
+
"readdir",
|
|
1307
|
+
"readdir-stat",
|
|
1308
|
+
"mkdir",
|
|
1309
|
+
"rm",
|
|
1310
|
+
"rename",
|
|
1311
|
+
"unlink",
|
|
1312
|
+
"rmdir",
|
|
1313
|
+
"symlink",
|
|
1314
|
+
"readlink",
|
|
1315
|
+
"chmod",
|
|
1316
|
+
"utimes",
|
|
1317
|
+
"lutimes",
|
|
1318
|
+
"statfs",
|
|
1319
|
+
"hold",
|
|
1320
|
+
"pread",
|
|
1321
|
+
"pwrite",
|
|
1322
|
+
"truncate"
|
|
1323
|
+
];
|
|
1275
1324
|
SYNC_FS_REQUEST_TIMEOUT_MS = 25e3;
|
|
1276
1325
|
}
|
|
1277
1326
|
});
|
|
@@ -2216,6 +2265,47 @@ function positionalIo(imports, deps) {
|
|
|
2216
2265
|
}
|
|
2217
2266
|
}
|
|
2218
2267
|
}
|
|
2268
|
+
function staging(Fs, length) {
|
|
2269
|
+
try {
|
|
2270
|
+
return new Uint8Array(length);
|
|
2271
|
+
} catch {
|
|
2272
|
+
throw new Fs.ErrnoError(wasiErrno("ENOMEM"));
|
|
2273
|
+
}
|
|
2274
|
+
}
|
|
2275
|
+
function useFileMmap(Fs, deps) {
|
|
2276
|
+
const fs = Fs;
|
|
2277
|
+
const mmap = fs.mmap;
|
|
2278
|
+
if (typeof mmap !== "function") return;
|
|
2279
|
+
fs.mmap = (stream, length, position, prot, flags) => {
|
|
2280
|
+
const memalign = deps.memalign();
|
|
2281
|
+
const memory = deps.memory();
|
|
2282
|
+
const shared = (flags & MAP_TYPE) !== MAP_PRIVATE && (prot & PROT_WRITE) !== 0;
|
|
2283
|
+
const kfd = stream.sliccKernelFile ? stream.sliccKernelFd : void 0;
|
|
2284
|
+
if (shared && kfd !== void 0) throw new Fs.ErrnoError(wasiErrno("ENODEV"));
|
|
2285
|
+
if (stream.stream_ops.mmap && kfd === void 0 || !memalign || !memory || length <= 0 || shared || (stream.flags & O_ACCMODE) === O_WRONLY || !Fs.isFile(stream.node.mode)) {
|
|
2286
|
+
return mmap.call(fs, stream, length, position, prot, flags);
|
|
2287
|
+
}
|
|
2288
|
+
const data = staging(Fs, length);
|
|
2289
|
+
let done = 0;
|
|
2290
|
+
try {
|
|
2291
|
+
if (kfd !== void 0) done = readInto(deps.sys, kfd, data, position);
|
|
2292
|
+
else {
|
|
2293
|
+
for (let got = 1; done < length && got > 0; done += got) {
|
|
2294
|
+
got = Fs.read(stream, data, done, length - done, position + done);
|
|
2295
|
+
}
|
|
2296
|
+
}
|
|
2297
|
+
} catch (err) {
|
|
2298
|
+
throw new Fs.ErrnoError(errnoOf(err));
|
|
2299
|
+
}
|
|
2300
|
+
const size = Math.ceil(length / MAP_ALIGN) * MAP_ALIGN;
|
|
2301
|
+
const ptr = memalign(MAP_ALIGN, size);
|
|
2302
|
+
if (!ptr) throw new Fs.ErrnoError(wasiErrno("ENOMEM"));
|
|
2303
|
+
const target = new Uint8Array(memory.buffer, ptr, size);
|
|
2304
|
+
target.fill(0);
|
|
2305
|
+
target.set(data.subarray(0, done));
|
|
2306
|
+
return { ptr, allocated: true };
|
|
2307
|
+
};
|
|
2308
|
+
}
|
|
2219
2309
|
function wasmMemory(instance, imports) {
|
|
2220
2310
|
const isMemory = (v) => v instanceof WebAssembly.Memory;
|
|
2221
2311
|
const exported = Object.values(instance.exports).find(isMemory);
|
|
@@ -2412,7 +2502,7 @@ function useMounts(Fs, env = {}, live = false) {
|
|
|
2412
2502
|
}
|
|
2413
2503
|
};
|
|
2414
2504
|
}
|
|
2415
|
-
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE, O_CREAT2, field, NAME;
|
|
2505
|
+
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE, O_CREAT2, field, NAME;
|
|
2416
2506
|
var init_process_fds = __esm({
|
|
2417
2507
|
"src/process/process-fds.ts"() {
|
|
2418
2508
|
"use strict";
|
|
@@ -2440,6 +2530,11 @@ var init_process_fds = __esm({
|
|
|
2440
2530
|
AT_SYMLINK_NOFOLLOW = 256;
|
|
2441
2531
|
EMSCRIPTEN_EPERM = 63;
|
|
2442
2532
|
O_PATH = 2097152;
|
|
2533
|
+
PROT_WRITE = 2;
|
|
2534
|
+
MAP_PRIVATE = 2;
|
|
2535
|
+
MAP_TYPE = 15;
|
|
2536
|
+
O_WRONLY = 1;
|
|
2537
|
+
MAP_ALIGN = 65536;
|
|
2443
2538
|
DIR_MODE = 16749;
|
|
2444
2539
|
LINK_MODE = 41408;
|
|
2445
2540
|
CHAR_DEVICE = 8630;
|
|
@@ -2714,7 +2809,6 @@ function createProcessKernel(deps) {
|
|
|
2714
2809
|
if (!stream) return { none: true };
|
|
2715
2810
|
promote?.(stream);
|
|
2716
2811
|
if (stream.sliccKernelFd !== void 0) return { fd: stream.sliccKernelFd };
|
|
2717
|
-
if (stream.path === "/dev/null") return { none: true };
|
|
2718
2812
|
const device = deviceOfStream(stream);
|
|
2719
2813
|
if (device) return device;
|
|
2720
2814
|
return n === 0 ? { input: drain(Fs, stream) } : { capture: true };
|
|
@@ -2929,6 +3023,7 @@ var init_process_signals = __esm({
|
|
|
2929
3023
|
depth = 0;
|
|
2930
3024
|
reporting = false;
|
|
2931
3025
|
unwinding = false;
|
|
3026
|
+
quieted = 0;
|
|
2932
3027
|
raw;
|
|
2933
3028
|
header;
|
|
2934
3029
|
hooks;
|
|
@@ -2973,7 +3068,16 @@ var init_process_signals = __esm({
|
|
|
2973
3068
|
this.reported = { caught, ignored };
|
|
2974
3069
|
this.raw.call({ op: "sig-mask", caught, ignored }, Number.POSITIVE_INFINITY, "sig-mask");
|
|
2975
3070
|
}
|
|
3071
|
+
quiet(fn) {
|
|
3072
|
+
this.quieted++;
|
|
3073
|
+
try {
|
|
3074
|
+
return fn();
|
|
3075
|
+
} finally {
|
|
3076
|
+
this.quieted--;
|
|
3077
|
+
}
|
|
3078
|
+
}
|
|
2976
3079
|
deliver() {
|
|
3080
|
+
if (this.quieted > 0) return;
|
|
2977
3081
|
const killed = Atomics.load(this.header, SAB_I_KILLED);
|
|
2978
3082
|
if (killed !== 0 && !this.unwinding && this.hooks.killed) {
|
|
2979
3083
|
this.unwinding = true;
|
|
@@ -3008,7 +3112,7 @@ function socketNode(Fs, addr) {
|
|
|
3008
3112
|
const fs = Fs;
|
|
3009
3113
|
let stream;
|
|
3010
3114
|
try {
|
|
3011
|
-
stream = Fs.open(addr.path,
|
|
3115
|
+
stream = Fs.open(addr.path, O_WRONLY2 | O_CREAT4 | O_EXCL3, 493);
|
|
3012
3116
|
} catch (e) {
|
|
3013
3117
|
if (e?.errno === wasiErrno("EEXIST")) {
|
|
3014
3118
|
throw new SyscallError("EADDRINUSE");
|
|
@@ -3140,7 +3244,7 @@ function createSocketKernel(deps) {
|
|
|
3140
3244
|
})
|
|
3141
3245
|
};
|
|
3142
3246
|
}
|
|
3143
|
-
var O_RDWR2, KILLED_BY_SIGPIPE2,
|
|
3247
|
+
var O_RDWR2, KILLED_BY_SIGPIPE2, O_WRONLY2, O_CREAT4, O_EXCL3;
|
|
3144
3248
|
var init_process_sockets = __esm({
|
|
3145
3249
|
"src/process/process-sockets.ts"() {
|
|
3146
3250
|
"use strict";
|
|
@@ -3150,7 +3254,7 @@ var init_process_sockets = __esm({
|
|
|
3150
3254
|
init_wasi_errno();
|
|
3151
3255
|
O_RDWR2 = 2;
|
|
3152
3256
|
KILLED_BY_SIGPIPE2 = 128 + 13;
|
|
3153
|
-
|
|
3257
|
+
O_WRONLY2 = 1;
|
|
3154
3258
|
O_CREAT4 = 64;
|
|
3155
3259
|
O_EXCL3 = 128;
|
|
3156
3260
|
}
|
|
@@ -3562,6 +3666,9 @@ function kernelSys(transport) {
|
|
|
3562
3666
|
kind(fd) {
|
|
3563
3667
|
return json(call2({ op: "fd-info", fd }, `fd-info ${fd}`))?.kind;
|
|
3564
3668
|
},
|
|
3669
|
+
device(fd) {
|
|
3670
|
+
return json(call2({ op: "fd-info", fd }, `fd-info ${fd}`)).meta;
|
|
3671
|
+
},
|
|
3565
3672
|
size(fd) {
|
|
3566
3673
|
return json(call2({ op: "fd-vfs-stat", fd }, `fd-vfs-stat ${fd}`)).size;
|
|
3567
3674
|
},
|
|
@@ -3619,7 +3726,7 @@ function wireKernelFd(Fs, streams, entry) {
|
|
|
3619
3726
|
});
|
|
3620
3727
|
}
|
|
3621
3728
|
function openDevice(Fs, fd, meta) {
|
|
3622
|
-
const flags = meta.access === "read" ? O_RDONLY : meta.access === "write" ?
|
|
3729
|
+
const flags = meta.access === "read" ? O_RDONLY : meta.access === "write" ? O_WRONLY3 : O_RDWR3;
|
|
3623
3730
|
let stream;
|
|
3624
3731
|
try {
|
|
3625
3732
|
stream = Fs.open(`/dev/${meta.device}`, flags);
|
|
@@ -3637,6 +3744,8 @@ function wireKernelStdio(Fs, streams, sys) {
|
|
|
3637
3744
|
const stream = Fs.getStream(fd);
|
|
3638
3745
|
if (!stream) continue;
|
|
3639
3746
|
const kind = sys?.kind?.(fd);
|
|
3747
|
+
const device = kind === "device" ? sys?.device?.(fd) : void 0;
|
|
3748
|
+
if (device && openDevice(Fs, fd, device)) continue;
|
|
3640
3749
|
if (kind && PLACED.has(kind)) {
|
|
3641
3750
|
const { flags } = stream;
|
|
3642
3751
|
Fs.closeStream(fd);
|
|
@@ -3695,7 +3804,15 @@ async function runWasmProcess(init, port, deps = {}) {
|
|
|
3695
3804
|
}
|
|
3696
3805
|
}
|
|
3697
3806
|
);
|
|
3698
|
-
const
|
|
3807
|
+
const gated = signals.transport();
|
|
3808
|
+
let early = () => {
|
|
3809
|
+
};
|
|
3810
|
+
const transport = {
|
|
3811
|
+
call: (req, timeoutMs, label) => {
|
|
3812
|
+
if (!FS_OPS.has(req.op)) early();
|
|
3813
|
+
return gated.call(req, timeoutMs, label);
|
|
3814
|
+
}
|
|
3815
|
+
};
|
|
3699
3816
|
const sys = kernelSys(transport);
|
|
3700
3817
|
const encoder3 = new TextEncoder();
|
|
3701
3818
|
const say = (fd) => (text) => sys.write(fd, encoder3.encode(`${text}
|
|
@@ -3703,6 +3820,7 @@ async function runWasmProcess(init, port, deps = {}) {
|
|
|
3703
3820
|
let ready;
|
|
3704
3821
|
let failed2;
|
|
3705
3822
|
let memory;
|
|
3823
|
+
let exports;
|
|
3706
3824
|
const initialized = new Promise((resolve, reject) => {
|
|
3707
3825
|
ready = resolve;
|
|
3708
3826
|
failed2 = reject;
|
|
@@ -3750,6 +3868,7 @@ async function runWasmProcess(init, port, deps = {}) {
|
|
|
3750
3868
|
return WebAssembly.instantiate(init.program.module, imports);
|
|
3751
3869
|
}).then((instance) => {
|
|
3752
3870
|
memory = wasmMemory(instance, imports);
|
|
3871
|
+
exports = instance.exports;
|
|
3753
3872
|
publishMemory(init.sab, memory?.buffer.byteLength ?? 0);
|
|
3754
3873
|
done(instance, init.program.module);
|
|
3755
3874
|
}, failed2);
|
|
@@ -3779,6 +3898,7 @@ async function runWasmProcess(init, port, deps = {}) {
|
|
|
3779
3898
|
cwd: init.cwd,
|
|
3780
3899
|
warn: deps.warn ?? say(2)
|
|
3781
3900
|
});
|
|
3901
|
+
early = () => signals.quiet(() => vfs.flushDirty());
|
|
3782
3902
|
const sigpipe = () => running.sliccSigpipe?.() === 1;
|
|
3783
3903
|
const restartable = () => signals.restartable();
|
|
3784
3904
|
const streams = new KernelStreams(running.FS, sys, { sigpipe, restartable });
|
|
@@ -3796,6 +3916,11 @@ async function runWasmProcess(init, port, deps = {}) {
|
|
|
3796
3916
|
if (pipefs) streams.usePipes(pipefs);
|
|
3797
3917
|
streams.useControllingTerminal();
|
|
3798
3918
|
useDevFd(running.FS);
|
|
3919
|
+
useFileMmap(running.FS, {
|
|
3920
|
+
sys,
|
|
3921
|
+
memory: () => memory,
|
|
3922
|
+
memalign: () => exports?.emscripten_builtin_memalign
|
|
3923
|
+
});
|
|
3799
3924
|
ownByRealmUser(running.FS);
|
|
3800
3925
|
const livePath = (s) => liveNodePath(s.node);
|
|
3801
3926
|
running.sliccKernel = createProcessKernel({
|
|
@@ -3867,7 +3992,7 @@ function runMain(running, init) {
|
|
|
3867
3992
|
return status2;
|
|
3868
3993
|
}
|
|
3869
3994
|
}
|
|
3870
|
-
var O_RDONLY,
|
|
3995
|
+
var FS_OPS, O_RDONLY, O_WRONLY3, O_RDWR3, PLACED, GLUE_TRAILER, evaluateGlue, EVAL_BLOCKED;
|
|
3871
3996
|
var init_process_runtime = __esm({
|
|
3872
3997
|
"src/process/process-runtime.ts"() {
|
|
3873
3998
|
"use strict";
|
|
@@ -3875,6 +4000,7 @@ var init_process_runtime = __esm({
|
|
|
3875
4000
|
init_signals();
|
|
3876
4001
|
init_emscripten_vfs_hook();
|
|
3877
4002
|
init_live_vfs_fs();
|
|
4003
|
+
init_sync_fs_wire();
|
|
3878
4004
|
init_sync_sab_bridge();
|
|
3879
4005
|
init_sync_sab_wire();
|
|
3880
4006
|
init_kernel_streams();
|
|
@@ -3887,8 +4013,9 @@ var init_process_runtime = __esm({
|
|
|
3887
4013
|
init_procfs();
|
|
3888
4014
|
init_realm_user();
|
|
3889
4015
|
init_kernel_streams();
|
|
4016
|
+
FS_OPS = new Set(SYNC_FS_OPS);
|
|
3890
4017
|
O_RDONLY = 0;
|
|
3891
|
-
|
|
4018
|
+
O_WRONLY3 = 1;
|
|
3892
4019
|
O_RDWR3 = 2;
|
|
3893
4020
|
PLACED = /* @__PURE__ */ new Set(["stream", "file", "socket"]);
|
|
3894
4021
|
GLUE_TRAILER = [
|
|
@@ -4348,7 +4475,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
4348
4475
|
op: "fd-promote",
|
|
4349
4476
|
fd,
|
|
4350
4477
|
path: f.path,
|
|
4351
|
-
flags: (f.writable ? f.readable ? O_RDWR4 :
|
|
4478
|
+
flags: (f.writable ? f.readable ? O_RDWR4 : O_WRONLY4 : 0) | (f.append ? O_APPEND : 0),
|
|
4352
4479
|
position: f.offset,
|
|
4353
4480
|
...joins ? {} : { contents: f.buffer.contents() },
|
|
4354
4481
|
...orphan ? { orphan: true } : {},
|
|
@@ -4356,7 +4483,7 @@ function promoteRequest(fd, f, handed) {
|
|
|
4356
4483
|
...!joins && f.buffer.isDirty() ? { dirty: true } : {}
|
|
4357
4484
|
};
|
|
4358
4485
|
}
|
|
4359
|
-
var SYNTHETIC_DIRS2, O_NONBLOCK2,
|
|
4486
|
+
var SYNTHETIC_DIRS2, O_NONBLOCK2, O_WRONLY4, O_RDWR4, O_APPEND, DEVICES2, WasiFds, GEN;
|
|
4360
4487
|
var init_wasi_fds = __esm({
|
|
4361
4488
|
"src/process/wasi/wasi-fds.ts"() {
|
|
4362
4489
|
"use strict";
|
|
@@ -4364,7 +4491,7 @@ var init_wasi_fds = __esm({
|
|
|
4364
4491
|
init_wasi_files();
|
|
4365
4492
|
SYNTHETIC_DIRS2 = ["usr", "bin"];
|
|
4366
4493
|
O_NONBLOCK2 = 2048;
|
|
4367
|
-
|
|
4494
|
+
O_WRONLY4 = 1;
|
|
4368
4495
|
O_RDWR4 = 2;
|
|
4369
4496
|
O_APPEND = 1024;
|
|
4370
4497
|
DEVICES2 = {
|
|
@@ -4777,7 +4904,7 @@ var init_wasi_fds = __esm({
|
|
|
4777
4904
|
kernelFile(path, existing, oflags, rights, fdflags) {
|
|
4778
4905
|
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
4779
4906
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
4780
|
-
const flags = (writable ? readable ? O_RDWR4 :
|
|
4907
|
+
const flags = (writable ? readable ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND : 0);
|
|
4781
4908
|
if (!existing) this.fs.writeFile(path, new Uint8Array(0));
|
|
4782
4909
|
const truncate = !existing || (oflags & OFLAGS.TRUNC) !== 0;
|
|
4783
4910
|
const fd = this.kernel.sys.openVfs(path, flags, 0, truncate ? { truncate } : {});
|
|
@@ -5024,8 +5151,9 @@ function filestatOf(path, s) {
|
|
|
5024
5151
|
function kernelFiletype(kind) {
|
|
5025
5152
|
switch (kind) {
|
|
5026
5153
|
case "tty":
|
|
5027
|
-
case "device":
|
|
5028
5154
|
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: false };
|
|
5155
|
+
case "device":
|
|
5156
|
+
return { filetype: FILETYPE.CHARACTER_DEVICE, seeks: true };
|
|
5029
5157
|
case "socket":
|
|
5030
5158
|
return { filetype: FILETYPE.SOCKET_STREAM, seeks: false };
|
|
5031
5159
|
case "file":
|
|
@@ -5429,7 +5557,9 @@ var init_wasi_host = __esm({
|
|
|
5429
5557
|
seek(fd, offset, whence) {
|
|
5430
5558
|
const e = this.fds.get(fd);
|
|
5431
5559
|
if (e.type === "kernel") {
|
|
5432
|
-
|
|
5560
|
+
const kind = this.fds.kind(fd, e);
|
|
5561
|
+
if (kind === "device") return 0;
|
|
5562
|
+
if (kind !== "file") throw new WasiError("ESPIPE");
|
|
5433
5563
|
return this.o.kernel.sys.seek(fd, offset, whence);
|
|
5434
5564
|
}
|
|
5435
5565
|
if (e.type === "device") return 0;
|
|
@@ -6427,7 +6557,7 @@ var init_wasix_linker = __esm({
|
|
|
6427
6557
|
function resolveFrom(cwd, path) {
|
|
6428
6558
|
return normalize(path.startsWith("/") ? path : `${cwd}/${path}`);
|
|
6429
6559
|
}
|
|
6430
|
-
var POSIX_TO_WASI_SIGNAL,
|
|
6560
|
+
var POSIX_TO_WASI_SIGNAL, O_WRONLY5, O_RDWR5, O_APPEND2, OFLAG_CREAT, OFLAG_TRUNC, WasixProcess;
|
|
6431
6561
|
var init_wasix_process = __esm({
|
|
6432
6562
|
"src/process/wasi/wasix-process.ts"() {
|
|
6433
6563
|
"use strict";
|
|
@@ -6437,7 +6567,7 @@ var init_wasix_process = __esm({
|
|
|
6437
6567
|
POSIX_TO_WASI_SIGNAL = Object.fromEntries(
|
|
6438
6568
|
Object.entries(WASI_SIGNAL_TO_POSIX).map(([wasi, posix]) => [posix, Number(wasi)])
|
|
6439
6569
|
);
|
|
6440
|
-
|
|
6570
|
+
O_WRONLY5 = 1;
|
|
6441
6571
|
O_RDWR5 = 2;
|
|
6442
6572
|
O_APPEND2 = 1024;
|
|
6443
6573
|
OFLAG_CREAT = 1;
|
|
@@ -6528,7 +6658,7 @@ var init_wasix_process = __esm({
|
|
|
6528
6658
|
throw Object.assign(new Error("ENOENT"), { code: "ENOENT" });
|
|
6529
6659
|
}
|
|
6530
6660
|
const flags = (op.rightsWrite ? O_RDWR5 : 0) | (op.append ? O_APPEND2 : 0);
|
|
6531
|
-
return this.host.o.kernel.sys.openVfs(path, op.rightsWrite ? flags ||
|
|
6661
|
+
return this.host.o.kernel.sys.openVfs(path, op.rightsWrite ? flags || O_WRONLY5 : 0, 0, {
|
|
6532
6662
|
...create ? { create } : {},
|
|
6533
6663
|
...op.oflags & OFLAG_TRUNC ? { truncate: true } : {}
|
|
6534
6664
|
});
|
|
@@ -8009,7 +8139,7 @@ function typeOf(info) {
|
|
|
8009
8139
|
}
|
|
8010
8140
|
function flagsOf(o) {
|
|
8011
8141
|
const write = o.write || o.append || o.truncate;
|
|
8012
|
-
const access = write ? o.read ? O_RDWR6 :
|
|
8142
|
+
const access = write ? o.read ? O_RDWR6 : O_WRONLY6 : 0;
|
|
8013
8143
|
return access | (o.append ? O_APPEND3 : 0);
|
|
8014
8144
|
}
|
|
8015
8145
|
function createContext(o) {
|
|
@@ -8281,7 +8411,7 @@ function pathOps(kernel, resolve, statOf, open) {
|
|
|
8281
8411
|
}
|
|
8282
8412
|
};
|
|
8283
8413
|
}
|
|
8284
|
-
var JsExit, CHUNK, MAX_IO,
|
|
8414
|
+
var JsExit, CHUNK, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND3, encoder2;
|
|
8285
8415
|
var init_js_context = __esm({
|
|
8286
8416
|
"src/process/js/js-context.ts"() {
|
|
8287
8417
|
"use strict";
|
|
@@ -8298,7 +8428,7 @@ var init_js_context = __esm({
|
|
|
8298
8428
|
};
|
|
8299
8429
|
CHUNK = 64 * 1024;
|
|
8300
8430
|
MAX_IO = 1024 * 1024;
|
|
8301
|
-
|
|
8431
|
+
O_WRONLY6 = 1;
|
|
8302
8432
|
O_RDWR6 = 2;
|
|
8303
8433
|
O_APPEND3 = 1024;
|
|
8304
8434
|
encoder2 = new TextEncoder();
|