@ai-ecoverse/slicc-kernel 1.140.1 → 1.140.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/dist/node.js CHANGED
@@ -7514,7 +7514,7 @@ function satisfies(version, range2) {
7514
7514
  }
7515
7515
 
7516
7516
  // src/version.ts
7517
- var KERNEL_VERSION = true ? "1.140.1" : "0.0.0-dev";
7517
+ var KERNEL_VERSION = true ? "1.140.2" : "0.0.0-dev";
7518
7518
  var OS_RELEASE = "6.0.0-slicc";
7519
7519
  function procVersion() {
7520
7520
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9819,6 +9819,9 @@ function devCreation(path, cred) {
9819
9819
  // src/fs/etc-files.ts
9820
9820
  var HOSTNAME_PATH = "/etc/hostname";
9821
9821
  var S_IFREG3 = 32768;
9822
+ var MAX_HOPS2 = 40;
9823
+ var parentOf6 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
9824
+ var baseOf2 = (path) => path.slice(path.lastIndexOf("/") + 1);
9822
9825
  function missing4(err) {
9823
9826
  return err?.code === "ENOENT";
9824
9827
  }
@@ -9839,21 +9842,53 @@ function statOf(path, bytes) {
9839
9842
  gid: 0
9840
9843
  };
9841
9844
  }
9845
+ function linkFollower(fs, files) {
9846
+ const bases = new Set([...files.keys()].map(baseOf2));
9847
+ const linkOf2 = (path) => fs.readlink(path).then(
9848
+ (link2) => link2,
9849
+ () => void 0
9850
+ );
9851
+ const viaParent = async (path) => {
9852
+ if (!bases.has(baseOf2(path)) || !fs.realpath) return path;
9853
+ const parent = parentOf6(path);
9854
+ const dir = await fs.realpath(parent, true).catch(() => parent);
9855
+ return fs.resolvePath(dir, baseOf2(path));
9856
+ };
9857
+ return async (path) => {
9858
+ let current = path;
9859
+ for (let hop = 0; hop < MAX_HOPS2 && !files.has(current); hop++) {
9860
+ const link2 = await linkOf2(current);
9861
+ if (link2 === void 0) return viaParent(current);
9862
+ current = fs.resolvePath(parentOf6(current), link2);
9863
+ }
9864
+ return current;
9865
+ };
9866
+ }
9867
+ function materializer(fs, listedAbsent) {
9868
+ return async (path) => {
9869
+ const bytes = await listedAbsent(path);
9870
+ if (bytes !== void 0) await fs.writeFile(path, bytes);
9871
+ };
9872
+ }
9842
9873
  function withEtcFiles(fs, files) {
9843
9874
  const bytesOf4 = (path) => {
9844
9875
  const text = files.get(path)?.();
9845
9876
  return text === void 0 ? void 0 : new TextEncoder().encode(text);
9846
9877
  };
9847
9878
  const absent2 = (path) => fs.lstat(path).then(() => false, missing4);
9879
+ const follow2 = linkFollower(fs, files);
9880
+ const listedAbsent = async (path) => files.has(path) && await absent2(path) ? bytesOf4(path) : void 0;
9848
9881
  const fallback = (path, make) => async (err) => {
9849
- const bytes = missing4(err) && files.has(path) && await absent2(path) ? bytesOf4(path) : void 0;
9850
- if (bytes === void 0) throw err;
9851
- return make(bytes);
9882
+ const at = missing4(err) ? await follow2(path) : void 0;
9883
+ const bytes = at === void 0 ? void 0 : await listedAbsent(at);
9884
+ if (bytes === void 0 || at === void 0) throw err;
9885
+ return make(bytes, at);
9852
9886
  };
9853
9887
  const ranged2 = rangedOps(fs);
9888
+ const materialize = materializer(fs, listedAbsent);
9854
9889
  const own = {
9855
- stat: (path) => fs.stat(path).catch(fallback(path, (b) => statOf(path, b))),
9856
- lstat: (path) => fs.lstat(path).catch(fallback(path, (b) => statOf(path, b))),
9890
+ stat: (path) => fs.stat(path).catch(fallback(path, (b, at) => statOf(at, b))),
9891
+ lstat: (path) => fs.lstat(path).catch(fallback(path, (b, at) => statOf(at, b))),
9857
9892
  exists: async (path) => await fs.exists(path) || files.has(path) && await absent2(path),
9858
9893
  ...fs.createExclusive ? {
9859
9894
  createExclusive: async (path, owner) => {
@@ -9866,9 +9901,23 @@ function withEtcFiles(fs, files) {
9866
9901
  }
9867
9902
  } : {},
9868
9903
  readFile: (path) => fs.readFile(path).catch(fallback(path, (b) => new TextDecoder().decode(b))),
9904
+ ...fs.append ? {
9905
+ append: async (path, bytes) => {
9906
+ if (files.has(path)) await materialize(path);
9907
+ return fs.append.call(fs, path, bytes);
9908
+ }
9909
+ } : {},
9869
9910
  readFileBuffer: (path) => fs.readFileBuffer(path).catch(fallback(path, (b) => b)),
9870
9911
  ...ranged2 ? {
9871
- pread: (path, offset, length2, version) => ranged2.pread(path, offset, length2, version).catch(fallback(path, (b) => b.slice(offset, offset + length2)))
9912
+ pread: (path, offset, length2, version) => ranged2.pread(path, offset, length2, version).catch(fallback(path, (b) => b.slice(offset, offset + length2))),
9913
+ pwrite: async (path, offset, bytes, transfer) => {
9914
+ if (files.has(path)) await materialize(path);
9915
+ return ranged2.pwrite(path, offset, bytes, transfer);
9916
+ },
9917
+ truncate: async (path, size) => {
9918
+ if (files.has(path)) await materialize(path);
9919
+ return ranged2.truncate(path, size);
9920
+ }
9872
9921
  } : {}
9873
9922
  };
9874
9923
  return new Proxy(fs, {
@@ -10001,7 +10050,7 @@ var FreshModules = class {
10001
10050
  };
10002
10051
 
10003
10052
  // src/fs/physical-path.ts
10004
- var MAX_HOPS2 = 40;
10053
+ var MAX_HOPS3 = 40;
10005
10054
  function start(path) {
10006
10055
  return { done: [], todo: path.split("/").filter((p) => p !== ""), hops: 0 };
10007
10056
  }
@@ -10026,7 +10075,7 @@ function rest(walk2, part) {
10026
10075
  return lexical(`/${[...walk2.done, part, ...walk2.todo].join("/")}`);
10027
10076
  }
10028
10077
  function follow(walk2, target) {
10029
- if (++walk2.hops > MAX_HOPS2) return false;
10078
+ if (++walk2.hops > MAX_HOPS3) return false;
10030
10079
  if (target.startsWith("/")) walk2.done.length = 0;
10031
10080
  walk2.todo = [...target.split("/").filter((p) => p !== ""), ...walk2.todo];
10032
10081
  return true;
@@ -10049,13 +10098,13 @@ async function physicalPathAsync(fs, path) {
10049
10098
 
10050
10099
  // src/fs/watch.ts
10051
10100
  var WATCH_NOTES_LIMIT = 1e3;
10052
- var baseOf2 = (path) => path.slice(path.lastIndexOf("/") + 1);
10101
+ var baseOf3 = (path) => path.slice(path.lastIndexOf("/") + 1);
10053
10102
  var WATCH_BATCH_LIMIT = 1e3;
10054
10103
  var under3 = (path, dir) => dir === "/" || path.startsWith(`${dir}/`);
10055
- var parentOf6 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
10104
+ var parentOf7 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
10056
10105
  function touches(watcher, changed) {
10057
10106
  return watcher.paths.some(
10058
- (watched) => changed === watched || under3(watched, changed) || (watcher.recursive ? under3(changed, watched) : parentOf6(changed) === watched)
10107
+ (watched) => changed === watched || under3(watched, changed) || (watcher.recursive ? under3(changed, watched) : parentOf7(changed) === watched)
10059
10108
  );
10060
10109
  }
10061
10110
  var REALS_KEPT = 4096;
@@ -10079,11 +10128,11 @@ function route(watch, type, path) {
10079
10128
  }
10080
10129
  function routed(watch, root, type, path) {
10081
10130
  if (path === root || type === "rename" && root !== "/" && under3(root, path)) {
10082
- noted(watch, { type, filename: baseOf2(root) });
10131
+ noted(watch, { type, filename: baseOf3(root) });
10083
10132
  if (type === "rename") noted(watch, { ended: true });
10084
10133
  return true;
10085
10134
  }
10086
- if (parentOf6(path) === root) noted(watch, { type, filename: baseOf2(path) });
10135
+ if (parentOf7(path) === root) noted(watch, { type, filename: baseOf3(path) });
10087
10136
  else if (watch.recursive && under3(path, root)) {
10088
10137
  noted(watch, { type, filename: path.slice(root === "/" ? 1 : root.length + 1) });
10089
10138
  } else return false;
@@ -10159,7 +10208,7 @@ var FsWatchers = class {
10159
10208
  covers(path) {
10160
10209
  for (const watch of this.typed) {
10161
10210
  for (const root of watch.roots) {
10162
- if (path === root || parentOf6(path) === root || watch.recursive && under3(path, root))
10211
+ if (path === root || parentOf7(path) === root || watch.recursive && under3(path, root))
10163
10212
  return true;
10164
10213
  }
10165
10214
  }
@@ -11328,7 +11377,7 @@ var HeldPaths = class extends Map {
11328
11377
  return this.revoked.has(path);
11329
11378
  }
11330
11379
  };
11331
- var parentOf7 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
11380
+ var parentOf8 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
11332
11381
  var readonly = (mount) => mount.caps.readonly === true || mount.options.ro !== void 0;
11333
11382
  function inodeless(mount, attr2) {
11334
11383
  if (attr2.ino !== void 0) return false;
@@ -11628,7 +11677,7 @@ var MountTable = class {
11628
11677
  for (const [key, cached] of [...mount.attrs])
11629
11678
  if (within6(key, path) || linked2(cached.value)) mount.attrs.delete(key);
11630
11679
  mount.lists.delete(path);
11631
- mount.lists.delete(parentOf7(path));
11680
+ mount.lists.delete(parentOf8(path));
11632
11681
  for (const [key, cached] of [...mount.lists])
11633
11682
  if (within6(key, path) || cached.value.some((e) => linked2(e.attr))) mount.lists.delete(key);
11634
11683
  }
@@ -11748,7 +11797,7 @@ var MountFs = class _MountFs {
11748
11797
  const real = normalizePath(path);
11749
11798
  if (this.at(real)) return real;
11750
11799
  try {
11751
- await this.base.stat(parentOf7(real));
11800
+ await this.base.stat(parentOf8(real));
11752
11801
  return real;
11753
11802
  } catch (err) {
11754
11803
  const moved2 = redirectOf(err);
@@ -11790,7 +11839,7 @@ var MountFs = class _MountFs {
11790
11839
  if (this.rejectLinks) throw errnoError("ELOOP", path);
11791
11840
  if (hops >= MAX_LINKS7) throw errnoError("ELOOP", path);
11792
11841
  const target = await found.mount.conn.call({ op: "readlink", path: found.rel });
11793
- return this.follow(this.base.resolvePath(parentOf7(real), target), hops + 1, create);
11842
+ return this.follow(this.base.resolvePath(parentOf8(real), target), hops + 1, create);
11794
11843
  }
11795
11844
  async open(mount, rel2, write, owner) {
11796
11845
  return await mount.conn.call({
@@ -11806,8 +11855,8 @@ var MountFs = class _MountFs {
11806
11855
  async driverOwner(found, real, owner, directory) {
11807
11856
  const { mount, rel: rel2 } = found;
11808
11857
  if (!owner || !mount.owners || !mount.caps.owners) return void 0;
11809
- const dir = parentOf7(real);
11810
- const above = statOf2(await this.table.getattr(mount, dir, parentOf7(rel2)), dir, mount);
11858
+ const dir = parentOf8(real);
11859
+ const above = statOf2(await this.table.getattr(mount, dir, parentOf8(rel2)), dir, mount);
11811
11860
  const setgid = (above.mode & S_ISGID4) !== 0;
11812
11861
  let mode = owner.mode;
11813
11862
  if (directory && setgid) mode = (mode ?? 493) | S_ISGID4;
@@ -12313,7 +12362,7 @@ var MountFs = class _MountFs {
12313
12362
  }
12314
12363
  async named(path) {
12315
12364
  const at = normalizePath(path);
12316
- return joinName(await realDir(this, parentOf7(at)), at.slice(at.lastIndexOf("/") + 1));
12365
+ return joinName(await realDir(this, parentOf8(at)), at.slice(at.lastIndexOf("/") + 1));
12317
12366
  }
12318
12367
  async link(source, target, follow2 = false) {
12319
12368
  const from = follow2 ? await realTarget(this, normalizePath(source)) : await this.named(source);
@@ -14199,6 +14248,12 @@ var ProcTree = class {
14199
14248
  if (node.kind !== "dir") throw syncError("ENOTDIR", path);
14200
14249
  return node.names();
14201
14250
  }
14251
+ escape(path) {
14252
+ const node = this.node(this.parts(path, true));
14253
+ if (node?.kind !== "link" || !node.target.startsWith("/")) return void 0;
14254
+ if (node.denied) throw syncError("EACCES", path);
14255
+ return node.target;
14256
+ }
14202
14257
  readlink(path) {
14203
14258
  const node = this.find(path, false);
14204
14259
  if (node.kind !== "link") throw syncError("EINVAL", path);
@@ -14214,7 +14269,7 @@ var ProcTree = class {
14214
14269
  }
14215
14270
  }
14216
14271
  };
14217
- var MAX_HOPS3 = 40;
14272
+ var MAX_HOPS4 = 40;
14218
14273
  function* procWalk(path, follow2) {
14219
14274
  let done4 = [];
14220
14275
  let todo = path.split("/").filter((part) => part !== "");
@@ -14233,7 +14288,7 @@ function* procWalk(path, follow2) {
14233
14288
  if (!follow2 && todo.length === 0) return void 0;
14234
14289
  const target = yield { at, check: todo.find((next3) => next3 !== ".") === ".." };
14235
14290
  if (typeof target === "string") {
14236
- if (++hops > MAX_HOPS3) return void 0;
14291
+ if (++hops > MAX_HOPS4) return void 0;
14237
14292
  [done4, todo] = throughLink(target, done4, todo);
14238
14293
  } else {
14239
14294
  broken ??= refusalOf(target);
@@ -21733,7 +21788,7 @@ function isWatchSyscall(req) {
21733
21788
  return WATCHING.has(req.op);
21734
21789
  }
21735
21790
  var WATCHES_MAX = 8192;
21736
- var parentOf8 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
21791
+ var parentOf9 = (path) => path.slice(0, path.lastIndexOf("/")) || "/";
21737
21792
  function visibleTo2(watch, root, visible) {
21738
21793
  return {
21739
21794
  close: () => watch.close(),
@@ -21743,7 +21798,7 @@ function visibleTo2(watch, root, visible) {
21743
21798
  const shown = await Promise.all(
21744
21799
  notes.map(async (note) => {
21745
21800
  if (!("filename" in note) || !note.filename.includes("/")) return true;
21746
- const dir = parentOf8(`${root === "/" ? "" : root}/${note.filename}`);
21801
+ const dir = parentOf9(`${root === "/" ? "" : root}/${note.filename}`);
21747
21802
  if (!seen.has(dir)) seen.set(dir, visible(dir));
21748
21803
  return seen.get(dir);
21749
21804
  })