@ai-ecoverse/slicc-kernel 1.196.24 → 1.196.26
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 +2 -2
- package/dist/async-process.js +1 -1
- package/dist/cloudflare-sources.js +1 -1
- package/dist/cloudflare.js +127 -14
- package/dist/cloudflare.js.map +3 -3
- package/dist/kernel-worker.js +127 -14
- package/dist/kernel-worker.js.map +3 -3
- package/dist/meta.js.map +2 -2
- package/dist/node-process-worker.cjs +1 -1
- package/dist/node-process-worker.js +1 -1
- package/dist/node.js +127 -14
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +1 -1
- package/dist/types/fs/meta.d.ts +2 -0
- package/dist/types/fs/opfs.d.ts +8 -0
- package/dist/types/fs/private-rename.d.ts +3 -1
- package/package.json +1 -1
package/dist/kernel-worker.js
CHANGED
|
@@ -861,6 +861,9 @@ var PrivatePaths = class {
|
|
|
861
861
|
}
|
|
862
862
|
return false;
|
|
863
863
|
}
|
|
864
|
+
get openSession() {
|
|
865
|
+
return this.bound;
|
|
866
|
+
}
|
|
864
867
|
bind(path) {
|
|
865
868
|
if (this.shifted) return;
|
|
866
869
|
this.names.clear();
|
|
@@ -937,7 +940,14 @@ var PrivateRename = class {
|
|
|
937
940
|
moved(from, to) {
|
|
938
941
|
for (const op of this.active) op.moved(from, to);
|
|
939
942
|
}
|
|
940
|
-
async
|
|
943
|
+
async drain(op, native) {
|
|
944
|
+
const draining = this.barriers.get(op);
|
|
945
|
+
await this.wait(
|
|
946
|
+
() => ![...draining].some((active) => this.active.has(active) && !(native && active.openSession)),
|
|
947
|
+
DRAIN_MS
|
|
948
|
+
);
|
|
949
|
+
}
|
|
950
|
+
async exclusive(op, run2, native = false) {
|
|
941
951
|
const draining = /* @__PURE__ */ new Set();
|
|
942
952
|
await this.wait(() => {
|
|
943
953
|
if (this.blocked(op)) return false;
|
|
@@ -946,7 +956,7 @@ var PrivateRename = class {
|
|
|
946
956
|
return true;
|
|
947
957
|
}, ADMISSION_MS);
|
|
948
958
|
try {
|
|
949
|
-
await this.
|
|
959
|
+
await this.drain(op, native);
|
|
950
960
|
return await run2();
|
|
951
961
|
} finally {
|
|
952
962
|
this.barriers.delete(op);
|
|
@@ -1899,6 +1909,7 @@ var LISTINGS = /* @__PURE__ */ new Set(["readdir", "readdirStat"]);
|
|
|
1899
1909
|
var REMOVALS = /* @__PURE__ */ new Set(["rm", "rename"]);
|
|
1900
1910
|
var RETRY = /* @__PURE__ */ Symbol("retry");
|
|
1901
1911
|
var PRIVATE_COPY = /* @__PURE__ */ Symbol("private-copy");
|
|
1912
|
+
var PRIVATE_NATIVE = /* @__PURE__ */ Symbol("private-native");
|
|
1902
1913
|
var ACK_SAMPLES = 4096;
|
|
1903
1914
|
var INTENT_POLL_MS = 5;
|
|
1904
1915
|
function needsCopy(handle, swap) {
|
|
@@ -3315,6 +3326,9 @@ var OpfsFs = class {
|
|
|
3315
3326
|
const name2 = baseOf(link2.path);
|
|
3316
3327
|
if (!children3.has(name2)) children3.set(name2, link2);
|
|
3317
3328
|
}
|
|
3329
|
+
for (const backup of this.hiddenBackups) {
|
|
3330
|
+
if (parentOf4(backup) === found.path) children3.delete(baseOf(backup));
|
|
3331
|
+
}
|
|
3318
3332
|
return [found.path, [...children3].sort(([a], [b]) => a < b ? -1 : 1)];
|
|
3319
3333
|
}
|
|
3320
3334
|
async readdir(path) {
|
|
@@ -3984,6 +3998,7 @@ var OpfsFs = class {
|
|
|
3984
3998
|
await gate.enter(op);
|
|
3985
3999
|
const leave = () => gate.leave(op);
|
|
3986
4000
|
let sessionOwnsAdmission = false;
|
|
4001
|
+
let native = false;
|
|
3987
4002
|
try {
|
|
3988
4003
|
if (name2 === "writeSession") {
|
|
3989
4004
|
const session = await inner.apply(inside2, args);
|
|
@@ -3995,21 +4010,50 @@ var OpfsFs = class {
|
|
|
3995
4010
|
try {
|
|
3996
4011
|
return await inner.apply(inside2, args);
|
|
3997
4012
|
} catch (err) {
|
|
3998
|
-
|
|
4013
|
+
native = err === PRIVATE_NATIVE;
|
|
4014
|
+
if (!native && err !== PRIVATE_COPY) throw err;
|
|
3999
4015
|
}
|
|
4000
4016
|
} finally {
|
|
4001
4017
|
if (!sessionOwnsAdmission) leave();
|
|
4002
4018
|
}
|
|
4003
|
-
const exclusive = view(inside2, {
|
|
4004
|
-
|
|
4019
|
+
const exclusive = view(inside2, {
|
|
4020
|
+
privateCopyReady: true,
|
|
4021
|
+
beforePrivateCopy: () => gate.drain(op, false)
|
|
4022
|
+
});
|
|
4023
|
+
return gate.exclusive(op, () => inner.apply(exclusive, args), native);
|
|
4024
|
+
}
|
|
4025
|
+
swapEntry(path) {
|
|
4026
|
+
return this.exactly(() => this.handle(path)).catch((err) => {
|
|
4027
|
+
if (!missing2(err)) throw err;
|
|
4028
|
+
return void 0;
|
|
4029
|
+
});
|
|
4005
4030
|
}
|
|
4006
4031
|
privateCopyReady = false;
|
|
4032
|
+
beforePrivateCopy;
|
|
4007
4033
|
usePrivateCopy(handle, staging) {
|
|
4008
4034
|
if (!this.privateRename) return false;
|
|
4009
4035
|
if (this.privateCopyReady) return true;
|
|
4036
|
+
if (staging && movable(handle)) throw PRIVATE_NATIVE;
|
|
4010
4037
|
if (staging || !movable(handle)) throw PRIVATE_COPY;
|
|
4011
4038
|
return false;
|
|
4012
4039
|
}
|
|
4040
|
+
async swapNative(source, parent, name2, target, emptyBackup, intent) {
|
|
4041
|
+
let staged2 = false;
|
|
4042
|
+
const reset = async () => {
|
|
4043
|
+
if (staged2 && !await this.moved(target, parent, name2, false)) throw fsError("EIO", name2);
|
|
4044
|
+
await this.dropSwapIntent(intent, emptyBackup);
|
|
4045
|
+
};
|
|
4046
|
+
try {
|
|
4047
|
+
staged2 = await this.moved(target, parent, baseOf(emptyBackup), false);
|
|
4048
|
+
if (staged2) this.forget(resolvePath(parentOf4(emptyBackup), name2));
|
|
4049
|
+
if (staged2 && await this.moved(source.handle, parent, name2, false)) return true;
|
|
4050
|
+
} catch (err) {
|
|
4051
|
+
await reset();
|
|
4052
|
+
throw err;
|
|
4053
|
+
}
|
|
4054
|
+
await reset();
|
|
4055
|
+
return false;
|
|
4056
|
+
}
|
|
4013
4057
|
async privateCopy(source, parent, to, target, owner) {
|
|
4014
4058
|
const handle = source.handle;
|
|
4015
4059
|
const dir = parent.handle;
|
|
@@ -4017,6 +4061,18 @@ var OpfsFs = class {
|
|
|
4017
4061
|
const copies = /* @__PURE__ */ new Map();
|
|
4018
4062
|
const [entry] = await this.meta.get([source.path]);
|
|
4019
4063
|
const root = { ino: occupied(entry).ino ?? inodeOf(source.path), ...owner };
|
|
4064
|
+
if (target?.kind === "directory" && movable(target) && movable(handle)) {
|
|
4065
|
+
const backup = ".slicc-empty-" + crypto.randomUUID();
|
|
4066
|
+
const emptyBackup = resolvePath(parent.path, backup);
|
|
4067
|
+
const intent2 = await this.intend({ from: source.path, to, root, emptyBackup });
|
|
4068
|
+
if (await this.swapNative(source, dir, name2, target, emptyBackup, intent2)) {
|
|
4069
|
+
this.forget(source.path);
|
|
4070
|
+
this.forget(to);
|
|
4071
|
+
await this.commitPrivateCopy(source.path, to, root, intent2, copies, emptyBackup);
|
|
4072
|
+
return;
|
|
4073
|
+
}
|
|
4074
|
+
}
|
|
4075
|
+
await this.beforePrivateCopy?.();
|
|
4020
4076
|
const intent = await this.intend({ from: source.path, to, root, privateCopy: true });
|
|
4021
4077
|
try {
|
|
4022
4078
|
await this.duplicate(handle, dir, name2, copies, "");
|
|
@@ -4035,7 +4091,24 @@ var OpfsFs = class {
|
|
|
4035
4091
|
}
|
|
4036
4092
|
await this.commitPrivateCopy(source.path, to, root, intent, copies);
|
|
4037
4093
|
}
|
|
4038
|
-
async
|
|
4094
|
+
async dropSwapIntent(intent, backup) {
|
|
4095
|
+
await this.meta.update(intent, () => void 0);
|
|
4096
|
+
this.hiddenBackups.delete(backup);
|
|
4097
|
+
}
|
|
4098
|
+
async cleanSwapIntent(intent, backup) {
|
|
4099
|
+
try {
|
|
4100
|
+
await this.clearPrivateBackup(backup);
|
|
4101
|
+
} catch {
|
|
4102
|
+
return;
|
|
4103
|
+
}
|
|
4104
|
+
await this.dropSwapIntent(intent, backup);
|
|
4105
|
+
}
|
|
4106
|
+
async clearPrivateBackup(backup) {
|
|
4107
|
+
await this.removePhysical(backup, false).catch((err) => {
|
|
4108
|
+
if (!missing2(err)) throw err;
|
|
4109
|
+
});
|
|
4110
|
+
}
|
|
4111
|
+
async commitPrivateCopy(from, to, root, intent, copies, emptyBackup) {
|
|
4039
4112
|
const { ino, ...owner } = root;
|
|
4040
4113
|
const entries = await this.meta.get([from, to]);
|
|
4041
4114
|
if (!entries[0]?.vacated || entries[1]?.ino !== ino) {
|
|
@@ -4047,11 +4120,15 @@ var OpfsFs = class {
|
|
|
4047
4120
|
);
|
|
4048
4121
|
}
|
|
4049
4122
|
this.movePending(from, to);
|
|
4050
|
-
await this.removePhysical(from, true);
|
|
4051
|
-
await this.meta.update(intent, () => void 0);
|
|
4123
|
+
if (!emptyBackup) await this.removePhysical(from, true);
|
|
4052
4124
|
await this.restamp(to, copies);
|
|
4053
4125
|
this.changed(from, to);
|
|
4054
4126
|
this.touch(Date.now(), parentOf4(from), parentOf4(to));
|
|
4127
|
+
if (emptyBackup) {
|
|
4128
|
+
await this.intend({ from, to, root, emptyBackup, cleanupOnly: true }, intent);
|
|
4129
|
+
return this.cleanSwapIntent(intent, emptyBackup);
|
|
4130
|
+
}
|
|
4131
|
+
await this.meta.update(intent, () => void 0);
|
|
4055
4132
|
}
|
|
4056
4133
|
async duplicate(handle, parent, name2, copies, rest2) {
|
|
4057
4134
|
if (handle.kind === "file") return this.copyBytes(handle, parent, name2, { copies }, rest2);
|
|
@@ -4060,11 +4137,13 @@ var OpfsFs = class {
|
|
|
4060
4137
|
for await (const child2 of handle.values())
|
|
4061
4138
|
await this.duplicate(child2, dir, child2.name, copies, rest2 + "/" + child2.name);
|
|
4062
4139
|
}
|
|
4140
|
+
hiddenBackups = /* @__PURE__ */ new Set();
|
|
4063
4141
|
renamingDirs = /* @__PURE__ */ new Set();
|
|
4064
4142
|
intents = 0;
|
|
4065
4143
|
async intend(rename, at = `${RENAMES2}/${crypto.randomUUID()}`) {
|
|
4066
4144
|
const record3 = { ...rename, at: Date.now() * 1e3 + this.intents++ % 1e3 };
|
|
4067
4145
|
await this.meta.update(at, () => ({ path: at, rename: record3 }));
|
|
4146
|
+
if (rename.emptyBackup) this.hiddenBackups.add(rename.emptyBackup);
|
|
4068
4147
|
return at;
|
|
4069
4148
|
}
|
|
4070
4149
|
async rollBack(from, to, intents) {
|
|
@@ -4111,16 +4190,50 @@ var OpfsFs = class {
|
|
|
4111
4190
|
}
|
|
4112
4191
|
return intents.length;
|
|
4113
4192
|
}
|
|
4193
|
+
async finishPrivateSwap(intent, from, to, root, backup, left) {
|
|
4194
|
+
const [src, dest] = await this.meta.get([from, to]);
|
|
4195
|
+
if (dest?.ino === root.ino && (src?.vacated || src?.ino !== root.ino)) {
|
|
4196
|
+
await this.intend({ from, to, root, emptyBackup: backup, cleanupOnly: true }, intent);
|
|
4197
|
+
return this.cleanSwapIntent(intent, backup);
|
|
4198
|
+
}
|
|
4199
|
+
if (!left) {
|
|
4200
|
+
if ((await this.swapEntry(to))?.kind !== "directory") throw fsError("EIO", to);
|
|
4201
|
+
return this.commitPrivateCopy(from, to, root, intent, /* @__PURE__ */ new Map(), backup);
|
|
4202
|
+
}
|
|
4203
|
+
const staged2 = await this.swapEntry(backup);
|
|
4204
|
+
if (staged2) {
|
|
4205
|
+
if (await this.swapEntry(to)) {
|
|
4206
|
+
await this.intend({ from, to, root, emptyBackup: backup, cleanupOnly: true }, intent);
|
|
4207
|
+
return this.cleanSwapIntent(intent, backup);
|
|
4208
|
+
}
|
|
4209
|
+
const dir = await this.dir(parentOf4(to));
|
|
4210
|
+
if (!await this.moved(staged2, dir, baseOf(to), false)) throw fsError("EIO", to);
|
|
4211
|
+
}
|
|
4212
|
+
await this.dropSwapIntent(intent, backup);
|
|
4213
|
+
}
|
|
4114
4214
|
async finishRename(entry) {
|
|
4115
4215
|
const [current] = await this.meta.under(entry.path);
|
|
4116
4216
|
if (current?.rename === void 0) return;
|
|
4117
|
-
const { from, to, replace, root } = current.rename;
|
|
4217
|
+
const { from, to, replace, root, emptyBackup, cleanupOnly } = current.rename;
|
|
4218
|
+
if (emptyBackup) this.hiddenBackups.add(emptyBackup);
|
|
4219
|
+
if (emptyBackup && cleanupOnly) return this.cleanSwapIntent(entry.path, emptyBackup);
|
|
4118
4220
|
const { promise, resolve: resolve2 } = Promise.withResolvers();
|
|
4119
4221
|
const barrier = { from, to, done: promise };
|
|
4120
4222
|
this.renamingDirs.add(barrier);
|
|
4121
4223
|
this.forget(from);
|
|
4122
4224
|
this.forget(to);
|
|
4123
4225
|
try {
|
|
4226
|
+
if (current.rename.emptyBackup && root) {
|
|
4227
|
+
await this.finishPrivateSwap(
|
|
4228
|
+
entry.path,
|
|
4229
|
+
from,
|
|
4230
|
+
to,
|
|
4231
|
+
root,
|
|
4232
|
+
current.rename.emptyBackup,
|
|
4233
|
+
!!await this.swapEntry(from)
|
|
4234
|
+
);
|
|
4235
|
+
return;
|
|
4236
|
+
}
|
|
4124
4237
|
const left = await this.real(from);
|
|
4125
4238
|
if (current.rename.privateCopy) {
|
|
4126
4239
|
if (left) {
|
|
@@ -4505,7 +4618,9 @@ var OpfsFs = class {
|
|
|
4505
4618
|
let removed = 0;
|
|
4506
4619
|
const entries = await this.meta.all();
|
|
4507
4620
|
const carried = new Set(entries.filter((e) => !e.vacated).map((e) => e.ino));
|
|
4508
|
-
const checked = entries.filter(
|
|
4621
|
+
const checked = entries.filter(
|
|
4622
|
+
(e) => !e.rename && !(e.vacated && carried.has(inodeOf(e.path)))
|
|
4623
|
+
);
|
|
4509
4624
|
const real = await this.present(
|
|
4510
4625
|
checked.flatMap((e) => e.link === void 0 ? [e.path] : [e.path, parentOf4(e.path)])
|
|
4511
4626
|
);
|
|
@@ -9883,7 +9998,7 @@ function satisfies(version, range2) {
|
|
|
9883
9998
|
}
|
|
9884
9999
|
|
|
9885
10000
|
// src/version.ts
|
|
9886
|
-
var KERNEL_VERSION = true ? "1.196.
|
|
10001
|
+
var KERNEL_VERSION = true ? "1.196.26" : "0.0.0-dev";
|
|
9887
10002
|
var OS_RELEASE = "6.0.0-slicc";
|
|
9888
10003
|
function procVersion() {
|
|
9889
10004
|
return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
|
|
@@ -24273,9 +24388,7 @@ ${SCRIPT_HELP}
|
|
|
24273
24388
|
return DONE;
|
|
24274
24389
|
}
|
|
24275
24390
|
if (parsed3.nonInteractive) return failed2("EPERM", "sudo: a password is required");
|
|
24276
|
-
const cwd = await this.canonical(dir, s.caller.cred);
|
|
24277
|
-
if (cwd === void 0)
|
|
24278
|
-
return failed2("EACCES", `sudo: cannot run in ${dir}: it isn't a directory you can enter`);
|
|
24391
|
+
const cwd = await this.canonical(dir, s.caller.cred) ?? "";
|
|
24279
24392
|
return this.pendingFor(s.caller.cred.ruid, async () => {
|
|
24280
24393
|
const answer2 = await this.ask(s, { argv: [], path: "", cwd, bound: {}, validate: true });
|
|
24281
24394
|
if ("error" in answer2) return answer2;
|