@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.
@@ -3094,7 +3094,7 @@ var OpfsFs = class {
3094
3094
  }
3095
3095
  async mkdirExcl(path, owner) {
3096
3096
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
3097
- const parent = await this.locate(parentOf4(path), true);
3097
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3098
3098
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3099
3099
  const dir = parent.handle;
3100
3100
  const name2 = baseOf(path);
@@ -3116,7 +3116,7 @@ var OpfsFs = class {
3116
3116
  }
3117
3117
  async createExclusive(path, owner) {
3118
3118
  if (normalizePath(path) === "/") throw fsError("EEXIST", path);
3119
- const parent = await this.locate(parentOf4(path), true);
3119
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3120
3120
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3121
3121
  const dir = parent.handle;
3122
3122
  const name2 = baseOf(path);
@@ -3865,7 +3865,7 @@ var OpfsFs = class {
3865
3865
  }
3866
3866
  }
3867
3867
  async symlink(target, path, owner) {
3868
- const parent = await this.locate(parentOf4(path), true);
3868
+ const parent = await this.exactly(() => this.locate(parentOf4(path), true));
3869
3869
  if (parent.handle?.kind !== "directory") throw fsError("ENOTDIR", path);
3870
3870
  const at = resolvePath(parent.path, baseOf(path));
3871
3871
  this.refuse(at);
@@ -5580,14 +5580,21 @@ async function ownerOnly(g, op, path, follow2) {
5580
5580
  return walked;
5581
5581
  }
5582
5582
  async function chmodMode(g, path, mode) {
5583
- const perm = (await ownerOnly(g, "chmod", path, true)).perm;
5584
- if (!g.dac.enforcing || !perm || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
5583
+ const walked = await need(g, "chmod", path, 0, { follow: true });
5584
+ const perm = walked.perm;
5585
+ const st = await g.fs.stat(walked.path).catch(() => void 0);
5586
+ if (!st?.fat && perm && g.cred.euid !== 0 && perm.uid !== g.cred.euid) {
5587
+ if (await present(g.fs, walked.path, false)) deny(g, "chmod", path, "EPERM");
5588
+ }
5589
+ if (!g.dac.enforcing || !perm || g.cred.euid === 0 || st?.fat || inGroup(g.cred, perm.gid)) {
5590
+ return mode;
5591
+ }
5585
5592
  return mode & ~S_ISGID3;
5586
5593
  }
5587
5594
  function heldChmodMode(g, path, st, mode) {
5588
5595
  const perm = permOf(st);
5589
- if (g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
5590
- if (!g.dac.enforcing || g.cred.euid === 0 || inGroup(g.cred, perm.gid)) return mode;
5596
+ if (!st.fat && g.cred.euid !== 0 && perm.uid !== g.cred.euid) deny(g, "fchmod", path, "EPERM");
5597
+ if (!g.dac.enforcing || g.cred.euid === 0 || st.fat || inGroup(g.cred, perm.gid)) return mode;
5591
5598
  return mode & ~S_ISGID3;
5592
5599
  }
5593
5600
  function heldRetimable(g, path, st, now) {
@@ -8767,7 +8774,7 @@ function satisfies(version, range2) {
8767
8774
  }
8768
8775
 
8769
8776
  // src/version.ts
8770
- var KERNEL_VERSION = true ? "1.176.0" : "0.0.0-dev";
8777
+ var KERNEL_VERSION = true ? "1.176.2" : "0.0.0-dev";
8771
8778
  var OS_RELEASE = "6.0.0-slicc";
8772
8779
  function procVersion() {
8773
8780
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13912,10 +13919,15 @@ var DriverConnection = class _DriverConnection {
13912
13919
  // src/mount/mount-fs.ts
13913
13920
  var S_ISGID4 = 1024;
13914
13921
  var ID = /^\d{1,10}$/;
13922
+ var MASK = /^0*[0-7]{1,4}$/;
13915
13923
  var MAX_ID2 = 4294967294;
13916
13924
  function idOption(value2) {
13917
13925
  return value2 === void 0 ? 0 : Number(value2);
13918
13926
  }
13927
+ function maskOption(value2) {
13928
+ if (value2 === void 0) return void 0;
13929
+ return Number.parseInt(value2, 8) & 511;
13930
+ }
13919
13931
  function checkIds(options) {
13920
13932
  for (const key of ["uid", "gid"]) {
13921
13933
  const value2 = options[key];
@@ -13923,6 +13935,27 @@ function checkIds(options) {
13923
13935
  if (!ID.test(value2) || Number(value2) > MAX_ID2) throw errnoError("EINVAL", `${key}=${value2}`);
13924
13936
  }
13925
13937
  }
13938
+ function checkMasks(options) {
13939
+ for (const key of ["umask", "fmask", "dmask"]) {
13940
+ const value2 = options[key];
13941
+ if (value2 === void 0) continue;
13942
+ if (!MASK.test(value2) || Number.parseInt(value2, 8) > 511) {
13943
+ throw errnoError("EINVAL", `${key}=${value2}`);
13944
+ }
13945
+ }
13946
+ }
13947
+ function modeOf(attr2, mount) {
13948
+ const type = attr2.kind === "directory" ? 16384 : attr2.kind === "symlink" ? 40960 : attr2.kind === "fifo" ? 4096 : 32768;
13949
+ const fallback = type | (attr2.kind === "directory" ? 493 : attr2.kind === "symlink" ? 511 : 420);
13950
+ if (mount.caps.owners) return attr2.mode ?? fallback;
13951
+ const umask = maskOption(mount.options.umask);
13952
+ const fmask = maskOption(mount.options.fmask) ?? umask;
13953
+ const dmask = maskOption(mount.options.dmask) ?? umask;
13954
+ const mask = attr2.kind === "directory" ? dmask : fmask;
13955
+ if (mask === void 0) return attr2.mode ?? fallback;
13956
+ const base = attr2.kind === "directory" || attr2.kind === "symlink" ? 511 : 438;
13957
+ return type | base & ~mask;
13958
+ }
13926
13959
  var MAX_LINKS7 = 40;
13927
13960
  var STALE_RETRIES = 3;
13928
13961
  var SETTLE_ROUNDS = 4;
@@ -14189,14 +14222,13 @@ function inodeless(mount, attr2) {
14189
14222
  }
14190
14223
  function statOf2(attr2, path, mount) {
14191
14224
  const mtime = new Date(attr2.mtime);
14192
- const fallback = attr2.kind === "directory" ? 16877 : attr2.kind === "symlink" ? 41471 : attr2.kind === "fifo" ? 4516 : 33188;
14193
14225
  return {
14194
14226
  isFile: attr2.kind === "file",
14195
14227
  isDirectory: attr2.kind === "directory",
14196
14228
  isSymbolicLink: attr2.kind === "symlink",
14197
14229
  ...attr2.kind === "fifo" ? { isFifo: true } : {},
14198
14230
  size: attr2.size,
14199
- mode: attr2.mode ?? fallback,
14231
+ mode: modeOf(attr2, mount),
14200
14232
  mtime,
14201
14233
  atime: attr2.atime === void 0 ? mtime : new Date(attr2.atime),
14202
14234
  ctime: mtime,
@@ -14210,7 +14242,8 @@ function statOf2(attr2, path, mount) {
14210
14242
  ...attr2.etag !== void 0 ? { version: attr2.etag } : {},
14211
14243
  ...mount.owners ? {
14212
14244
  uid: (mount.caps.owners ? attr2.uid : void 0) ?? idOption(mount.options.uid),
14213
- gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid)
14245
+ gid: (mount.caps.owners ? attr2.gid : void 0) ?? idOption(mount.options.gid),
14246
+ ...!mount.caps.owners && !mount.caps.chmod && (mount.options.umask !== void 0 || mount.options.fmask !== void 0 || mount.options.dmask !== void 0) ? { fat: true } : {}
14214
14247
  } : {}
14215
14248
  };
14216
14249
  }
@@ -14317,6 +14350,7 @@ var MountTable = class {
14317
14350
  if (!st.isDirectory) throw errnoError("ENOTDIR", target);
14318
14351
  const options = { ...spec.options };
14319
14352
  if (this.deps.owners) checkIds(options);
14353
+ checkMasks(options);
14320
14354
  const maxFile = options.maxfile !== void 0 ? parseSize(options.maxfile) : void 0;
14321
14355
  const opened2 = await this.deps.open(spec.type, { ...spec, target, options });
14322
14356
  let mounted;
@@ -16811,6 +16845,10 @@ var lengthOf = getter("length");
16811
16845
 
16812
16846
  // src/realm/live-vfs-fs.ts
16813
16847
  var EARLY_WHOLE_FILE = 64 * 1024;
16848
+ var createParentRefresh = 0;
16849
+ function createParentRefreshCount() {
16850
+ return createParentRefresh;
16851
+ }
16814
16852
 
16815
16853
  // src/process/process-fds.ts
16816
16854
  var REFUSED = /* @__PURE__ */ new Set([wasiErrno("EACCES"), wasiErrno("EPERM")]);
@@ -16853,6 +16891,8 @@ var SYS_TREE = {
16853
16891
  slicc_opfs_calls: (listing) => `${listing.opfsCalls ?? 0}
16854
16892
  `,
16855
16893
  slicc_opfs_ops: (listing) => `${listing.opfsOps ?? 0}
16894
+ `,
16895
+ slicc_create_parent_refresh: (_listing) => `${createParentRefreshCount()}
16856
16896
  `,
16857
16897
  slicc_meta_transactions: ({ meta }) => `${meta?.reads ?? 0} ${meta?.writes ?? 0}
16858
16898
  `,
@@ -24445,7 +24485,7 @@ function headEnd2(bytes) {
24445
24485
  }
24446
24486
  return -1;
24447
24487
  }
24448
- function modeOf(start2) {
24488
+ function modeOf2(start2) {
24449
24489
  const sniffs = [
24450
24490
  ["http1", sniffHttp1(start2)],
24451
24491
  ["smtp", sniffSmtp(start2)],
@@ -24554,7 +24594,7 @@ var SessionWriter = class {
24554
24594
  joined5.set(bytes, this.buffer.length);
24555
24595
  this.buffer.fill(0);
24556
24596
  this.buffer = joined5;
24557
- if (this.mode === "sniff") this.mode = modeOf(latin12(joined5.subarray(0, 8))) ?? "sniff";
24597
+ if (this.mode === "sniff") this.mode = modeOf2(latin12(joined5.subarray(0, 8))) ?? "sniff";
24558
24598
  if (this.mode === "pg" && !this.sawPg) {
24559
24599
  this.sawPg = true;
24560
24600
  if (!this.s.verified) void this.proof("pg");