@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.
@@ -5273,7 +5273,7 @@ function satisfies(version, range2) {
5273
5273
  }
5274
5274
 
5275
5275
  // src/version.ts
5276
- var KERNEL_VERSION = true ? "1.196.30" : "0.0.0-dev";
5276
+ var KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
5277
5277
  var OS_RELEASE = "6.0.0-slicc";
5278
5278
  function procVersion() {
5279
5279
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13471,12 +13471,15 @@ var MountFs = class _MountFs {
13471
13471
  );
13472
13472
  }
13473
13473
  if (a?.mount !== b?.mount) throw errnoError("EXDEV", `${from} -> ${to}`);
13474
- if (a) this.writable(a.mount, normalizePath(to));
13474
+ if (a && !options.exclusive) this.writable(a.mount, normalizePath(to));
13475
13475
  return copyByBytes(this, source, to, options);
13476
13476
  }
13477
13477
  async createExclusive(path, owner, redirects = 0) {
13478
+ const real2 = normalizePath(path);
13479
+ const found = this.at(real2);
13480
+ if (found) return this.createMounted(found, real2, owner);
13478
13481
  const exclusive = this.base.createExclusive?.bind(this.base);
13479
- if (!this.at(path) && exclusive) {
13482
+ if (exclusive) {
13480
13483
  return this.based(
13481
13484
  [path],
13482
13485
  redirects,
@@ -13491,6 +13494,39 @@ var MountFs = class _MountFs {
13491
13494
  if (there) throw errnoError("EEXIST", path);
13492
13495
  await this.writeFile(path, new Uint8Array(0), owner);
13493
13496
  }
13497
+ async createMounted(found, real2, owner) {
13498
+ const { mount, rel: rel2 } = found;
13499
+ if (rel2 === "/") throw errnoError("EEXIST", real2);
13500
+ await mount.conn.call({ op: "getattr", path: rel2 }).then(
13501
+ () => {
13502
+ throw errnoError("EEXIST", real2);
13503
+ },
13504
+ (err) => {
13505
+ if (err?.code !== "ENOENT") throw err;
13506
+ }
13507
+ );
13508
+ this.writable(mount, real2);
13509
+ if (owner?.fifo) return this.mkfifo(found, real2, owner);
13510
+ const made2 = await this.driverOwner(found, real2, owner, false);
13511
+ await this.table.commit(real2);
13512
+ this.table.forget(mount, real2);
13513
+ try {
13514
+ const fh = await mount.conn.call({
13515
+ op: "open",
13516
+ path: rel2,
13517
+ write: true,
13518
+ create: true,
13519
+ exclusive: true,
13520
+ truncate: false,
13521
+ ...made2
13522
+ });
13523
+ if (typeof fh !== "number" || !Number.isSafeInteger(fh) || fh < 0)
13524
+ throw errnoError("EIO", real2);
13525
+ await mount.conn.call({ op: "release", fh });
13526
+ } finally {
13527
+ this.table.forget(mount, real2);
13528
+ }
13529
+ }
13494
13530
  async lstat(path, redirects = 0) {
13495
13531
  const found = this.at(path);
13496
13532
  if (!found) {
@@ -36515,11 +36551,16 @@ function kernelFsHandlers(fs) {
36515
36551
  return [{ name: name2, kind: attr2.kind, attr: attr2 }];
36516
36552
  }),
36517
36553
  async open(path, flags2) {
36518
- const st = await existing(path);
36519
- if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36520
- if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36521
- if (!st && !flags2.create) throw fsError2("ENOENT", path);
36522
- if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36554
+ if (flags2.create && flags2.exclusive) {
36555
+ if (!fs.createExclusive) throw fsError2("ENOTSUP", path);
36556
+ await fs.createExclusive(path);
36557
+ } else {
36558
+ const st = await existing(path);
36559
+ if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36560
+ if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36561
+ if (!st && !flags2.create) throw fsError2("ENOENT", path);
36562
+ if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36563
+ }
36523
36564
  handles.set(++nextFh, { path });
36524
36565
  return nextFh;
36525
36566
  },
@@ -36918,11 +36959,14 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
36918
36959
  });
36919
36960
  async function writable3(client2, path, flags2) {
36920
36961
  const { ifMatch: _, ...asked } = flags2;
36921
- const opening2 = () => client2.call("open", { path: rel(path), ...asked });
36962
+ const opening2 = () => client2.call("open", {
36963
+ path: rel(path),
36964
+ ...asked
36965
+ });
36922
36966
  try {
36923
36967
  return { opened: await opening2(), restore: void 0 };
36924
36968
  } catch (err) {
36925
- if (!flags2.write || codeOf7(err) !== "EACCES") throw err;
36969
+ if (!flags2.write || flags2.exclusive || codeOf7(err) !== "EACCES") throw err;
36926
36970
  const was = await client2.call("stat", { path: rel(path) });
36927
36971
  const mode = was.mode ?? 0;
36928
36972
  if (mode & 128) throw err;
@@ -36948,6 +36992,10 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
36948
36992
  const client2 = current();
36949
36993
  const token = client2.token;
36950
36994
  const { opened: opened2, restore: restore2 } = await writable3(client2, path, flags2);
36995
+ if (flags2.exclusive && (opened2.created === false || opened2.attr && (opened2.attr.kind !== "file" || opened2.attr.size !== 0))) {
36996
+ await client2.call("release", { fh: opened2.fh }, true);
36997
+ throw fsError2("EEXIST", path);
36998
+ }
36951
36999
  if (flags2.ifMatch !== void 0 && opened2.attr?.etag !== flags2.ifMatch) {
36952
37000
  await client2.call("release", { fh: opened2.fh }, true);
36953
37001
  throw fsError2("ESTALE", `${path} changed on the host while it was being read`);