@ai-ecoverse/slicc-kernel 1.29.0 → 1.29.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 +4 -4
- package/dist/driver-worker.js.map +2 -2
- package/dist/driver.js.map +2 -2
- package/dist/kernel-worker.js +104 -8
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js.map +2 -2
- package/dist/node-process-worker.js +91 -22
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +104 -8
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +91 -22
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -2
package/dist/kernel-worker.js
CHANGED
|
@@ -183,6 +183,11 @@ function rangedOps(fs) {
|
|
|
183
183
|
if (!pread || !pwrite || !truncate) return void 0;
|
|
184
184
|
return { pread: pread.bind(fs), pwrite: pwrite.bind(fs), truncate: truncate.bind(fs) };
|
|
185
185
|
}
|
|
186
|
+
async function lutimesOf(fs, path, atime, mtime) {
|
|
187
|
+
if (fs.lutimes) return fs.lutimes(path, atime, mtime);
|
|
188
|
+
if ((await fs.lstat(path)).isSymbolicLink) throw fsError("EOPNOTSUPP", path);
|
|
189
|
+
return fs.utimes(path, atime, mtime);
|
|
190
|
+
}
|
|
186
191
|
function fsError(code, path) {
|
|
187
192
|
return Object.assign(new Error(`${code}: ${path}`), { code });
|
|
188
193
|
}
|
|
@@ -470,7 +475,7 @@ var OpfsFs = class {
|
|
|
470
475
|
size: new TextEncoder().encode(entry.link).length,
|
|
471
476
|
mode: S_IFLNK | 511,
|
|
472
477
|
mtime: time2,
|
|
473
|
-
atime: time2,
|
|
478
|
+
atime: entry.atimeMs === void 0 ? time2 : new Date(entry.atimeMs),
|
|
474
479
|
ctime: new Date(entry.ctimeMs ?? 0),
|
|
475
480
|
ino: entry.ino ?? inodeOf(entry.path)
|
|
476
481
|
};
|
|
@@ -766,7 +771,24 @@ var OpfsFs = class {
|
|
|
766
771
|
}));
|
|
767
772
|
}
|
|
768
773
|
async utimes(path, atime, mtime) {
|
|
769
|
-
|
|
774
|
+
await this.setTimes(await this.locate(path, true), atime, mtime);
|
|
775
|
+
}
|
|
776
|
+
async lutimes(path, atime, mtime) {
|
|
777
|
+
await this.setTimes(await this.locate(path, false), atime, mtime);
|
|
778
|
+
}
|
|
779
|
+
async setTimes(found, atime, mtime) {
|
|
780
|
+
const { link: link2 } = found;
|
|
781
|
+
if (link2) {
|
|
782
|
+
const ctimeMs2 = Date.now();
|
|
783
|
+
await this.meta.update(found.path, (entry) => ({
|
|
784
|
+
...link2,
|
|
785
|
+
...entry,
|
|
786
|
+
atimeMs: atime.getTime(),
|
|
787
|
+
mtimeMs: mtime.getTime(),
|
|
788
|
+
ctimeMs: ctimeMs2
|
|
789
|
+
}));
|
|
790
|
+
return;
|
|
791
|
+
}
|
|
770
792
|
const handle = found.handle;
|
|
771
793
|
const file = handle.kind === "file" ? await handle.getFile() : void 0;
|
|
772
794
|
const ctimeMs = Date.now();
|
|
@@ -4740,6 +4762,7 @@ function withCommandDirs(fs, names) {
|
|
|
4740
4762
|
readlink: (path) => fs.readlink(path),
|
|
4741
4763
|
chmod: (path, mode) => fs.chmod(path, mode),
|
|
4742
4764
|
utimes: (path, atime, mtime) => fs.utimes(path, atime, mtime),
|
|
4765
|
+
lutimes: (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
|
|
4743
4766
|
...rangedOps(fs) ?? {}
|
|
4744
4767
|
};
|
|
4745
4768
|
}
|
|
@@ -4815,7 +4838,11 @@ var FsWatchers = class {
|
|
|
4815
4838
|
rename: after(fs.rename.bind(fs), (from, to) => [from, to]),
|
|
4816
4839
|
symlink: after(fs.symlink.bind(fs), (_target, path) => [path]),
|
|
4817
4840
|
chmod: after(fs.chmod.bind(fs), (path) => [path]),
|
|
4818
|
-
utimes: after(fs.utimes.bind(fs), (path) => [path])
|
|
4841
|
+
utimes: after(fs.utimes.bind(fs), (path) => [path]),
|
|
4842
|
+
lutimes: after(
|
|
4843
|
+
(path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
|
|
4844
|
+
(path) => [path]
|
|
4845
|
+
)
|
|
4819
4846
|
};
|
|
4820
4847
|
const ranged2 = rangedOps(fs);
|
|
4821
4848
|
if (ranged2) {
|
|
@@ -5743,10 +5770,23 @@ var MountFs = class {
|
|
|
5743
5770
|
await found.mount.conn.call({ op: "setattr", path: found.rel, mode });
|
|
5744
5771
|
}
|
|
5745
5772
|
async utimes(path, atime, mtime) {
|
|
5773
|
+
const real = await this.follow(path);
|
|
5774
|
+
const found = this.at(real);
|
|
5775
|
+
if (!found) return this.base.utimes(real, atime, mtime);
|
|
5776
|
+
await this.setMtime(found, real, mtime);
|
|
5777
|
+
}
|
|
5778
|
+
async lutimes(path, atime, mtime) {
|
|
5746
5779
|
const found = this.at(path);
|
|
5747
|
-
if (!found) return this.base
|
|
5748
|
-
|
|
5749
|
-
|
|
5780
|
+
if (!found) return lutimesOf(this.base, path, atime, mtime);
|
|
5781
|
+
const real = normalizePath(path);
|
|
5782
|
+
if (!found.mount.caps.linkTimes && (await this.lstat(real)).isSymbolicLink) {
|
|
5783
|
+
throw errnoError("EOPNOTSUPP", path);
|
|
5784
|
+
}
|
|
5785
|
+
await this.setMtime(found, real, mtime);
|
|
5786
|
+
}
|
|
5787
|
+
async setMtime(found, real, mtime) {
|
|
5788
|
+
this.writable(found.mount, real);
|
|
5789
|
+
this.table.forget(found.mount, real);
|
|
5750
5790
|
await found.mount.conn.call({ op: "setattr", path: found.rel, mtime: mtime.getTime() });
|
|
5751
5791
|
}
|
|
5752
5792
|
};
|
|
@@ -5860,6 +5900,9 @@ async function run(entry, path, req) {
|
|
|
5860
5900
|
case "utimes":
|
|
5861
5901
|
await fs.utimes(path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
|
|
5862
5902
|
return done;
|
|
5903
|
+
case "lutimes":
|
|
5904
|
+
await lutimesOf(fs, path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
|
|
5905
|
+
return done;
|
|
5863
5906
|
case "pread":
|
|
5864
5907
|
case "pwrite":
|
|
5865
5908
|
case "truncate":
|
|
@@ -7732,6 +7775,7 @@ var SYSCALL_OPS = /* @__PURE__ */ new Set([
|
|
|
7732
7775
|
"mount",
|
|
7733
7776
|
"umount",
|
|
7734
7777
|
"proc-exec",
|
|
7778
|
+
"proc-identity",
|
|
7735
7779
|
"proc-setpgid",
|
|
7736
7780
|
"proc-getpgid",
|
|
7737
7781
|
"proc-getsid",
|
|
@@ -7831,6 +7875,7 @@ var WasmProcess = class {
|
|
|
7831
7875
|
for (const listener of this.stateListeners) listener("continued", SIG.CONT);
|
|
7832
7876
|
}
|
|
7833
7877
|
async syscall(req) {
|
|
7878
|
+
this.options.onSyscall?.();
|
|
7834
7879
|
for (; ; ) {
|
|
7835
7880
|
await this.resumed;
|
|
7836
7881
|
const stops = this.stops;
|
|
@@ -8176,6 +8221,8 @@ var WasmProcess = class {
|
|
|
8176
8221
|
const waited = await this.children.wait(req.pid, req.nohang, signal, flags);
|
|
8177
8222
|
return { ok: true, kind: "json", json: waited };
|
|
8178
8223
|
}
|
|
8224
|
+
case "proc-identity":
|
|
8225
|
+
return { ok: true, kind: "json", json: await this.options.identity?.() ?? null };
|
|
8179
8226
|
case "proc-exec": {
|
|
8180
8227
|
this.execChild = req.pid;
|
|
8181
8228
|
this.options.jobs?.exec(this.pid, req.pid);
|
|
@@ -8326,6 +8373,8 @@ function spawnWasmProcess(opts) {
|
|
|
8326
8373
|
const header2 = new Int32Array(sab, 0, SAB_HEADER_I32);
|
|
8327
8374
|
const process = new WasmProcess(opts.pid, opts.fds, {
|
|
8328
8375
|
...opts.ignored ? { ignored: opts.ignored } : {},
|
|
8376
|
+
...opts.identity ? { identity: opts.identity } : {},
|
|
8377
|
+
...opts.onSyscall ? { onSyscall: opts.onSyscall } : {},
|
|
8329
8378
|
spawner: opts.spawner,
|
|
8330
8379
|
forker: opts.forker,
|
|
8331
8380
|
fs: opts.fs,
|
|
@@ -9798,6 +9847,7 @@ var ENV_REFERENCE = /\$\{([A-Za-z_][A-Za-z0-9_]*)\}/g;
|
|
|
9798
9847
|
var WASM_MAGIC = [0, 97, 115, 109];
|
|
9799
9848
|
var SHEBANG_MAX = 256;
|
|
9800
9849
|
var NOT_FOUND = 127;
|
|
9850
|
+
var DECIDE_MS = 100;
|
|
9801
9851
|
var INIT_PID = 1;
|
|
9802
9852
|
var SHARED_DIRS = ["/tmp", "/home"];
|
|
9803
9853
|
var encoder3 = new TextEncoder();
|
|
@@ -9896,6 +9946,8 @@ var Launcher = class {
|
|
|
9896
9946
|
fstabRetries;
|
|
9897
9947
|
inserted = /* @__PURE__ */ new Map();
|
|
9898
9948
|
openFiles = /* @__PURE__ */ new Set();
|
|
9949
|
+
deciding = /* @__PURE__ */ new Map();
|
|
9950
|
+
identities = { asked: 0, timedOut: 0 };
|
|
9899
9951
|
nodes;
|
|
9900
9952
|
held = /* @__PURE__ */ new Set();
|
|
9901
9953
|
processMounts;
|
|
@@ -10102,8 +10154,19 @@ var Launcher = class {
|
|
|
10102
10154
|
}
|
|
10103
10155
|
const pid = this.nextPid++;
|
|
10104
10156
|
const terminal = req.fds.stdioTerminal();
|
|
10157
|
+
const decided = req.decided ?? Promise.resolve(true);
|
|
10158
|
+
const count = (byParent) => {
|
|
10159
|
+
this.identities.asked++;
|
|
10160
|
+
if (!byParent) this.identities.timedOut++;
|
|
10161
|
+
};
|
|
10162
|
+
let asked;
|
|
10105
10163
|
const handle = spawnWasmProcess({
|
|
10106
10164
|
pid,
|
|
10165
|
+
identity: async () => {
|
|
10166
|
+
await (asked ??= decided.then(count));
|
|
10167
|
+
return this.identityOf(pid);
|
|
10168
|
+
},
|
|
10169
|
+
onSyscall: () => this.decide(pid),
|
|
10107
10170
|
...req.ignored ? { ignored: req.ignored } : {},
|
|
10108
10171
|
program: req.program,
|
|
10109
10172
|
argv0: req.argv0,
|
|
@@ -10176,7 +10239,8 @@ var Launcher = class {
|
|
|
10176
10239
|
};
|
|
10177
10240
|
const shown = (pid) => {
|
|
10178
10241
|
const member = pid === void 0 ? void 0 : members.get(pid);
|
|
10179
|
-
|
|
10242
|
+
const root = member && rootOf(member).pid;
|
|
10243
|
+
return root !== void 0 && this.running(root) ? root : INIT_PID;
|
|
10180
10244
|
};
|
|
10181
10245
|
const listed = [];
|
|
10182
10246
|
for (const member of members.values()) {
|
|
@@ -10205,7 +10269,9 @@ var Launcher = class {
|
|
|
10205
10269
|
throw new SpawnError(await this.unrunnable(req.file, req.cwd));
|
|
10206
10270
|
}
|
|
10207
10271
|
const exec = req.exec ? { exec: true } : {};
|
|
10272
|
+
const deciding = req.exec ? void 0 : this.undecided(ppid);
|
|
10208
10273
|
const handle = await this.launch(planned, {
|
|
10274
|
+
...deciding ? { decided: deciding.promise } : {},
|
|
10209
10275
|
env: req.env,
|
|
10210
10276
|
cwd: req.cwd,
|
|
10211
10277
|
fds,
|
|
@@ -10214,9 +10280,39 @@ var Launcher = class {
|
|
|
10214
10280
|
ignored: this.ignoredBy(ppid),
|
|
10215
10281
|
...exec
|
|
10216
10282
|
});
|
|
10283
|
+
deciding?.attach();
|
|
10217
10284
|
return childHandle(handle);
|
|
10218
10285
|
};
|
|
10219
10286
|
}
|
|
10287
|
+
undecided(ppid) {
|
|
10288
|
+
const decided = Promise.withResolvers();
|
|
10289
|
+
return {
|
|
10290
|
+
promise: decided.promise,
|
|
10291
|
+
attach: () => {
|
|
10292
|
+
const timer = setTimeout(() => decided.resolve(false), DECIDE_MS);
|
|
10293
|
+
void decided.promise.then(() => clearTimeout(timer));
|
|
10294
|
+
const waiting = this.deciding.get(ppid) ?? /* @__PURE__ */ new Set();
|
|
10295
|
+
waiting.add(decided.resolve);
|
|
10296
|
+
this.deciding.set(ppid, waiting);
|
|
10297
|
+
}
|
|
10298
|
+
};
|
|
10299
|
+
}
|
|
10300
|
+
identityOf(pid) {
|
|
10301
|
+
const parent = this.jobs.shownParent(pid);
|
|
10302
|
+
const alive = parent !== void 0 && this.running(parent);
|
|
10303
|
+
return { pid: this.jobs.shown(pid), ppid: alive ? parent : INIT_PID };
|
|
10304
|
+
}
|
|
10305
|
+
running(shown) {
|
|
10306
|
+
return this.jobs.list().some((member) => !this.zombies.has(member.pid) && this.jobs.shown(member.pid) === shown);
|
|
10307
|
+
}
|
|
10308
|
+
decide(ppid) {
|
|
10309
|
+
const waiting = this.deciding.get(ppid);
|
|
10310
|
+
if (!waiting) return;
|
|
10311
|
+
this.deciding.delete(ppid);
|
|
10312
|
+
setTimeout(() => {
|
|
10313
|
+
for (const resolve of waiting) resolve(true);
|
|
10314
|
+
}, 0);
|
|
10315
|
+
}
|
|
10220
10316
|
forker(ppid, parent) {
|
|
10221
10317
|
const { exec: _exec, ...image } = parent;
|
|
10222
10318
|
return async (state, fds) => childHandle(
|
|
@@ -10258,7 +10354,7 @@ var Launcher = class {
|
|
|
10258
10354
|
serveFilesystem(
|
|
10259
10355
|
port2,
|
|
10260
10356
|
tmpfs(),
|
|
10261
|
-
{ symlinks: true, chmod: true, ranges: true, attrTtl: 0 },
|
|
10357
|
+
{ symlinks: true, chmod: true, linkTimes: true, ranges: true, attrTtl: 0 },
|
|
10262
10358
|
{ owned: true }
|
|
10263
10359
|
);
|
|
10264
10360
|
return {
|