@ai-ecoverse/slicc-kernel 1.167.2 → 1.167.4

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.
@@ -7511,7 +7511,7 @@ var init_version = __esm({
7511
7511
  "src/version.ts"() {
7512
7512
  "use strict";
7513
7513
  init_captured_globals();
7514
- KERNEL_VERSION = true ? "1.167.2" : "0.0.0-dev";
7514
+ KERNEL_VERSION = true ? "1.167.4" : "0.0.0-dev";
7515
7515
  OS_RELEASE = "6.0.0-slicc";
7516
7516
  }
7517
7517
  });
@@ -7510,7 +7510,7 @@ var init_version = __esm({
7510
7510
  "src/version.ts"() {
7511
7511
  "use strict";
7512
7512
  init_captured_globals();
7513
- KERNEL_VERSION = true ? "1.167.2" : "0.0.0-dev";
7513
+ KERNEL_VERSION = true ? "1.167.4" : "0.0.0-dev";
7514
7514
  OS_RELEASE = "6.0.0-slicc";
7515
7515
  }
7516
7516
  });
package/dist/node.js CHANGED
@@ -800,28 +800,39 @@ async function stickyEntry(g, op, path, dir) {
800
800
  if (sticky(g.cred, perm, (await ancestryOf(g.fs, entry)).at(-1))) return;
801
801
  if (await present(g.fs, entry, false)) deny(g, op, path, "EPERM");
802
802
  }
803
+ async function unwritable(g, op, path, dir) {
804
+ if (dir.denied === void 0) return false;
805
+ if (dir.link) {
806
+ deny(g, op, dir.denied);
807
+ return false;
808
+ }
809
+ const perm = dir.denied === dir.path ? dir.perm : void 0;
810
+ if (perm && !await present(g.fs, dir.path, true)) return false;
811
+ if (perm && permits(g.cred, perm, X_OK)) return true;
812
+ deny(g, op, path);
813
+ return false;
814
+ }
803
815
  async function inParent(g, op, path, old = false) {
804
816
  await fence(g, op, path);
805
- if (old === "replaced") {
806
- const dir2 = await need(g, op, parentOf(path), W_OK | X_OK, DIR, path);
807
- return dir2.denied === void 0 ? stickyEntry(g, op, path, dir2) : void 0;
808
- }
809
- if (!old) return void await need(g, op, parentOf(path), W_OK | X_OK, DIR, path);
810
817
  const dir = await access(g.fs, g.cred, parentOf(path), W_OK | X_OK, linked(g, DIR));
818
+ if (old !== true) {
819
+ if (await unwritable(g, op, path, dir)) deny(g, op, path);
820
+ else if (old === "replaced" && dir.denied === void 0) await stickyEntry(g, op, path, dir);
821
+ return;
822
+ }
811
823
  if (dir.denied === void 0) return stickyEntry(g, op, path, dir);
812
824
  if (dir.link) return deny(g, op, dir.denied);
813
825
  const lookup4 = dir.denied === dir.path && dir.perm && permits(g.cred, dir.perm, X_OK);
814
826
  if (!lookup4 || await present(g.fs, entryIn(dir, path), false)) deny(g, op, path);
815
827
  }
