@ai-ecoverse/slicc-kernel 1.196.30 → 1.196.31

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.
@@ -10034,7 +10034,7 @@ function satisfies(version, range2) {
10034
10034
  }
10035
10035
 
10036
10036
  // src/version.ts
10037
- var KERNEL_VERSION = true ? "1.196.30" : "0.0.0-dev";
10037
+ var KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
10038
10038
  var OS_RELEASE = "6.0.0-slicc";
10039
10039
  function procVersion() {
10040
10040
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -17444,12 +17444,15 @@ var MountFs = class _MountFs {
17444
17444
  );
17445
17445
  }
17446
17446
  if (a?.mount !== b?.mount) throw errnoError("EXDEV", `${from} -> ${to}`);
17447
- if (a) this.writable(a.mount, normalizePath(to));
17447
+ if (a && !options.exclusive) this.writable(a.mount, normalizePath(to));
17448
17448
  return copyByBytes(this, source, to, options);
17449
17449
  }
17450
17450
  async createExclusive(path, owner, redirects = 0) {
17451
+ const real = normalizePath(path);
17452
+ const found = this.at(real);
17453
+ if (found) return this.createMounted(found, real, owner);
17451
17454
  const exclusive = this.base.createExclusive?.bind(this.base);
17452
- if (!this.at(path) && exclusive) {
17455
+ if (exclusive) {
17453
17456
  return this.based(
17454
17457
  [path],
17455
17458
  redirects,
@@ -17464,6 +17467,39 @@ var MountFs = class _MountFs {
17464
17467
  if (there) throw errnoError("EEXIST", path);
17465
17468
  await this.writeFile(path, new Uint8Array(0), owner);
17466
17469
  }
17470
+ async createMounted(found, real, owner) {
17471
+ const { mount, rel: rel2 } = found;
17472
+ if (rel2 === "/") throw errnoError("EEXIST", real);
17473
+ await mount.conn.call({ op: "getattr", path: rel2 }).then(
17474
+ () => {
17475
+ throw errnoError("EEXIST", real);
17476
+ },
17477
+ (err) => {
17478
+ if (err?.code !== "ENOENT") throw err;
17479
+ }
17480
+ );
17481
+ this.writable(mount, real);
17482
+ if (owner?.fifo) return this.mkfifo(found, real, owner);
17483
+ const made2 = await this.driverOwner(found, real, owner, false);
17484
+ await this.table.commit(real);
17485
+ this.table.forget(mount, real);
17486
+ try {
17487
+ const fh = await mount.conn.call({
17488
+ op: "open",
17489
+ path: rel2,
17490
+ write: true,
17491
+ create: true,
17492
+ exclusive: true,
17493
+ truncate: false,
17494
+ ...made2
17495
+ });
17496
+ if (typeof fh !== "number" || !Number.isSafeInteger(fh) || fh < 0)
17497
+ throw errnoError("EIO", real);
17498
+ await mount.conn.call({ op: "release", fh });
17499
+ } finally {
17500
+ this.table.forget(mount, real);
17501
+ }
17502
+ }
17467
17503
  async lstat(path, redirects = 0) {
17468
17504
  const found = this.at(path);
17469
17505
  if (!found) {
@@ -36899,11 +36935,16 @@ function kernelFsHandlers(fs) {
36899
36935
  return [{ name: name2, kind: attr2.kind, attr: attr2 }];
36900
36936
  }),
36901
36937
  async open(path, flags2) {
36902
- const st = await existing(path);
36903
- if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36904
- if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36905
- if (!st && !flags2.create) throw fsError2("ENOENT", path);
36906
- if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36938
+ if (flags2.create && flags2.exclusive) {
36939
+ if (!fs.createExclusive) throw fsError2("ENOTSUP", path);
36940
+ await fs.createExclusive(path);
36941
+ } else {
36942
+ const st = await existing(path);
36943
+ if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36944
+ if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36945
+ if (!st && !flags2.create) throw fsError2("ENOENT", path);
36946
+ if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36947
+ }
36907
36948
  handles.set(++nextFh, { path });
36908
36949
  return nextFh;
36909
36950
  },
@@ -37302,11 +37343,14 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
37302
37343
  });
37303
37344
  async function writable3(client, path, flags2) {
37304
37345
  const { ifMatch: _, ...asked } = flags2;
37305
- const opening2 = () => client.call("open", { path: rel(path), ...asked });
37346
+ const opening2 = () => client.call("open", {
37347
+ path: rel(path),
37348
+ ...asked
37349
+ });
37306
37350
  try {
37307
37351
  return { opened: await opening2(), restore: void 0 };
37308
37352
  } catch (err) {
37309
- if (!flags2.write || codeOf7(err) !== "EACCES") throw err;
37353
+ if (!flags2.write || flags2.exclusive || codeOf7(err) !== "EACCES") throw err;
37310
37354
  const was = await client.call("stat", { path: rel(path) });
37311
37355
  const mode = was.mode ?? 0;
37312
37356
  if (mode & 128) throw err;
@@ -37332,6 +37376,10 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
37332
37376
  const client = current();
37333
37377
  const token = client.token;
37334
37378
  const { opened: opened2, restore } = await writable3(client, path, flags2);
37379
+ if (flags2.exclusive && (opened2.created === false || opened2.attr && (opened2.attr.kind !== "file" || opened2.attr.size !== 0))) {
37380
+ await client.call("release", { fh: opened2.fh }, true);
37381
+ throw fsError2("EEXIST", path);
37382
+ }
37335
37383
  if (flags2.ifMatch !== void 0 && opened2.attr?.etag !== flags2.ifMatch) {
37336
37384
  await client.call("release", { fh: opened2.fh }, true);
37337
37385
  throw fsError2("ESTALE", `${path} changed on the host while it was being read`);