@ai-ecoverse/slicc-kernel 1.29.1 → 1.30.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
@@ -93,6 +93,11 @@ function rangedOps(fs) {
93
93
  if (!pread || !pwrite || !truncate) return void 0;
94
94
  return { pread: pread.bind(fs), pwrite: pwrite.bind(fs), truncate: truncate.bind(fs) };
95
95
  }
96
+ async function lutimesOf(fs, path, atime, mtime) {
97
+ if (fs.lutimes) return fs.lutimes(path, atime, mtime);
98
+ if ((await fs.lstat(path)).isSymbolicLink) throw fsError("EOPNOTSUPP", path);
99
+ return fs.utimes(path, atime, mtime);
100
+ }
96
101
  function fsError(code, path) {
97
102
  return Object.assign(new Error(`${code}: ${path}`), { code });
98
103
  }
@@ -1964,7 +1969,7 @@ var OpfsFs = class {
1964
1969
  size: new TextEncoder().encode(entry.link).length,
1965
1970
  mode: S_IFLNK | 511,
1966
1971
  mtime: time2,
1967
- atime: time2,
1972
+ atime: entry.atimeMs === void 0 ? time2 : new Date(entry.atimeMs),
1968
1973
  ctime: new Date(entry.ctimeMs ?? 0),
1969
1974
  ino: entry.ino ?? inodeOf(entry.path)
1970
1975
  };
@@ -2260,7 +2265,24 @@ var OpfsFs = class {
2260
2265
  }));
2261
2266
  }