816
- async function makeIn(g, op, path) {
828
+ async function makeIn(g, op, path, parents = true) {
817
829
  for (let dir = parentOf(path); ; dir = parentOf(dir)) {
818
830
  const walked = await access(g.fs, g.cred, dir, W_OK | X_OK, linked(g, DIR));
819
- if (walked.link) return deny(g, op, walked.denied);
820
- if (walked.denied !== void 0) {
831
+ if (await unwritable(g, op, path, walked)) {
821
832
  if (!await present(g.fs, path, true)) deny(g, op, path);
822
833
  return;
823
834
  }
824
- if (!walked.missing || dir === "/") return;
835
+ if (!parents || !walked.missing || dir === "/") return;
825
836
  }
826
837
  }
827
838
  async function tree(g, op, dir, perm) {
@@ -3684,7 +3695,7 @@ function satisfies(version, range2) {
3684
3695
  }
3685
3696
 
3686
3697
  // src/version.ts
3687
- var KERNEL_VERSION = true ? "1.167.2" : "0.0.0-dev";
3698
+ var KERNEL_VERSION = true ? "1.167.4" : "0.0.0-dev";
3688
3699
  var OS_RELEASE = "6.0.0-slicc";
3689
3700
  function procVersion() {
3690
3701
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -10956,7 +10967,7 @@ async function guard(g, path, req, cwd) {
10956
10967
  return { path: w };
10957
10968
  }
10958
10969
  case "mkdir": {
10959
- await makeIn(g, op, path);
10970
+ await makeIn(g, op, path, !req.exclusive);
10960
10971
  return { path: await walkSafe(g, path, false) };
10961
10972
  }
10962
10973
  case "create":
@@ -26953,6 +26964,10 @@ var OpfsFs = class {
26953
26964
  const children3 = /* @__PURE__ */ new Map();
26954
26965
  this.others++;
26955
26966
  for await (const child of handle.values()) children3.set(child.name, child);
26967
+ if (this.absent.size > 0) {
26968
+ const base = found.path === "/" ? "" : found.path;
26969
+ for (const name2 of children3.keys()) this.absent.delete(`${base}/${name2}`);
26970
+ }
26956
26971
  for (const link2 of await this.meta.links(found.path)) {
26957
26972
  const name2 = baseOf3(link2.path);
26958
26973
  if (!children3.has(name2)) children3.set(name2, link2);
@@ -32862,7 +32877,7 @@ var Launcher = class {
32862
32877
  kept: async (tab, items, paths) => {
32863
32878
  for (const { path, hidden, fid } of items) {
32864
32879
  if (hidden !== void 0 && sharedKept(hidden)) await this.adoptShared(path, hidden, fid);
32865
- else this.adoptKept(path, hidden, fid, ours);
32880
+ else await this.adoptKept(path, hidden, fid, ours);
32866
32881
  }
32867
32882
  await open(tab, paths);
32868
32883
  },
@@ -32872,14 +32887,33 @@ var Launcher = class {
32872
32887
  }
32873
32888
  };
32874
32889
  }
32875
- async adoptShared(path, hidden, fid) {
32876
- const bound3 = [...this.held].map(
32877
- (holds2) => [holds2, [...holds2.boundAt(path, fid), ...holds2.boundAt(hidden, fid)]]
32878
- );
32879
- const keeping = bound3.filter(([, ids]) => ids.length > 0);
32890
+ async keptIds(hidden, fid) {
32891
+ if (fid !== void 0) return [fid];
32892
+ const st = await this.rootFs.lstat(hidden).catch(() => void 0);
32893
+ return st?.fid === void 0 ? [void 0] : [void 0, st.fid];
32894
+ }
32895
+ boundTo(path, hidden, fids) {
32896
+ const keeping = [...this.held].map(
32897
+ (holds2) => [
32898
+ holds2,
32899
+ fids.flatMap((fid) => [...holds2.boundAt(path, fid), ...holds2.boundAt(hidden, fid)])
32900
+ ]
32901
+ ).filter(([, ids]) => ids.length > 0);
32880
32902
  const nodes = [...this.openFiles].filter(
32881
32903
  (open) => [path, hidden].some((at) => open.holdsAt(at))
32882
32904
  );
32905
+ const keep2 = (file) => {
32906
+ const kept = nodes.filter(
32907
+ (open) => fids.some((fid) => open.keepBound([hidden, path], fid, file))
32908
+ ).length;
32909
+ for (let i = kept; i < nodes.length; i++) file.release();
32910
+ for (const [holds2, ids] of keeping) holds2.keepBound(ids, path, file);
32911
+ void this.rootFs.announceHolds?.([], [path, hidden], false);
32912
+ };
32913
+ return { keeping, nodes, keep: keep2 };
32914
+ }
32915
+ async adoptShared(path, hidden, fid) {
32916
+ const { keeping, nodes, keep: keep2 } = this.boundTo(path, hidden, await this.keptIds(hidden, fid));
32883
32917
  const refs = keeping.length + nodes.length;
32884
32918
  if (refs === 0) {
32885
32919
  this.held.doubt([path]);
@@ -32894,29 +32928,17 @@ var Launcher = class {
32894
32928
  this.held.doubt([path]);
32895
32929
  return;
32896
32930
  }
32897
- const kept = nodes.filter((open) => open.keepBound([hidden, path], fid, file)).length;
32898
- for (let i = kept; i < nodes.length; i++) file.release();
32899
- for (const [holds2, ids] of keeping) holds2.keepBound(ids, path, file);
32900
- void this.rootFs.announceHolds?.([], [path, hidden], false);
32931
+ keep2(file);
32901
32932
  }
32902
- adoptKept(path, hidden, fid, ours) {
32933
+ async adoptKept(path, hidden, fid, ours) {
32903
32934
  if (hidden === void 0 || !ours(hidden)) {
32904
32935
  this.held.doubt([path]);
32905
32936
  return;
32906
32937
  }
32907
- const bound3 = [...this.held].map(
32908
- (holds2) => [holds2, [...holds2.boundAt(path, fid), ...holds2.boundAt(hidden, fid)]]
32909
- );
32910
- const keeping = bound3.filter(([, ids]) => ids.length > 0);
32911
- const nodes = [...this.openFiles].filter(
32912
- (open) => [path, hidden].some((at) => open.holdsAt(at))
32913
- );
32938
+ const { keeping, nodes, keep: keep2 } = this.boundTo(path, hidden, await this.keptIds(hidden, fid));
32914
32939
  const file = this.unlinked.adopt(hidden, Math.max(keeping.length + nodes.length, 1));
32915
- const kept = nodes.filter((open) => open.keepBound([hidden, path], fid, file)).length;
32916
- for (let i = kept; i < nodes.length; i++) file.release();
32917
32940
  if (keeping.length === 0 && nodes.length === 0) file.release();
32918
- for (const [holds2, ids] of keeping) holds2.keepBound(ids, path, file);
32919
- void this.rootFs.announceHolds?.([], [path, hidden], false);
32941
+ keep2(file);
32920
32942
  }
32921
32943
  openNodes(fs, entries) {
32922
32944
  const nodes = new VfsNodes(fs, (path) => this.released(path), entries);
@@ -32953,6 +32975,7 @@ var Launcher = class {
32953
32975
  this.changes.flush();
32954
32976
  this.changes.foreign(crowded);
32955
32977
  if (crowded) {
32978
+ void this.announceHeld();
32956
32979
  void this.held.bindIds((path) => this.rootFileId(path)).then(
32957
32980
  () => Promise.all([...this.openFiles].map((open) => open.bindIds((p) => this.rootFileId(p))))
32958
32981
  ).then(() => this.announceHeld());