@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.
@@ -9383,7 +9383,7 @@ var init_version = __esm({
9383
9383
  "src/version.ts"() {
9384
9384
  "use strict";
9385
9385
  init_captured_globals();
9386
- KERNEL_VERSION = true ? "1.196.30" : "0.0.0-dev";
9386
+ KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
9387
9387
  OS_RELEASE = "6.0.0-slicc";
9388
9388
  }
9389
9389
  });
@@ -9382,7 +9382,7 @@ var init_version = __esm({
9382
9382
  "src/version.ts"() {
9383
9383
  "use strict";
9384
9384
  init_captured_globals();
9385
- KERNEL_VERSION = true ? "1.196.30" : "0.0.0-dev";
9385
+ KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
9386
9386
  OS_RELEASE = "6.0.0-slicc";
9387
9387
  }
9388
9388
  });
package/dist/node.js CHANGED
@@ -7789,7 +7789,7 @@ function satisfies(version, range2) {
7789
7789
  }
7790
7790
 
7791
7791
  // src/version.ts
7792
- var KERNEL_VERSION = true ? "1.196.30" : "0.0.0-dev";
7792
+ var KERNEL_VERSION = true ? "1.196.31" : "0.0.0-dev";
7793
7793
  var OS_RELEASE = "6.0.0-slicc";
7794
7794
  function procVersion() {
7795
7795
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -14294,12 +14294,15 @@ var MountFs = class _MountFs {
14294
14294
  );
14295
14295
  }
14296
14296
  if (a?.mount !== b?.mount) throw errnoError("EXDEV", `${from} -> ${to}`);
14297
- if (a) this.writable(a.mount, normalizePath(to));
14297
+ if (a && !options.exclusive) this.writable(a.mount, normalizePath(to));
14298
14298
  return copyByBytes(this, source, to, options);
14299
14299
  }
14300
14300
  async createExclusive(path, owner, redirects = 0) {
14301
+ const real = normalizePath(path);
14302
+ const found = this.at(real);
14303
+ if (found) return this.createMounted(found, real, owner);
14301
14304
  const exclusive = this.base.createExclusive?.bind(this.base);
14302
- if (!this.at(path) && exclusive) {
14305
+ if (exclusive) {
14303
14306
  return this.based(
14304
14307
  [path],
14305
14308
  redirects,
@@ -14314,6 +14317,39 @@ var MountFs = class _MountFs {
14314
14317
  if (there) throw errnoError("EEXIST", path);
14315
14318
  await this.writeFile(path, new Uint8Array(0), owner);
14316
14319
  }
14320
+ async createMounted(found, real, owner) {
14321
+ const { mount, rel: rel2 } = found;
14322
+ if (rel2 === "/") throw errnoError("EEXIST", real);
14323
+ await mount.conn.call({ op: "getattr", path: rel2 }).then(
14324
+ () => {
14325
+ throw errnoError("EEXIST", real);
14326
+ },
14327
+ (err) => {
14328
+ if (err?.code !== "ENOENT") throw err;
14329
+ }
14330
+ );
14331
+ this.writable(mount, real);
14332
+ if (owner?.fifo) return this.mkfifo(found, real, owner);
14333
+ const made2 = await this.driverOwner(found, real, owner, false);
14334
+ await this.table.commit(real);
14335
+ this.table.forget(mount, real);
14336
+ try {
14337
+ const fh = await mount.conn.call({
14338
+ op: "open",
14339
+ path: rel2,
14340
+ write: true,
14341
+ create: true,
14342
+ exclusive: true,
14343
+ truncate: false,
14344
+ ...made2
14345
+ });
14346
+ if (typeof fh !== "number" || !Number.isSafeInteger(fh) || fh < 0)
14347
+ throw errnoError("EIO", real);
14348
+ await mount.conn.call({ op: "release", fh });
14349
+ } finally {
14350
+ this.table.forget(mount, real);
14351
+ }
14352
+ }
14317
14353
  async lstat(path, redirects = 0) {
14318
14354
  const found = this.at(path);
14319
14355
  if (!found) {
@@ -36843,11 +36879,16 @@ function kernelFsHandlers(fs) {
36843
36879
  return [{ name: name2, kind: attr2.kind, attr: attr2 }];
36844
36880
  }),
36845
36881
  async open(path, flags2) {
36846
- const st = await existing(path);
36847
- if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36848
- if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36849
- if (!st && !flags2.create) throw fsError2("ENOENT", path);
36850
- if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36882
+ if (flags2.create && flags2.exclusive) {
36883
+ if (!fs.createExclusive) throw fsError2("ENOTSUP", path);
36884
+ await fs.createExclusive(path);
36885
+ } else {
36886
+ const st = await existing(path);
36887
+ if (st && flags2.exclusive) throw fsError2("EEXIST", path);
36888
+ if (st?.isDirectory && flags2.write) throw fsError2("EISDIR", path);
36889
+ if (!st && !flags2.create) throw fsError2("ENOENT", path);
36890
+ if (!st || flags2.truncate) await fs.writeFile(path, new Uint8Array(0));
36891
+ }
36851
36892
  handles.set(++nextFh, { path });
36852
36893
  return nextFh;
36853
36894
  },
@@ -37246,11 +37287,14 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
37246
37287
  });
37247
37288
  async function writable3(client, path, flags2) {
37248
37289
  const { ifMatch: _, ...asked } = flags2;
37249
- const opening2 = () => client.call("open", { path: rel(path), ...asked });
37290
+ const opening2 = () => client.call("open", {
37291
+ path: rel(path),
37292
+ ...asked
37293
+ });
37250
37294
  try {
37251
37295
  return { opened: await opening2(), restore: void 0 };
37252
37296
  } catch (err) {
37253
- if (!flags2.write || codeOf8(err) !== "EACCES") throw err;
37297
+ if (!flags2.write || flags2.exclusive || codeOf8(err) !== "EACCES") throw err;
37254
37298
  const was = await client.call("stat", { path: rel(path) });
37255
37299
  const mode = was.mode ?? 0;
37256
37300
  if (mode & 128) throw err;
@@ -37276,6 +37320,10 @@ function hostfsHandlers(current, againMs = RESTORE_AGAIN_MS) {
37276
37320
  const client = current();
37277
37321
  const token = client.token;
37278
37322
  const { opened: opened2, restore } = await writable3(client, path, flags2);
37323
+ if (flags2.exclusive && (opened2.created === false || opened2.attr && (opened2.attr.kind !== "file" || opened2.attr.size !== 0))) {
37324
+ await client.call("release", { fh: opened2.fh }, true);
37325
+ throw fsError2("EEXIST", path);
37326
+ }
37279
37327
  if (flags2.ifMatch !== void 0 && opened2.attr?.etag !== flags2.ifMatch) {
37280
37328
  await client.call("release", { fh: opened2.fh }, true);
37281
37329
  throw fsError2("ESTALE", `${path} changed on the host while it was being read`);