@ai-ecoverse/slicc-kernel 1.146.4 → 1.146.7
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 +97 -23
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +4 -2
- package/dist/node-process-worker.js.map +2 -2
- package/dist/node.js +97 -23
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +4 -2
- package/dist/process-worker.js.map +2 -2
- package/dist/types/fs/opfs.d.ts +1 -0
- package/dist/types/kernel/process.d.ts +2 -0
- package/dist/types/process/kernel-streams.d.ts +1 -0
- package/package.json +3 -3
package/dist/kernel-worker.js
CHANGED
|
@@ -1376,6 +1376,28 @@ function prefixes(path) {
|
|
|
1376
1376
|
function within2(path, root) {
|
|
1377
1377
|
return path === root || path.startsWith(`${root}/`);
|
|
1378
1378
|
}
|
|
1379
|
+
var unstored = () => Object.assign(new Error("the file system kept fewer bytes than were written"), {
|
|
1380
|
+
code: "ENOSPC"
|
|
1381
|
+
});
|
|
1382
|
+
var CHECKED_BYTES = 16 * 1024 * 1024;
|
|
1383
|
+
var Extent = class {
|
|
1384
|
+
floor = 0;
|
|
1385
|
+
exact;
|
|
1386
|
+
wrote(end) {
|
|
1387
|
+
this.floor = Math.max(this.floor, end);
|
|
1388
|
+
if (this.exact !== void 0) this.exact = Math.max(this.exact, end);
|
|
1389
|
+
}
|
|
1390
|
+
cut(size) {
|
|
1391
|
+
this.exact = size;
|
|
1392
|
+
this.floor = Math.min(this.floor, size);
|
|
1393
|
+
}
|
|
1394
|
+
big() {
|
|
1395
|
+
return Math.max(this.floor, this.exact ?? 0) >= CHECKED_BYTES;
|
|
1396
|
+
}
|
|
1397
|
+
check(size) {
|
|
1398
|
+
if (size < this.floor || this.exact !== void 0 && size < this.exact) throw unstored();
|
|
1399
|
+
}
|
|
1400
|
+
};
|
|
1379
1401
|
var LOCKED = /* @__PURE__ */ new Set(["NotReadableError", "NoModificationAllowedError", "InvalidStateError"]);
|
|
1380
1402
|
var SYNC_BACKOFF_MS = [5, 10, 20, 40, 80];
|
|
1381
1403
|
async function openSync(handle) {
|
|
@@ -1401,14 +1423,22 @@ function writeAll(access2, at, bytes) {
|
|
|
1401
1423
|
}
|
|
1402
1424
|
}
|
|
1403
1425
|
async function positioned(handle, op) {
|
|
1426
|
+
const extent = new Extent();
|
|
1404
1427
|
const access2 = await openSync(handle);
|
|
1405
1428
|
if (access2) {
|
|
1406
1429
|
try {
|
|
1407
1430
|
op({
|
|
1408
|
-
write: (at, bytes) =>
|
|
1409
|
-
|
|
1431
|
+
write: (at, bytes) => {
|
|
1432
|
+
writeAll(access2, at, bytes);
|
|
1433
|
+
extent.wrote(at + bytes.length);
|
|
1434
|
+
},
|
|
1435
|
+
truncate: (n) => {
|
|
1436
|
+
access2.truncate(n);
|
|
1437
|
+
extent.cut(n);
|
|
1438
|
+
}
|
|
1410
1439
|
});
|
|
1411
1440
|
access2.flush();
|
|
1441
|
+
if (access2.getSize) extent.check(access2.getSize());
|
|
1412
1442
|
} finally {
|
|
1413
1443
|
access2.close();
|
|
1414
1444
|
}
|
|
@@ -1417,14 +1447,25 @@ async function positioned(handle, op) {
|
|
|
1417
1447
|
const writable2 = await handle.createWritable({ keepExistingData: true });
|
|
1418
1448
|
try {
|
|
1419
1449
|
await op({
|
|
1420
|
-
write: (at, bytes) =>
|
|
1421
|
-
|
|
1450
|
+
write: async (at, bytes) => {
|
|
1451
|
+
await writable2.write({
|
|
1452
|
+
type: "write",
|
|
1453
|
+
position: at,
|
|
1454
|
+
data: bytes
|
|
1455
|
+
});
|
|
1456
|
+
extent.wrote(at + bytes.length);
|
|
1457
|
+
},
|
|
1458
|
+
truncate: async (n) => {
|
|
1459
|
+
await writable2.truncate(n);
|
|
1460
|
+
extent.cut(n);
|
|
1461
|
+
}
|
|
1422
1462
|
});
|
|
1423
1463
|
} catch (err) {
|
|
1424
1464
|
await writable2.abort();
|
|
1425
1465
|
throw err;
|
|
1426
1466
|
}
|
|
1427
1467
|
await writable2.close();
|
|
1468
|
+
if (extent.big()) extent.check((await handle.getFile()).size);
|
|
1428
1469
|
}
|
|
1429
1470
|
function syncAccessHandles(scope = globalThis) {
|
|
1430
1471
|
const handle = scope.FileSystemFileHandle;
|
|
@@ -2403,6 +2444,11 @@ var OpfsFs = class {
|
|
|
2403
2444
|
writable2 = await this.io(file.createWritable());
|
|
2404
2445
|
await writable2.write(content);
|
|
2405
2446
|
await writable2.close();
|
|
2447
|
+
if (typeof content !== "string" && content.length >= CHECKED_BYTES) {
|
|
2448
|
+
const extent = new Extent();
|
|
2449
|
+
extent.cut(content.length);
|
|
2450
|
+
extent.check((await file.getFile()).size);
|
|
2451
|
+
}
|
|
2406
2452
|
} catch (err) {
|
|
2407
2453
|
await writable2?.abort().catch(() => void 0);
|
|
2408
2454
|
throw translate(err, path, "commit", false);
|
|
@@ -3175,13 +3221,7 @@ var OpfsFs = class {
|
|
|
3175
3221
|
}
|
|
3176
3222
|
}
|
|
3177
3223
|
async place(handle, dir, name2, copies) {
|
|
3178
|
-
|
|
3179
|
-
if (move) this.others++;
|
|
3180
|
-
const moved2 = await move?.call(handle, dir, name2).then(
|
|
3181
|
-
() => true,
|
|
3182
|
-
() => false
|
|
3183
|
-
);
|
|
3184
|
-
if (moved2) return true;
|
|
3224
|
+
if (await this.moved(handle, dir, name2)) return true;
|
|
3185
3225
|
const before = this.fileMoves;
|
|
3186
3226
|
try {
|
|
3187
3227
|
await this.copy(handle, dir, name2, copies);
|
|
@@ -3194,6 +3234,23 @@ var OpfsFs = class {
|
|
|
3194
3234
|
return false;
|
|
3195
3235
|
}
|
|
3196
3236
|
fileMoves = 0;
|
|
3237
|
+
async moved(handle, dir, name2) {
|
|
3238
|
+
const move = handle.move;
|
|
3239
|
+
if (!move) return false;
|
|
3240
|
+
for (let attempt = 0; ; attempt++) {
|
|
3241
|
+
this.others++;
|
|
3242
|
+
const failed3 = await move.call(handle, dir, name2).then(
|
|
3243
|
+
() => void 0,
|
|
3244
|
+
(err) => ({ err })
|
|
3245
|
+
);
|
|
3246
|
+
if (!failed3) return true;
|
|
3247
|
+
const error = failed3.err?.name;
|
|
3248
|
+
if (handle.kind !== "file" || !LOCKED.has(error)) return false;
|
|
3249
|
+
const delay = SYNC_BACKOFF_MS[attempt];
|
|
3250
|
+
if (delay === void 0) throw fsError("EBUSY", name2);
|
|
3251
|
+
await new Promise((resolve2) => setTimeout(resolve2, delay));
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3197
3254
|
async copy(handle, dir, name2, copies, rest2 = "") {
|
|
3198
3255
|
if (handle.kind === "file" && movable(handle)) {
|
|
3199
3256
|
this.others++;
|
|
@@ -7728,7 +7785,7 @@ function satisfies(version, range2) {
|
|
|
7728
7785
|
}
|
|
7729
7786
|
|
|
7730
7787
|
// src/version.ts
|
|
7731
|
-
var KERNEL_VERSION = true ? "1.146.
|
|
7788
|
+
var KERNEL_VERSION = true ? "1.146.7" : "0.0.0-dev";
|
|
7732
7789
|
var OS_RELEASE = "6.0.0-slicc";
|
|
7733
7790
|
function procVersion() {
|
|
7734
7791
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -23831,15 +23888,7 @@ var WasmProcess = class {
|
|
|
23831
23888
|
}
|
|
23832
23889
|
});
|
|
23833
23890
|
} else {
|
|
23834
|
-
await this.
|
|
23835
|
-
() => this.openPath(req, marked),
|
|
23836
|
-
async (at) => {
|
|
23837
|
-
await this.stillOpen(at, req.handle);
|
|
23838
|
-
return nodes.identify(at);
|
|
23839
|
-
},
|
|
23840
|
-
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...open2, path: at }, id2, fs)),
|
|
23841
|
-
{ at: path, gen }
|
|
23842
|
-
);
|
|
23891
|
+
await this.openExisting(req, marked, fd, open2, fs, { at: path, gen });
|
|
23843
23892
|
}
|
|
23844
23893
|
if (req.existing && !await present3(fs, path, true)) {
|
|
23845
23894
|
throw new KernelError("ENOENT");
|
|
@@ -23899,7 +23948,22 @@ var WasmProcess = class {
|
|
|
23899
23948
|
const inherited2 = req.orphan || req.contents !== void 0 || req.handle !== void 0;
|
|
23900
23949
|
if (guard2?.links === void 0 || !noLinks || inherited2 || req.pin !== void 0)
|
|
23901
23950
|
return void 0;
|
|
23902
|
-
|
|
23951
|
+
const follow2 = !req.exclusive && req.nofollow !== true;
|
|
23952
|
+
return (await walk(guard2.fs, this.cred, req.path, follow2, guard2.links)).path;
|
|
23953
|
+
}
|
|
23954
|
+
async openExisting(req, marked, fd, open2, fs, first) {
|
|
23955
|
+
const nodes = this.nodes;
|
|
23956
|
+
const own = unfollowed(req);
|
|
23957
|
+
await this.unmissed(
|
|
23958
|
+
this.openPath.bind(this, req, marked),
|
|
23959
|
+
async (at) => {
|
|
23960
|
+
if (own) await notLink(this.options.fs, at);
|
|
23961
|
+
await this.stillOpen(at, req.handle);
|
|
23962
|
+
return nodes.identify(at);
|
|
23963
|
+
},
|
|
23964
|
+
(id2, at) => this.fds.installAt(fd, this.openVfsFile({ ...open2, path: at }, id2, fs)),
|
|
23965
|
+
first
|
|
23966
|
+
);
|
|
23903
23967
|
}
|
|
23904
23968
|
async openPath(req, marked) {
|
|
23905
23969
|
const nodes = this.nodes;
|
|
@@ -23907,6 +23971,7 @@ var WasmProcess = class {
|
|
|
23907
23971
|
if (req.exclusive) return nodes.entryKey(marked ?? req.path);
|
|
23908
23972
|
if (marked !== void 0) return marked;
|
|
23909
23973
|
if (req.create) return nodes.targetKey(req.path);
|
|
23974
|
+
if (unfollowed(req)) return nodes.entryKey(req.path);
|
|
23910
23975
|
return this.keptOr(await nodes.targetKey(req.path), req.handle);
|
|
23911
23976
|
}
|
|
23912
23977
|
async mayOpen(req) {
|
|
@@ -24202,7 +24267,9 @@ var WasmProcess = class {
|
|
|
24202
24267
|
given = void 0;
|
|
24203
24268
|
await r?.settled(at);
|
|
24204
24269
|
const found = await look(at);
|
|
24205
|
-
if (!r || !r.missed(at) && !r.changedSince(at, gen)
|
|
24270
|
+
if (!r || !r.missed(at) && !r.changedSince(at, gen) && !r.inFlight?.(at)) {
|
|
24271
|
+
return make(found, at);
|
|
24272
|
+
}
|
|
24206
24273
|
}
|
|
24207
24274
|
}
|
|
24208
24275
|
async stillOpen(at, handle) {
|
|
@@ -24730,6 +24797,13 @@ var WasmProcess = class {
|
|
|
24730
24797
|
await this.options.http?.closeAll();
|
|
24731
24798
|
}
|
|
24732
24799
|
};
|
|
24800
|
+
function unfollowed(req) {
|
|
24801
|
+
return req.nofollow === true && req.handle === void 0;
|
|
24802
|
+
}
|
|
24803
|
+
async function notLink(fs, path) {
|
|
24804
|
+
const st = await fs.lstat?.(path);
|
|
24805
|
+
if (st?.isSymbolicLink) throw new KernelError("ELOOP");
|
|
24806
|
+
}
|
|
24733
24807
|
|
|
24734
24808
|
// src/kernel/protocol.ts
|
|
24735
24809
|
var WASM_PROCESS_INIT = "wasm-process-init";
|