@ai-ecoverse/slicc-kernel 1.91.0 → 1.92.0

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
@@ -9159,6 +9159,7 @@ async function storageUsage() {
9159
9159
  if (typeof estimate?.quota !== "number") return null;
9160
9160
  return { quota: estimate.quota, usage: estimate.usage ?? 0 };
9161
9161
  }
9162
+ var PLAIN_DIR_MODE = 493;
9162
9163
  var done = { ok: true, kind: "void" };
9163
9164
  function json2(value) {
9164
9165
  return { ok: true, kind: "json", json: value };
@@ -9168,6 +9169,11 @@ function ownerFor2(entry, mode) {
9168
9169
  if (!cred) return void 0;
9169
9170
  return ownerOf(cred, mode === void 0 ? void 0 : mode & ~(entry.umask?.() ?? 18));
9170
9171
  }
9172
+ function plainDirMode(entry, mode) {
9173
+ if (entry.cred || mode === void 0) return void 0;
9174
+ const wanted = mode & 4095 & ~(entry.umask?.() ?? 18);
9175
+ return wanted === PLAIN_DIR_MODE ? void 0 : wanted;
9176
+ }
9171
9177
  function mkdirOptions(entry, mode = 511) {
9172
9178
  const owner = ownerFor2(entry, mode);
9173
9179
  if (!owner) return { recursive: true };
@@ -9209,9 +9215,13 @@ async function run(entry, path, req) {
9209
9215
  return json2(await fs.readdir(path));
9210
9216
  case "readdir-stat":
9211
9217
  return json2(await readdirStat(fs, path));
9212
- case "mkdir":
9218
+ case "mkdir": {
9219
+ const plain = plainDirMode(entry, req.mode);
9220
+ const fresh2 = plain !== void 0 && !await fs.exists(path);
9213
9221
  await (req.exclusive ? mkdirExclusive(entry, path, req.mode) : fs.mkdir(path, mkdirOptions(entry, req.mode)));
9222
+ if (fresh2) await fs.chmod(path, plain);
9214
9223
  return done;
9224
+ }
9215
9225
  case "rm":
9216
9226
  await fs.rm(path, { recursive: true });
9217
9227
  return done;
@@ -10064,7 +10074,7 @@ function mountTable(mounts = []) {
10064
10074
  }
10065
10075
 
10066
10076
  // src/version.ts
10067
- var KERNEL_VERSION = true ? "1.91.0" : "0.0.0-dev";
10077
+ var KERNEL_VERSION = true ? "1.92.0" : "0.0.0-dev";
10068
10078
  var OS_RELEASE = "6.0.0-slicc";
10069
10079
  function procVersion() {
10070
10080
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13444,6 +13454,7 @@ function aborted(signal) {
13444
13454
  signal.addEventListener("abort", () => reject(new KernelError("EINTR")), { once: true });
13445
13455
  });
13446
13456
  }
13457
+ var PLAIN_FILE_MODE = 420;
13447
13458
  var JOB_OPS = /* @__PURE__ */ new Set([
13448
13459
  "proc-setpgid",
13449
13460
  "proc-getpgid",
@@ -13898,15 +13909,21 @@ var WasmProcess = class {
13898
13909
  }
13899
13910
  if (this.writesAt(req) && this.options.readonlyAt?.(path)) throw new KernelError("EROFS");
13900
13911
  const open = { ...req, path };
13912
+ const plain = this.plainMode(req.mode);
13901
13913
  if (req.exclusive) {
13902
- await nodes.createExclusive(path, this.newOwner());
13914
+ await nodes.createExclusive(path, this.newOwner(req.mode));
13915
+ if (plain !== void 0) await this.options.fs.chmod?.(path, plain);
13903
13916
  this.fds.installAt(fd, this.openVfsFile(open));
13904
13917
  } else if (req.create) {
13905
13918
  await nodes.onEntry(path, async () => {
13906
- const fresh2 = this.options.owners && !await present2(this.options.fs, path, true);
13919
+ const marks = this.options.owners || plain !== void 0;
13920
+ const fresh2 = marks && !await present2(this.options.fs, path, true);
13907
13921
  this.fds.installAt(fd, this.openVfsFile(open, await nodes.identify(path)));
13908
13922
  await this.fds.get(fd).file.stat?.();
13909
- if (fresh2) await this.options.fs.chown?.(path, { ...this.newOwner(), kind: "new" });
13923
+ if (fresh2 && plain !== void 0) await this.options.fs.chmod?.(path, plain);
13924
+ else if (fresh2) {
13925
+ await this.options.fs.chown?.(path, { ...this.newOwner(req.mode), kind: "new" });
13926
+ }
13910
13927
  });
13911
13928
  } else {
13912
13929
  this.fds.installAt(fd, this.openVfsFile(open, await nodes.identify(path)));
@@ -14019,9 +14036,14 @@ var WasmProcess = class {
14019
14036
  if (!tty) throw new KernelError("ENOENT");
14020
14037
  return tty;
14021
14038
  }
14022
- newOwner() {
14039
+ plainMode(mode) {
14040
+ if (this.options.owners || mode === void 0) return void 0;
14041
+ const wanted = mode & 4095 & ~this.umask;
14042
+ return wanted === PLAIN_FILE_MODE ? void 0 : wanted;
14043
+ }
14044
+ newOwner(mode = 438) {
14023
14045
  if (!this.options.owners) return void 0;
14024
- return { uid: this.cred.euid, gid: this.cred.egid, mode: 438 & ~this.umask };
14046
+ return { uid: this.cred.euid, gid: this.cred.egid, mode: mode & 4095 & ~this.umask };
14025
14047
  }
14026
14048
  async openProc(req, path) {
14027
14049
  return this.fds.install(await this.procFile(req, path), 3);
@@ -14761,7 +14783,7 @@ function inherited(opts) {
14761
14783
  }
14762
14784
  function holdingToken(opts, holds, caller) {
14763
14785
  return mintSyncFsToken({
14764
- ...opts.owners ? caller : {},
14786
+ ...opts.owners ? caller : { umask: caller.umask },
14765
14787
  ...opts.dac ? { dac: opts.dac, pid: opts.pid, created: caller.created } : {},
14766
14788
  ...opts.links !== void 0 ? { links: opts.links } : {},
14767
14789
  ...opts.fresh ? { fresh: (path) => opts.fresh?.(path, caller.umask()) } : {},