@ai-ecoverse/slicc-kernel 1.195.15 → 1.195.16
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/async-process.js +63 -25
- package/dist/async-process.js.map +3 -3
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +1 -1
- package/dist/kernel-worker.js +1 -1
- package/dist/node-process-worker.cjs +64 -26
- package/dist/node-process-worker.cjs.map +3 -3
- package/dist/node-process-worker.js +64 -26
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +1 -1
- package/dist/process-worker.js +64 -26
- package/dist/process-worker.js.map +3 -3
- package/dist/types/process/wasi/wasix-linker.d.ts +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -502,7 +502,7 @@ That's for programs that walk to the root, such as Go's (`GOOS=wasip1`) and esbu
|
|
|
502
502
|
|
|
503
503
|
A descriptor a program inherits at one of those numbers (from bash's `3<file`, or a `posix_spawn` file action) moves to the first free number above them. One above the range keeps its number. A command that takes descriptors by number from its caller should leave `preopenRoot` off, which keeps the shorter range. An unowned `.wasm` run by path has the longer one, so a descriptor it inherits in that range lands two numbers higher; one that needs the shorter range can be installed as a package command without the flag.
|
|
504
504
|
|
|
505
|
-
**Paths with `..`.** A `..` after a symlinked directory goes to the parent of the link's target, as on Linux: with `/a/link -> /x/y`, `/a/link/../f` is `/x/f`, for a WASI program as for bash, and for the program a WASIX `posix_spawn` or `execve` names, the path of a spawn file action ([#1960](https://github.com/ai-ecoverse/slicc-kernel/issues/1960)), and a `dlopen` path or search entry ([#1980](https://github.com/ai-ecoverse/slicc-kernel/issues/1980)). `dlopen` resolves the library to its real path in that one walk, every symlink followed, with at most 40 for the whole path as on Linux, and keys what it loaded by that path, so two spellings of one file (`alias/m.so`, `alias/d/../m.so`) give one handle and run its constructors once. A `dlopen` the walk refuses, or whose library can't be read, fails with `<name>: cannot open shared object file: <reason>` using the requested name and the error text (for example, `./unread.so: cannot open shared object file: Permission denied`) ([#1989](https://github.com/ai-ecoverse/slicc-kernel/issues/1989)), and a search entry
|
|
505
|
+
**Paths with `..`.** A `..` after a symlinked directory goes to the parent of the link's target, as on Linux: with `/a/link -> /x/y`, `/a/link/../f` is `/x/f`, for a WASI program as for bash, and for the program a WASIX `posix_spawn` or `execve` names, the path of a spawn file action ([#1960](https://github.com/ai-ecoverse/slicc-kernel/issues/1960)), and a `dlopen` path or search entry ([#1980](https://github.com/ai-ecoverse/slicc-kernel/issues/1980)). `dlopen` resolves the library to its real path in that one walk, every symlink followed, with at most 40 for the whole path as on Linux, and keys what it loaded by that path, so two spellings of one file (`alias/m.so`, `alias/d/../m.so`) give one handle and run its constructors once. A `dlopen` the walk refuses, or whose library can't be read, fails with `<name>: cannot open shared object file: <reason>` using the requested name and the error text (for example, `./unread.so: cannot open shared object file: Permission denied`) ([#1989](https://github.com/ai-ecoverse/slicc-kernel/issues/1989)), and a search entry (an `LD_LIBRARY_PATH` entry, the runtime path, `/lib`, `/usr/lib`, `/usr/local/lib`) is skipped when its candidate is `ENOENT`, `EACCES` or `ENOTDIR`, or when an absolute entry is no existing directory, probed as written (so `/loop/../d` with `/loop` a link loop is skipped), as glibc's `open_path` does. Any other error in an existing entry ends that entry's list, and a relative entry always counts as existing ([#2009](https://github.com/ai-ecoverse/slicc-kernel/issues/2009)). The lists are `LD_LIBRARY_PATH`, the runtime path, and `/lib`, `/usr/lib` and `/usr/local/lib` (for a needed library, its own directory first), so a link loop in `LD_LIBRARY_PATH` still lets the default directories load the library. A file found but unreadable ends the whole search: a directory of that name is `dir/m.so: cannot read file data: Is a directory`, where it used to be passed over for a later copy. When nothing loads, the error carries the last candidate's errno, `m.so: cannot open shared object file: No such file or directory` when every one was missing, where it used to be `m.so: not found`. Trailing slashes on an entry are dropped before the name is joined to it. A `dlopen` name, or an entry joined with the name, of 4096 bytes or more is `ENAMETOOLONG` (`File name too long`), as on Linux, checked on the name as given, so `./` padding counts. Before, the name was shortened first and could load. For all processes, a leading, trailing or doubled `:` in a nonempty `LD_LIBRARY_PATH` searches the working directory at that position. An unset or wholly empty `LD_LIBRARY_PATH` adds no directories. A `..` after a file or a missing name fails with `ENOTDIR` or `ENOENT`, and with users on, a `..` needs `x` on the directory it leaves, as on Linux: `noexec/../f` is `EACCES` when the caller can't search `noexec`, even though `f` itself is reachable (root can). That check uses the effective ids, except in `access` (`path_access`, and `faccessat` for an Emscripten program the kernel runs) without `AT_EACCESS`, which walks the whole path with the real ids, as Linux does. Paths without `..` are joined as they are.
|
|
506
506
|
|
|
507
507
|
**A trailing slash** (`name/`, or `name/.`) asks for a directory, as on Linux, with users on or off ([#1960](https://github.com/ai-ecoverse/slicc-kernel/issues/1960)). A call that looks the name up (`path_open`, `path_filestat_get` with or without `LOOKUP_SYMLINK_FOLLOW`, `path_filestat_set_times`, `path_readlink`, `path_link`'s source, `path_copy_file`'s source, the other `slicc_fs` path calls, a WASIX exec or spawn file action, and `dlopen`) follows a symlink there and is `ENOTDIR` for anything but a directory, so `lstat("link/")` describes the directory and `readlink("link/")` is `EINVAL`. `path_unlink_file` and `path_rename` of a name that isn't a directory are `ENOTDIR` (a symlink counts as one, as on Linux), `path_open` with `O_CREAT` (a WASIX spawn file action included) and `path_copy_file`'s destination are `EISDIR` once the directory the name is in resolves, and that directory's error first: `ENOENT` when it's missing, `ENOTDIR` when it's a file, `EACCES` when the caller can't search it, and `path_symlink`, `path_link`'s destination and `path_mkfifo` are `EEXIST`, or `ENOENT` when the name is free. `path_create_directory` and `path_remove_directory` take the name as it is. Emscripten programs don't do either yet ([#1974](https://github.com/ai-ecoverse/slicc-kernel/issues/1974)): the `..` check holds for those the kernel runs itself (`emscripten: 'kernel'`), and for those that resolve paths in their glue only when the `..` is the final component (below), and a trailing slash is dropped in both, while `name/.` asks for a directory, as a final `.` does.
|
|
508
508
|
|
package/dist/async-process.js
CHANGED
|
@@ -1042,11 +1042,11 @@ var Pages = class {
|
|
|
1042
1042
|
runs.push({ offset: start2, bytes });
|
|
1043
1043
|
i = j;
|
|
1044
1044
|
}
|
|
1045
|
-
const
|
|
1045
|
+
const written2 = Math.max(this.stored, ...runs.map((r) => r.offset + r.bytes.length));
|
|
1046
1046
|
return {
|
|
1047
1047
|
...this.shrink !== void 0 ? { shrink: this.shrink } : {},
|
|
1048
1048
|
runs,
|
|
1049
|
-
...this.length >
|
|
1049
|
+
...this.length > written2 ? { extend: this.length } : {}
|
|
1050
1050
|
};
|
|
1051
1051
|
}
|
|
1052
1052
|
flushed() {
|
|
@@ -1395,7 +1395,7 @@ function createParentRefreshCount() {
|
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
1397
|
// src/version.ts
|
|
1398
|
-
var KERNEL_VERSION = true ? "1.195.
|
|
1398
|
+
var KERNEL_VERSION = true ? "1.195.16" : "0.0.0-dev";
|
|
1399
1399
|
var OS_RELEASE = "6.0.0-slicc";
|
|
1400
1400
|
function procVersion() {
|
|
1401
1401
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -6120,16 +6120,16 @@ var WasiHost = class {
|
|
|
6120
6120
|
return await this.fds.cwd() === void 0 ? await this.fds.resolve(3, `${await this.workingDir()}/${raw}`) : await this.fds.resolve(3, raw);
|
|
6121
6121
|
}
|
|
6122
6122
|
async lookup(dirfd, raw, kind) {
|
|
6123
|
-
const
|
|
6124
|
-
return await this.looked(await this.fds.resolve(dirfd,
|
|
6123
|
+
const written2 = await this.fds.written(dirfd, raw);
|
|
6124
|
+
return await this.looked(await this.fds.resolve(dirfd, written2, kind), written2, kind);
|
|
6125
6125
|
}
|
|
6126
6126
|
async looked(path, raw, kind) {
|
|
6127
6127
|
const node = await this.lookupNode(path, raw, kind);
|
|
6128
6128
|
return typeof node === "string" ? node : await physical(this.o.fs, await this.refPath(node), true, kind);
|
|
6129
6129
|
}
|
|
6130
6130
|
async nodeAt(dirfd, raw) {
|
|
6131
|
-
const
|
|
6132
|
-
return await this.lookupNode(await this.fds.resolve(dirfd,
|
|
6131
|
+
const written2 = await this.fds.written(dirfd, raw);
|
|
6132
|
+
return await this.lookupNode(await this.fds.resolve(dirfd, written2), written2);
|
|
6133
6133
|
}
|
|
6134
6134
|
async lookupNode(path, raw, kind) {
|
|
6135
6135
|
const dot = finalOf(raw) === ".";
|
|
@@ -9612,11 +9612,22 @@ var OPEN_ERRORS = {
|
|
|
9612
9612
|
EIO: "Input/output error"
|
|
9613
9613
|
};
|
|
9614
9614
|
function openError(name2, code2) {
|
|
9615
|
+
if (code2 === "EISDIR")
|
|
9616
|
+
return new DlError(`${name2}: cannot read file data: Is a directory`, E.ISDIR);
|
|
9615
9617
|
return new DlError(
|
|
9616
9618
|
`${name2}: cannot open shared object file: ${OPEN_ERRORS[code2] ?? code2}`,
|
|
9617
9619
|
wasiErrnoOf(code2)
|
|
9618
9620
|
);
|
|
9619
9621
|
}
|
|
9622
|
+
var PASSED = /* @__PURE__ */ new Set(["ENOENT", "EACCES", "ENOTDIR"]);
|
|
9623
|
+
var PATH_MAX = 4096;
|
|
9624
|
+
function fits(path) {
|
|
9625
|
+
return new TextEncoder().encode(path).length < PATH_MAX;
|
|
9626
|
+
}
|
|
9627
|
+
function written(path, asked) {
|
|
9628
|
+
if (!fits(path)) throw Object.assign(new Error("ENAMETOOLONG"), { code: "ENAMETOOLONG" });
|
|
9629
|
+
return asked;
|
|
9630
|
+
}
|
|
9620
9631
|
var WasixLinker = class {
|
|
9621
9632
|
table;
|
|
9622
9633
|
stackPointer;
|
|
@@ -9712,7 +9723,7 @@ var WasixLinker = class {
|
|
|
9712
9723
|
}
|
|
9713
9724
|
}
|
|
9714
9725
|
async open(name2, cwd, ldPath) {
|
|
9715
|
-
const path = await this.locate(name2, cwd, ldPath);
|
|
9726
|
+
const path = await this.locate(name2, cwd, [ldPath]);
|
|
9716
9727
|
if (await this.isMain(path)) return 0;
|
|
9717
9728
|
await this.indices?.lock();
|
|
9718
9729
|
try {
|
|
@@ -9836,32 +9847,52 @@ var WasixLinker = class {
|
|
|
9836
9847
|
if (!m) throw new DlError(`invalid handle ${handle}`);
|
|
9837
9848
|
return m;
|
|
9838
9849
|
}
|
|
9839
|
-
async locate(name2, cwd,
|
|
9850
|
+
async locate(name2, cwd, lists) {
|
|
9840
9851
|
if (name2.includes("/")) {
|
|
9841
9852
|
const asked = name2.startsWith("/") ? name2 : `${cwd}/${name2}`;
|
|
9842
9853
|
let real;
|
|
9843
9854
|
try {
|
|
9844
|
-
real = await this.host.resolve(asked);
|
|
9855
|
+
real = await this.host.resolve(written(name2, asked));
|
|
9845
9856
|
} catch (e) {
|
|
9846
9857
|
throw openError(name2, codeOf2(e));
|
|
9847
9858
|
}
|
|
9848
9859
|
return await this.checked(asked, real, name2);
|
|
9849
9860
|
}
|
|
9850
|
-
|
|
9851
|
-
|
|
9852
|
-
|
|
9861
|
+
let last = "ENOENT";
|
|
9862
|
+
for (const list of [...lists, LIBRARY_DIRS]) {
|
|
9863
|
+
for (const dir of list) {
|
|
9864
|
+
const found = await this.candidate(dir, name2, cwd);
|
|
9865
|
+
if ("real" in found) return found.real;
|
|
9866
|
+
last = found.code;
|
|
9867
|
+
if (found.ends) break;
|
|
9868
|
+
}
|
|
9853
9869
|
}
|
|
9854
|
-
throw
|
|
9870
|
+
throw openError(name2, last);
|
|
9855
9871
|
}
|
|
9856
|
-
async candidate(
|
|
9872
|
+
async candidate(dir, name2, cwd) {
|
|
9873
|
+
const base = dir.replace(/\/+$/, "");
|
|
9874
|
+
const entry = dir === "" ? name2 : `${base}/${name2}`;
|
|
9875
|
+
const asked = dir.startsWith("/") ? entry : `${cwd}/${entry}`;
|
|
9857
9876
|
let path;
|
|
9858
9877
|
try {
|
|
9859
|
-
path = await this.host.resolve(asked);
|
|
9878
|
+
path = await this.host.resolve(written(entry, asked));
|
|
9860
9879
|
} catch (e) {
|
|
9861
|
-
codeOf2(e);
|
|
9862
|
-
return
|
|
9880
|
+
const code2 = codeOf2(e);
|
|
9881
|
+
return { code: code2, ends: !PASSED.has(code2) && await this.existing(base || "/", dir) };
|
|
9882
|
+
}
|
|
9883
|
+
if (!this.byPath.has(path)) {
|
|
9884
|
+
try {
|
|
9885
|
+
await this.host.open(path);
|
|
9886
|
+
} catch (e) {
|
|
9887
|
+
const code2 = codeOf2(e);
|
|
9888
|
+
if (PASSED.has(code2)) return { code: code2, ends: false };
|
|
9889
|
+
throw openError(code2 === "EISDIR" ? entry : name2, code2);
|
|
9890
|
+
}
|
|
9863
9891
|
}
|
|
9864
|
-
return
|
|
9892
|
+
return { real: await this.checked(asked, path, name2) };
|
|
9893
|
+
}
|
|
9894
|
+
async existing(base, dir) {
|
|
9895
|
+
return !dir.startsWith("/") || fits(base) && await this.host.isDirectory(base);
|
|
9865
9896
|
}
|
|
9866
9897
|
async checked(asked, real, name2 = asked) {
|
|
9867
9898
|
if (!await this.host.allowed(asked, real)) throw openError(name2, "EACCES");
|
|
@@ -9885,7 +9916,7 @@ var WasixLinker = class {
|
|
|
9885
9916
|
const info = dylinkInfo(module);
|
|
9886
9917
|
if (!info) throw new DlError(`${path}: not a side module (no dylink.0)`);
|
|
9887
9918
|
const dir = path.slice(0, path.lastIndexOf("/")) || "/";
|
|
9888
|
-
const search = [dir,
|
|
9919
|
+
const search = [[dir], ldPath, info.runtimePath.map((p) => expandOrigin(p, dir))];
|
|
9889
9920
|
const needed = [];
|
|
9890
9921
|
for (const n of info.needed)
|
|
9891
9922
|
needed.push((await this.load(n, await this.locate(n, cwd, search), cwd, ldPath)).handle);
|
|
@@ -10953,6 +10984,13 @@ function linkerHost(host, imports) {
|
|
|
10953
10984
|
},
|
|
10954
10985
|
real: async (path) => await physicalPath(host.o.fs, path),
|
|
10955
10986
|
resolve: async (path) => await realFile(host.o.fs, path),
|
|
10987
|
+
isDirectory: async (path) => {
|
|
10988
|
+
try {
|
|
10989
|
+
return (await host.o.fs.stat(await physical(host.o.fs, path, true))).isDirectory === true;
|
|
10990
|
+
} catch {
|
|
10991
|
+
return false;
|
|
10992
|
+
}
|
|
10993
|
+
},
|
|
10956
10994
|
allowed: async (asked, real) => !host.o.checkedLibraries || await host.o.kernel.call({ op: "dl-allowed", asked, real }) === true
|
|
10957
10995
|
};
|
|
10958
10996
|
}
|
|
@@ -12891,16 +12929,16 @@ function streamWrite(ctx) {
|
|
|
12891
12929
|
return positive(async (fd, iov, n, out) => {
|
|
12892
12930
|
const e = await ctx.host.fds.get(fd);
|
|
12893
12931
|
const nonblock = e.type === "kernel" && e.nonblock;
|
|
12894
|
-
let
|
|
12932
|
+
let written2;
|
|
12895
12933
|
try {
|
|
12896
|
-
|
|
12934
|
+
written2 = await ctx.sys.write(fd, ctx.mem.gather(iov, n), { nonblock });
|
|
12897
12935
|
} catch (err) {
|
|
12898
12936
|
if (err.code === "EPIPE" && !await sigpipeSpared(ctx)) {
|
|
12899
12937
|
throw new WasiExit(KILLED_BY_SIGPIPE4);
|
|
12900
12938
|
}
|
|
12901
12939
|
throw err;
|
|
12902
12940
|
}
|
|
12903
|
-
ctx.mem.view().setUint32(out,
|
|
12941
|
+
ctx.mem.view().setUint32(out, written2, true);
|
|
12904
12942
|
});
|
|
12905
12943
|
}
|
|
12906
12944
|
function wasiImports(ctx, state) {
|
|
@@ -14175,9 +14213,9 @@ function dayOf(num, name2, at) {
|
|
|
14175
14213
|
if (day !== void 0) return { month: at.month, day };
|
|
14176
14214
|
const ofYear = num("j");
|
|
14177
14215
|
if (ofYear !== void 0) {
|
|
14178
|
-
const
|
|
14216
|
+
const fits2 = ofYear <= (leap(at.year) ? 366 : 365);
|
|
14179
14217
|
const december = (leap(at.year) ? LEAP : REGULAR)[11];
|
|
14180
|
-
return { month: at.month, day:
|
|
14218
|
+
return { month: at.month, day: fits2 ? ofYear - december : at.day };
|
|
14181
14219
|
}
|
|
14182
14220
|
const date = name2 ? weekDay(num, name2, at.year) : void 0;
|
|
14183
14221
|
return date ? { month: date.getMonth(), day: date.getDate() } : at;
|