2262
2267
  async utimes(path, atime, mtime) {
2263
- const found = await this.locate(path, true);
2268
+ await this.setTimes(await this.locate(path, true), atime, mtime);
2269
+ }
2270
+ async lutimes(path, atime, mtime) {
2271
+ await this.setTimes(await this.locate(path, false), atime, mtime);
2272
+ }
2273
+ async setTimes(found, atime, mtime) {
2274
+ const { link: link2 } = found;
2275
+ if (link2) {
2276
+ const ctimeMs2 = Date.now();
2277
+ await this.meta.update(found.path, (entry) => ({
2278
+ ...link2,
2279
+ ...entry,
2280
+ atimeMs: atime.getTime(),
2281
+ mtimeMs: mtime.getTime(),
2282
+ ctimeMs: ctimeMs2
2283
+ }));
2284
+ return;
2285
+ }
2264
2286
  const handle = found.handle;
2265
2287
  const file = handle.kind === "file" ? await handle.getFile() : void 0;
2266
2288
  const ctimeMs = Date.now();
@@ -3060,6 +3082,7 @@ function commandOf(pkg, name2, raw, packageAbi, shared) {
3060
3082
  wasm,
3061
3083
  argv0,
3062
3084
  ...raw.argv0Path === true ? { argv0Path: true } : {},
3085
+ ...abi === "wasi" && raw.preopenRoot === true ? { preopenRoot: true } : {},
3063
3086
  ...args ? { args } : {},
3064
3087
  ...withEnv,
3065
3088
  ...imports ? { imports } : {}
@@ -3272,6 +3295,7 @@ function withCommandDirs(fs, names) {
3272
3295
  readlink: (path) => fs.readlink(path),
3273
3296
  chmod: (path, mode) => fs.chmod(path, mode),
3274
3297
  utimes: (path, atime, mtime) => fs.utimes(path, atime, mtime),
3298
+ lutimes: (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
3275
3299
  ...rangedOps(fs) ?? {}
3276
3300
  };
3277
3301
  }
@@ -3347,7 +3371,11 @@ var FsWatchers = class {
3347
3371
  rename: after(fs.rename.bind(fs), (from, to) => [from, to]),
3348
3372
  symlink: after(fs.symlink.bind(fs), (_target, path) => [path]),
3349
3373
  chmod: after(fs.chmod.bind(fs), (path) => [path]),
3350
- utimes: after(fs.utimes.bind(fs), (path) => [path])
3374
+ utimes: after(fs.utimes.bind(fs), (path) => [path]),
3375
+ lutimes: after(
3376
+ (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
3377
+ (path) => [path]
3378
+ )
3351
3379
  };
3352
3380
  const ranged2 = rangedOps(fs);
3353
3381
  if (ranged2) {
@@ -4275,10 +4303,23 @@ var MountFs = class {
4275
4303
  await found.mount.conn.call({ op: "setattr", path: found.rel, mode });
4276
4304
  }
4277
4305
  async utimes(path, atime, mtime) {
4306
+ const real = await this.follow(path);
4307
+ const found = this.at(real);
4308
+ if (!found) return this.base.utimes(real, atime, mtime);
4309
+ await this.setMtime(found, real, mtime);
4310
+ }
4311
+ async lutimes(path, atime, mtime) {
4278
4312
  const found = this.at(path);
4279
- if (!found) return this.base.utimes(path, atime, mtime);
4280
- this.writable(found.mount, normalizePath(path));
4281
- this.table.forget(found.mount, normalizePath(path));
4313
+ if (!found) return lutimesOf(this.base, path, atime, mtime);
4314
+ const real = normalizePath(path);
4315
+ if (!found.mount.caps.linkTimes && (await this.lstat(real)).isSymbolicLink) {
4316
+ throw errnoError("EOPNOTSUPP", path);
4317
+ }
4318
+ await this.setMtime(found, real, mtime);
4319
+ }
4320
+ async setMtime(found, real, mtime) {
4321
+ this.writable(found.mount, real);
4322
+ this.table.forget(found.mount, real);
4282
4323
  await found.mount.conn.call({ op: "setattr", path: found.rel, mtime: mtime.getTime() });
4283
4324
  }
4284
4325
  };
@@ -4392,6 +4433,9 @@ async function run(entry, path, req) {
4392
4433
  case "utimes":
4393
4434
  await fs.utimes(path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
4394
4435
  return done;
4436
+ case "lutimes":
4437
+ await lutimesOf(fs, path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
4438
+ return done;
4395
4439
  case "pread":
4396
4440
  case "pwrite":
4397
4441
  case "truncate":
@@ -7674,9 +7718,10 @@ var WasmProcess = class {
7674
7718
  json: this.fds.numbers().map((fd) => ({ fd, ...this.fdInfo(fd) }))
7675
7719
  };
7676
7720
  case "fd-meta": {
7677
- const file = this.fds.get(req.fd).file;
7678
- if (!file.held) throw new KernelError("EBADF");
7679
- file.heldMeta = req.meta;
7721
+ if (!this.fds.get(req.fd).file.held) throw new KernelError("EBADF");
7722
+ const cloexec = this.fds.closesOnExec(req.fd);
7723
+ this.fds.installAt(req.fd, heldFile(req.meta));
7724
+ if (cloexec) this.fds.setCloseOnExec(req.fd);
7680
7725
  return { ok: true, kind: "void" };
7681
7726
  }
7682
7727
  case "fd-setfl":
@@ -9577,7 +9622,8 @@ function targetOf(command) {
9577
9622
  ...command.args ? { prefix: command.args } : {},
9578
9623
  ...command.env ? { env: command.env } : {},
9579
9624
  ...command.unset ? { unset: command.unset } : {},
9580
- ...command.imports ? { imports: command.imports } : {}
9625
+ ...command.imports ? { imports: command.imports } : {},
9626
+ ...command.preopenRoot ? { preopenRoot: true } : {}
9581
9627
  };
9582
9628
  }
9583
9629
  function childHandle(handle) {
@@ -9813,7 +9859,8 @@ var Launcher = class {
9813
9859
  ...memory ? { memory } : {},
9814
9860
  foreign,
9815
9861
  ...names ? { names } : {},
9816
- ...imports !== void 0 ? { imports } : {}
9862
+ ...imports !== void 0 ? { imports } : {},
9863
+ ...target.preopenRoot ? { preopenRoot: true } : {}
9817
9864
  };
9818
9865
  }
9819
9866
  async launch(planned, req) {
@@ -10038,7 +10085,7 @@ var Launcher = class {
10038
10085
  serveFilesystem(
10039
10086
  port2,
10040
10087
  tmpfs(),
10041
- { symlinks: true, chmod: true, ranges: true, attrTtl: 0 },
10088
+ { symlinks: true, chmod: true, linkTimes: true, ranges: true, attrTtl: 0 },
10042
10089
  { owned: true }
10043
10090
  );
10044
10091
  return {