@ai-ecoverse/slicc-kernel 1.176.0 → 1.176.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
@@ -876,14 +876,21 @@ async function ownerOnly(g, op, path, follow2) {
876
876
  return walked;
877
877
  }
878
878
  async function chmodMode(g, path, mode) {
879
- const perm = (await ownerOnly(g, "chmod", path, true)).perm;
880
- if (!g.dac.enforcing || !perm || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
879
+ const walked = await need(g, "chmod", path, 0, { follow: true });
880
+ const perm = walked.perm;
881
+ const st = await g.fs.stat(walked.path).catch(() => void 0);
882
+ if (!st?.fat && perm && g.cred.euid !== 0 && perm.uid !== g.cred.euid) {
883
+ if (await present(g.fs, walked.path, false)) deny(g, "chmod", path, "EPERM");
884
+ }
885
+ if (!g.dac.enforcing || !perm || g.cred.euid === 0 || st?.fat || inGroup(g.cred, perm.gid)) {
886
+ return mode;
887
+ }
881
888
  return mode & ~S_ISGID2;
882
889
  }
883
890
  function heldChmodMode(g, path, st, mode) {
884
891
  const perm = permOf(st);
885
- if (g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
886
- if (!g.dac.enforcing || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
892
+ if (!st.fat && g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
893
+ if (!g.dac.enforcing || g.cred.euid === 0 || st.fat || inGroup(g.cred, perm.gid)) return mode;
887
894
  return mode & ~S_ISGID2;
888
895
  }
889
896
  function heldRetimable(g, path, st, now) {
@@ -3702,7 +3709,7 @@ function satisfies(version, range2) {
3702
3709
  }
3703
3710
 
3704
3711
  // src/version.ts
3705
- var KERNEL_VERSION = true ? "1.176.0" : "0.0.0-dev";
3712
+ var KERNEL_VERSION = true ? "1.176.2" : "0.0.0-dev";
3706
3713
  var OS_RELEASE = "6.0.0-slicc";
3707
3714
  function procVersion() {
3708
3715
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -9599,10 +9606,15 @@ var DriverConnection = class _DriverConnection {
9599
9606
  // src/mount/mount-fs.ts
9600
9607
  var S_ISGID3 = 1024;
9601
9608
  var ID = /^\d{1,10}$/;
9609
+ var MASK = /^0*[0-7]{1,4}$/;
9602
9610
  var MAX_ID2 = 4294967294;
9603
9611
  function idOption(value2) {
9604
9612
  return value2 === void 0 ? 0 : Number(value2);
9605
9613
  }
9614
+ function maskOption(value2) {
9615
+ if (value2 === void 0) return void 0;
9616
+ return Number.parseInt(value2, 8) & 511;
9617
+ }
9606
9618
  function checkIds(options) {
9607
9619
  for (const key of ["uid", "gid"]) {
9608
9620
  const value2 = options[key];
@@ -9610,6 +9622,27 @@ function checkIds(options) {
9610
9622
  if (!ID.test(value2) || Number(value2) > MAX_ID2) throw errnoError("EINVAL", `${key}=${value2}`);
9611
9623
  }
9612
9624
  }
9625
+ function checkMasks(options) {
9626
+ for (const key of ["umask", "fmask", "dmask"]) {
9627
+ const value2 = options[key];
9628
+ if (value2 === void 0) continue;
9629
+ if (!MASK.test(value2) || Number.parseInt(value2, 8) > 511) {
9630
+ throw errnoError("EINVAL", `${key}=${value2}`);
9631
+ }
9632
+ }
9633
+ }
9634
+ function modeOf(attr2, mount) {
9635
+ const type = attr2.kind === "directory" ? 16384 : attr2.kind === "symlink" ? 40960 : attr2.kind === "fifo" ? 4096 : 32768;
9636
+ const fallback = type | (attr2.kind === "directory" ? 493 : attr2.kind === "symlink" ? 511 : 420);
9637
+ if (mount.caps.owners) return attr2.mode ?? fallback;
9638
+ const umask = maskOption(mount.options.umask);
9639
+ const fmask = maskOption(mount.options.fmask) ?? umask;
9640
+ const dmask = maskOption(mount.options.dmask) ?? umask;
9641
+ const mask = attr2.kind === "directory" ? dmask : fmask;
9642
+ if (mask === void 0) return attr2.mode ?? fallback;
9643
+ const base = attr2.kind === "directory" || attr2.kind === "symlink" ? 511 : 438;
9644
+ return type | base & ~mask;
9645
+ }
9613
9646
  var MAX_LINKS5 = 40;
9614
9647
  var STALE_RETRIES = 3;
9615
9648
  var SETTLE_ROUNDS = 4;
@@ -9876,14 +9909,13 @@ function inodeless(mount, attr2) {
9876
9909
  }
9877
9910
  function statOf2(attr2, path, mount) {
9878
9911
  const mtime = new Date(attr2.mtime);
9879
- const fallback = attr2.kind === "directory" ? 16877 : attr2.kind === "symlink" ? 41471 : attr2.kind === "fifo" ? 4516 : 33188;
9880
9912
  return {
9881
9913
  isFile: attr2.kind === "file",
9882
9914
  isDirectory: attr2.kind === "directory",
9883
9915
  isSymbolicLink: attr2.kind === "symlink",
9884
9916
  ...attr2.kind === "fifo" ? { isFifo: true } : {},
9885
9917
  size: attr2.size,
9886
- mode: attr2.mode ?? fallback,
9918
+ mode: modeOf(attr2, mount),
9887
9919
  mtime,
9888
9920
  atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
9889
9921
  ctime: mtime,
@@ -9897,7 +9929,8 @@ function statOf2(attr2, path, mount) {
9897
9929
  ...attr2.etag !== void 0 ? { version: attr2.etag } : {},
9898
9930
  ...mount.owners ? {
9899
9931
  uid: (mount.caps.owners ? attr2.uid : void 0) ?? idOption(mount.options.uid),
9900
- gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid)
9932
+ gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid),
9933
+ ...!mount.caps.owners && !mount.caps.chmod && (mount.options.umask !== void 0 || mount.options.fmask !== void 0 || mount.options.dmask !== void 0) ? { fat: true } : {}
9901
9934
  } : {}
9902
9935
  };
9903
9936
  }
@@ -10004,6 +10037,7 @@ var MountTable = class {
10004
10037
  if (!st.isDirectory) throw errnoError("ENOTDIR", target);
10005
10038
  const options = { ...spec.options };
10006
10039
  if (this.deps.owners) checkIds(options);
10040
+ checkMasks(options);
10007
10041
  const maxFile = options.maxfile !== void 0 ? parseSize(options.maxfile) : void 0;
10008
10042
  const opened2 = await this.deps.open(spec.type, { ...spec, target, options });
10009
10043
  let mounted;
@@ -12498,6 +12532,10 @@ var lengthOf = getter("length");
12498
12532
 
12499
12533
  // src/realm/live-vfs-fs.ts
12500
12534
  var EARLY_WHOLE_FILE = 64 * 1024;
12535
+ var createParentRefresh = 0;
12536
+ function createParentRefreshCount() {
12537
+ return createParentRefresh;
12538
+ }
12501
12539
 
12502
12540
  // src/process/process-fds.ts
12503
12541
  var REFUSED = /* @__PURE__ */ new Set([wasiErrno("EACCES"), wasiErrno("EPERM")]);
@@ -12540,6 +12578,8 @@ var SYS_TREE = {
12540
12578
  slicc_opfs_calls: (listing) => `${listing.opfsCalls ?? 0}
12541
12579
  `,
12542
12580
  slicc_opfs_ops: (listing) => `${listing.opfsOps ?? 0}
12581
+ `,
12582
+ slicc_create_parent_refresh: (_listing) => `${createParentRefreshCount()}
12543
12583
  `,
12544
12584
  slicc_meta_transactions: ({ meta }) => `${meta?.reads ?? 0} ${meta?.writes ?? 0}
12545
12585
  `,
@@ -20349,7 +20389,7 @@ function headEnd2(bytes) {
20349
20389
  }
20350
20390
  return -1;
20351
20391
  }
20352
- function modeOf(start2) {
20392
+ function modeOf2(start2) {
20353
20393
  const sniffs = [
20354
20394
  ["http1", sniffHttp1(start2)],
20355
20395
  ["smtp", sniffSmtp(start2)],
@@ -20458,7 +20498,7 @@ var SessionWriter = class {
20458
20498
  joined5.set(bytes, this.buffer.length);
20459
20499
  this.buffer.fill(0);
20460
20500
  this.buffer = joined5;
20461
- if (this.mode === "sniff") this.mode = modeOf(latin12(joined5.subarray(0, 8))) ?? "sniff";
20501
+ if (this.mode === "sniff") this.mode = modeOf2(latin12(joined5.subarray(0, 8))) ?? "sniff";
20462
20502
  if (this.mode === "pg" && !this.sawPg) {
20463
20503
  this.sawPg = true;
20464
20504
  if (!this.s.verified) void this.proof("pg");
@@ -29196,7 +29236,7 @@ var OpfsFs = class {
29196
29236
  }
29197
29237
  async mkdirExcl(path, owner) {
29198
29238
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
29199
- const parent = await this.locate(parentOf9(path), true);
29239
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29200
29240
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29201
29241
  const dir = parent.handle;
29202
29242
  const name2 = baseOf3(path);
@@ -29218,7 +29258,7 @@ var OpfsFs = class {
29218
29258
  }
29219
29259
  async createExclusive(path, owner) {
29220
29260
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
29221
- const parent = await this.locate(parentOf9(path), true);
29261
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29222
29262
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29223
29263
  const dir = parent.handle;
29224
29264
  const name2 = baseOf3(path);
@@ -29967,7 +30007,7 @@ var OpfsFs = class {
29967
30007
  }
29968
30008
  }
29969
30009
  async symlink(target, path, owner) {
29970
- const parent = await this.locate(parentOf9(path), true);
30010
+ const parent = await this.exactly(() => this.locate(parentOf9(path), true));
29971
30011
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
29972
30012
  const at = resolvePath(parent.path, baseOf3(path));
29973
30013
  this.refuse(at);