@ai-ecoverse/slicc-kernel 1.16.0 → 1.16.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/dist/kernel-worker.js +31 -9
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +63 -11
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +31 -9
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +63 -11
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -2
package/dist/node.js
CHANGED
|
@@ -1988,7 +1988,8 @@ function statJson(s) {
|
|
|
1988
1988
|
atimeMs: s.atime.getTime(),
|
|
1989
1989
|
ctimeMs: s.ctime.getTime(),
|
|
1990
1990
|
ino: s.ino,
|
|
1991
|
-
...s.dev !== void 0 ? { dev: s.dev } : {}
|
|
1991
|
+
...s.dev !== void 0 ? { dev: s.dev } : {},
|
|
1992
|
+
...s.readonly ? { readonly: true } : {}
|
|
1992
1993
|
};
|
|
1993
1994
|
}
|
|
1994
1995
|
async function readdirStat(fs, dir) {
|
|
@@ -4843,6 +4844,20 @@ var VfsNodes = class {
|
|
|
4843
4844
|
}
|
|
4844
4845
|
}
|
|
4845
4846
|
};
|
|
4847
|
+
async function refuseReadonly(fs, path, flags, opts = {}) {
|
|
4848
|
+
const writes = (flags & O_ACCMODE) !== 0 || opts.truncate === true;
|
|
4849
|
+
if (!writes && !opts.create || !fs.stat) return;
|
|
4850
|
+
const stat = (p) => fs.stat?.(p).catch((err) => {
|
|
4851
|
+
const code = err?.code;
|
|
4852
|
+
if (isMissing(err) || typeof code !== "string") return void 0;
|
|
4853
|
+
throw err;
|
|
4854
|
+
});
|
|
4855
|
+
const parent = path.slice(0, path.lastIndexOf("/")) || "/";
|
|
4856
|
+
const own = await stat(path);
|
|
4857
|
+
if (own && !writes) return;
|
|
4858
|
+
const st = own ?? await stat(parent);
|
|
4859
|
+
if (st?.readonly) throw new KernelError("EROFS");
|
|
4860
|
+
}
|
|
4846
4861
|
function vfsFile(fs, opts, nodes) {
|
|
4847
4862
|
const access = opts.flags & O_ACCMODE;
|
|
4848
4863
|
const readable = access !== O_WRONLY;
|
|
@@ -5113,6 +5128,10 @@ var WasmProcess = class {
|
|
|
5113
5128
|
if (e instanceof KernelError || e instanceof SpawnError) {
|
|
5114
5129
|
return { ok: false, errno: e.code, message: e.code };
|
|
5115
5130
|
}
|
|
5131
|
+
const code = e?.code;
|
|
5132
|
+
if (typeof code === "string" && /^E[A-Z]+$/.test(code)) {
|
|
5133
|
+
return { ok: false, errno: code, message: code };
|
|
5134
|
+
}
|
|
5116
5135
|
throw e;
|
|
5117
5136
|
}
|
|
5118
5137
|
}
|
|
@@ -5185,6 +5204,7 @@ var WasmProcess = class {
|
|
|
5185
5204
|
case "fd-poll":
|
|
5186
5205
|
return { ok: true, kind: "json", json: pollFile(this.fds.get(req.fd).file) };
|
|
5187
5206
|
case "fd-open-vfs":
|
|
5207
|
+
await refuseReadonly(this.options.fs, req.path, req.flags, req);
|
|
5188
5208
|
return { ok: true, kind: "json", json: this.fds.install(this.openVfsFile(req), 3) };
|
|
5189
5209
|
case "fd-info":
|
|
5190
5210
|
return { ok: true, kind: "json", json: this.fdInfo(req.fd) };
|
|
@@ -6354,14 +6374,14 @@ function invalidation(event) {
|
|
|
6354
6374
|
return event.paths ?? true;
|
|
6355
6375
|
}
|
|
6356
6376
|
async function openHostfs(spec, hook, fetch2, timing = {}) {
|
|
6357
|
-
const
|
|
6377
|
+
const readonly2 = spec.options?.ro !== void 0;
|
|
6358
6378
|
const { port1, port2 } = new MessageChannel();
|
|
6359
6379
|
const slot = mediumSlot(
|
|
6360
6380
|
async (err) => unreachable(err),
|
|
6361
6381
|
() => watching.kick()
|
|
6362
6382
|
);
|
|
6363
6383
|
const stop = new AbortController();
|
|
6364
|
-
const grant = () => hook(spec.source, { readonly });
|
|
6384
|
+
const grant = () => hook(spec.source, { readonly: readonly2 });
|
|
6365
6385
|
let active;
|
|
6366
6386
|
const handlers = hostfsHandlers(() => active);
|
|
6367
6387
|
const served = serveFilesystem(port2, slot.handlers, {
|
|
@@ -6369,7 +6389,7 @@ async function openHostfs(spec, hook, fetch2, timing = {}) {
|
|
|
6369
6389
|
chmod: true,
|
|
6370
6390
|
listingStats: true,
|
|
6371
6391
|
maxIo: HOSTFS_IO,
|
|
6372
|
-
...
|
|
6392
|
+
...readonly2 ? { readonly: true } : {}
|
|
6373
6393
|
});
|
|
6374
6394
|
const watching = keepWatching(
|
|
6375
6395
|
{
|
|
@@ -6518,7 +6538,8 @@ function heldUnder(held, target) {
|
|
|
6518
6538
|
return false;
|
|
6519
6539
|
}
|
|
6520
6540
|
var parentOf4 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
|
|
6521
|
-
|
|
6541
|
+
var readonly = (mount) => mount.caps.readonly === true;
|
|
6542
|
+
function statOf(attr, path, mount) {
|
|
6522
6543
|
const mtime = new Date(attr.mtime);
|
|
6523
6544
|
const fallback = attr.kind === "directory" ? 16877 : attr.kind === "symlink" ? 41471 : 33188;
|
|
6524
6545
|
return {
|
|
@@ -6531,7 +6552,8 @@ function statOf(attr, path, dev) {
|
|
|
6531
6552
|
atime: mtime,
|
|
6532
6553
|
ctime: mtime,
|
|
6533
6554
|
ino: attr.ino ?? inodeOf(path),
|
|
6534
|
-
dev
|
|
6555
|
+
dev: mount.dev,
|
|
6556
|
+
...readonly(mount) ? { readonly: true } : {}
|
|
6535
6557
|
};
|
|
6536
6558
|
}
|
|
6537
6559
|
function concat4(chunks2, total) {
|
|
@@ -6717,7 +6739,7 @@ var MountFs = class {
|
|
|
6717
6739
|
return this.table.locate(normalizePath(path));
|
|
6718
6740
|
}
|
|
6719
6741
|
writable(mount, path) {
|
|
6720
|
-
if (mount
|
|
6742
|
+
if (readonly(mount)) throw errnoError("EROFS", path);
|
|
6721
6743
|
}
|
|
6722
6744
|
async follow(path, hops = 0, create = false) {
|
|
6723
6745
|
const found = this.at(path);
|
|
@@ -6846,7 +6868,7 @@ var MountFs = class {
|
|
|
6846
6868
|
const found = this.at(path);
|
|
6847
6869
|
if (!found) return this.base.lstat(path);
|
|
6848
6870
|
const real = normalizePath(path);
|
|
6849
|
-
return statOf(await this.table.getattr(found.mount, real, found.rel), real, found.mount
|
|
6871
|
+
return statOf(await this.table.getattr(found.mount, real, found.rel), real, found.mount);
|
|
6850
6872
|
}
|
|
6851
6873
|
async stat(path) {
|
|
6852
6874
|
const real = await this.follow(path);
|
|
@@ -6873,7 +6895,7 @@ var MountFs = class {
|
|
|
6873
6895
|
list.map(async (entry) => {
|
|
6874
6896
|
const child = normalizePath(`${real}/${entry.name}`);
|
|
6875
6897
|
if (entry.attr && mount.caps.listingStats) {
|
|
6876
|
-
return [entry.name, statOf(entry.attr, child, mount
|
|
6898
|
+
return [entry.name, statOf(entry.attr, child, mount)];
|
|
6877
6899
|
}
|
|
6878
6900
|
return [entry.name, await this.lstat(child).catch(() => null)];
|
|
6879
6901
|
})
|