@ai-ecoverse/slicc-kernel 1.39.0 → 1.39.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 +1 -1
- package/dist/kernel-worker.js +101 -26
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +64 -9
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +290 -201
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +64 -9
- package/dist/process-worker.js.map +2 -2
- package/package.json +1 -1
|
@@ -831,7 +831,10 @@ function createNodeOps(h) {
|
|
|
831
831
|
const perm = mode & PERM_MASK & ~UMASK;
|
|
832
832
|
if (perm !== DEFAULT_DIR_PERM) metadataCall(() => bridgeOf(parent).chmod(path, perm));
|
|
833
833
|
} else if (Fs.isFile(mode)) {
|
|
834
|
-
|
|
834
|
+
const bridge = bridgeOf(parent);
|
|
835
|
+
call2(
|
|
836
|
+
() => bridge.create ? bridge.create(path) : bridge.writeFile(path, new Uint8Array(0))
|
|
837
|
+
);
|
|
835
838
|
} else {
|
|
836
839
|
throw new Fs.ErrnoError(wasiErrno("EPERM"));
|
|
837
840
|
}
|
|
@@ -1326,6 +1329,7 @@ var init_sync_fs_wire = __esm({
|
|
|
1326
1329
|
"lutimes",
|
|
1327
1330
|
"statfs",
|
|
1328
1331
|
"hold",
|
|
1332
|
+
"create",
|
|
1329
1333
|
"pread",
|
|
1330
1334
|
"pwrite",
|
|
1331
1335
|
"truncate"
|
|
@@ -1567,6 +1571,9 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1567
1571
|
lutimes: (path, atimeMs, mtimeMs) => {
|
|
1568
1572
|
run({ op: "lutimes", path, atimeMs, mtimeMs }, path);
|
|
1569
1573
|
},
|
|
1574
|
+
create: (path) => {
|
|
1575
|
+
run({ op: "create", path }, path);
|
|
1576
|
+
},
|
|
1570
1577
|
hold: (path, held, open) => {
|
|
1571
1578
|
run({ op: "hold", path, mode: (held ? 1 : 0) | (open ? 2 : 0) }, path);
|
|
1572
1579
|
},
|
|
@@ -1805,7 +1812,8 @@ var init_kernel_streams = __esm({
|
|
|
1805
1812
|
}
|
|
1806
1813
|
const pty = this.openPty(open, path, flags, mode);
|
|
1807
1814
|
if (pty) return pty;
|
|
1808
|
-
|
|
1815
|
+
this.refuseExclusiveLink(path, flags);
|
|
1816
|
+
const stream = this.openRacing(open, path, flags, mode);
|
|
1809
1817
|
if (!stream.tty) return stream;
|
|
1810
1818
|
if (stream.path === "/dev/tty" && this.sys.openTty) {
|
|
1811
1819
|
let kfd;
|
|
@@ -1834,6 +1842,24 @@ var init_kernel_streams = __esm({
|
|
|
1834
1842
|
return stream;
|
|
1835
1843
|
};
|
|
1836
1844
|
}
|
|
1845
|
+
openRacing(open, path, flags, mode) {
|
|
1846
|
+
try {
|
|
1847
|
+
return open(path, flags, mode);
|
|
1848
|
+
} catch (err) {
|
|
1849
|
+
const lost = err.errno === wasiErrno("EEXIST") && !(flags & O_EXCL);
|
|
1850
|
+
if (!lost) throw err;
|
|
1851
|
+
return open(path, flags, mode);
|
|
1852
|
+
}
|
|
1853
|
+
}
|
|
1854
|
+
refuseExclusiveLink(path, flags) {
|
|
1855
|
+
if ((flags & (O_CREAT | O_EXCL)) !== (O_CREAT | O_EXCL)) return;
|
|
1856
|
+
let mode = 0;
|
|
1857
|
+
try {
|
|
1858
|
+
mode = this.Fs.stat?.(path, true)?.mode ?? 0;
|
|
1859
|
+
} catch {
|
|
1860
|
+
}
|
|
1861
|
+
if ((mode & 61440) === 40960) throw new this.Fs.ErrnoError(wasiErrno("EEXIST"));
|
|
1862
|
+
}
|
|
1837
1863
|
openPty(open, path, flags, mode) {
|
|
1838
1864
|
const pts = /^\/dev\/pts\/(\d+)$/.exec(path);
|
|
1839
1865
|
if (path !== "/dev/ptmx" && !pts) return void 0;
|
|
@@ -4321,6 +4347,7 @@ function cachingBridge(bridge, now = () => performance.now()) {
|
|
|
4321
4347
|
utimes: (p, a, m) => mutating(() => bridge.utimes(p, a, m)),
|
|
4322
4348
|
lutimes: (p, a, m) => mutating(() => bridge.lutimes(p, a, m)),
|
|
4323
4349
|
...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
|
|
4350
|
+
...bridge.create ? { create: (p) => mutating(() => bridge.create?.(p)) } : {},
|
|
4324
4351
|
...bridge.pread && bridge.pwrite && bridge.truncate ? {
|
|
4325
4352
|
pread: bridge.pread.bind(bridge),
|
|
4326
4353
|
pwrite: (p, at, bytes, transfer) => mutating(() => bridge.pwrite?.(p, at, bytes, transfer)),
|
|
@@ -4982,8 +5009,10 @@ var init_wasi_fds = __esm({
|
|
|
4982
5009
|
}
|
|
4983
5010
|
const alias = stdioAlias(path);
|
|
4984
5011
|
if (alias !== void 0) return this.reopen(alias);
|
|
5012
|
+
const exclusive = (oflags & OFLAGS.CREAT) !== 0 && (oflags & OFLAGS.EXCL) !== 0;
|
|
5013
|
+
if (exclusive && this.isLink(path)) throw new WasiError("EEXIST");
|
|
4985
5014
|
const s = this.statOrMissing(path);
|
|
4986
|
-
if (
|
|
5015
|
+
if (exclusive && s) throw new WasiError("EEXIST");
|
|
4987
5016
|
if (oflags & OFLAGS.DIRECTORY && !s?.isDirectory) {
|
|
4988
5017
|
throw new WasiError(s ? "ENOTDIR" : "ENOENT");
|
|
4989
5018
|
}
|
|
@@ -4998,8 +5027,8 @@ var init_wasi_fds = __esm({
|
|
|
4998
5027
|
if (buffer) {
|
|
4999
5028
|
if (oflags & OFLAGS.TRUNC) buffer.truncate(0);
|
|
5000
5029
|
} else {
|
|
5001
|
-
|
|
5002
|
-
const empty =
|
|
5030
|
+
const made = !existing && this.createNew(path, oflags);
|
|
5031
|
+
const empty = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
5003
5032
|
if (existing?.ranged) this.fs.invalidate?.();
|
|
5004
5033
|
const st = existing?.ranged || !existing ? this.fs.stat(path) : existing;
|
|
5005
5034
|
const ranged = st.ranged ? st.size : void 0;
|
|
@@ -5014,14 +5043,34 @@ var init_wasi_fds = __esm({
|
|
|
5014
5043
|
const { readable, writable } = openAccess(existing, oflags, rights);
|
|
5015
5044
|
const append = (fdflags & FDFLAGS.APPEND) !== 0;
|
|
5016
5045
|
const flags = (writable ? readable ? O_RDWR4 : O_WRONLY4 : 0) | (append ? O_APPEND : 0);
|
|
5017
|
-
|
|
5018
|
-
const truncate =
|
|
5046
|
+
const made = !existing && this.createNew(path, oflags);
|
|
5047
|
+
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
5019
5048
|
const fd = this.kernel.sys.openVfs(path, flags, 0, truncate ? { truncate } : {});
|
|
5020
5049
|
this.table.set(fd, { type: "kernel", kind: "file", nonblock: false, append });
|
|
5021
5050
|
if (append) this.publishFlags(fd, { nonblock: false, append });
|
|
5022
5051
|
this.bump();
|
|
5023
5052
|
return fd;
|
|
5024
5053
|
}
|
|
5054
|
+
createNew(path, oflags) {
|
|
5055
|
+
if (!this.fs.create) {
|
|
5056
|
+
this.fs.writeFile(path, new Uint8Array(0));
|
|
5057
|
+
return true;
|
|
5058
|
+
}
|
|
5059
|
+
try {
|
|
5060
|
+
this.fs.create(path);
|
|
5061
|
+
return true;
|
|
5062
|
+
} catch (err) {
|
|
5063
|
+
if (oflags & OFLAGS.EXCL || err.code !== "EEXIST") throw err;
|
|
5064
|
+
return false;
|
|
5065
|
+
}
|
|
5066
|
+
}
|
|
5067
|
+
isLink(path) {
|
|
5068
|
+
try {
|
|
5069
|
+
return this.fs.lstat(path).isSymbolicLink === true;
|
|
5070
|
+
} catch {
|
|
5071
|
+
return false;
|
|
5072
|
+
}
|
|
5073
|
+
}
|
|
5025
5074
|
statOrMissing(path) {
|
|
5026
5075
|
try {
|
|
5027
5076
|
return this.fs.stat(path);
|
|
@@ -8165,6 +8214,7 @@ var init_js_kernel = __esm({
|
|
|
8165
8214
|
pid = 0;
|
|
8166
8215
|
reported = { caught: 0, ignored: 0 };
|
|
8167
8216
|
watching = false;
|
|
8217
|
+
faulted = false;
|
|
8168
8218
|
constructor(o) {
|
|
8169
8219
|
this.header = new Int32Array(o.sab, 0, SAB_HEADER_I32);
|
|
8170
8220
|
this.transport = o.transport;
|
|
@@ -8214,12 +8264,16 @@ var init_js_kernel = __esm({
|
|
|
8214
8264
|
continue;
|
|
8215
8265
|
}
|
|
8216
8266
|
try {
|
|
8217
|
-
Promise.resolve(handler(sig)).catch(this.
|
|
8267
|
+
Promise.resolve(handler(sig)).catch((err) => this.fault(err));
|
|
8218
8268
|
} catch (err) {
|
|
8219
|
-
this.
|
|
8269
|
+
this.fault(err);
|
|
8220
8270
|
}
|
|
8221
8271
|
}
|
|
8222
8272
|
}
|
|
8273
|
+
fault(err) {
|
|
8274
|
+
this.faulted = true;
|
|
8275
|
+
this.onError(err);
|
|
8276
|
+
}
|
|
8223
8277
|
async watch() {
|
|
8224
8278
|
if (this.watching) return;
|
|
8225
8279
|
this.watching = true;
|
|
@@ -8626,6 +8680,7 @@ function createContext(o) {
|
|
|
8626
8680
|
};
|
|
8627
8681
|
const unwind = () => {
|
|
8628
8682
|
if (exiting !== void 0) throw new JsExit(exiting);
|
|
8683
|
+
if (kernel.faulted) throw new JsExit(1);
|
|
8629
8684
|
};
|
|
8630
8685
|
const info = async (fd) => {
|
|
8631
8686
|
const known = infos.get(fd);
|