@ai-ecoverse/slicc-kernel 1.29.1 → 1.29.2

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();
@@ -3272,6 +3294,7 @@ function withCommandDirs(fs, names) {
3272
3294
  readlink: (path) => fs.readlink(path),
3273
3295
  chmod: (path, mode) => fs.chmod(path, mode),
3274
3296
  utimes: (path, atime, mtime) => fs.utimes(path, atime, mtime),
3297
+ lutimes: (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
3275
3298
  ...rangedOps(fs) ?? {}
3276
3299
  };
3277
3300
  }
@@ -3347,7 +3370,11 @@ var FsWatchers = class {
3347
3370
  rename: after(fs.rename.bind(fs), (from, to) => [from, to]),
3348
3371
  symlink: after(fs.symlink.bind(fs), (_target, path) => [path]),
3349
3372
  chmod: after(fs.chmod.bind(fs), (path) => [path]),
3350
- utimes: after(fs.utimes.bind(fs), (path) => [path])
3373
+ utimes: after(fs.utimes.bind(fs), (path) => [path]),
3374
+ lutimes: after(
3375
+ (path, atime, mtime) => lutimesOf(fs, path, atime, mtime),
3376
+ (path) => [path]
3377
+ )
3351
3378
  };
3352
3379
  const ranged2 = rangedOps(fs);
3353
3380
  if (ranged2) {
@@ -4275,10 +4302,23 @@ var MountFs = class {
4275
4302
  await found.mount.conn.call({ op: "setattr", path: found.rel, mode });
4276
4303
  }
4277
4304
  async utimes(path, atime, mtime) {
4305
+ const real = await this.follow(path);
4306
+ const found = this.at(real);
4307
+ if (!found) return this.base.utimes(real, atime, mtime);
4308
+ await this.setMtime(found, real, mtime);
4309
+ }
4310
+ async lutimes(path, atime, mtime) {
4278
4311
  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));
4312
+ if (!found) return lutimesOf(this.base, path, atime, mtime);
4313
+ const real = normalizePath(path);
4314
+ if (!found.mount.caps.linkTimes && (await this.lstat(real)).isSymbolicLink) {
4315
+ throw errnoError("EOPNOTSUPP", path);
4316
+ }
4317
+ await this.setMtime(found, real, mtime);
4318
+ }
4319
+ async setMtime(found, real, mtime) {
4320
+ this.writable(found.mount, real);
4321
+ this.table.forget(found.mount, real);
4282
4322
  await found.mount.conn.call({ op: "setattr", path: found.rel, mtime: mtime.getTime() });
4283
4323
  }
4284
4324
  };
@@ -4392,6 +4432,9 @@ async function run(entry, path, req) {
4392
4432
  case "utimes":
4393
4433
  await fs.utimes(path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
4394
4434
  return done;
4435
+ case "lutimes":
4436
+ await lutimesOf(fs, path, new Date(req.atimeMs ?? 0), new Date(req.mtimeMs ?? 0));
4437
+ return done;
4395
4438
  case "pread":
4396
4439
  case "pwrite":
4397
4440
  case "truncate":
@@ -10038,7 +10081,7 @@ var Launcher = class {
10038
10081
  serveFilesystem(
10039
10082
  port2,
10040
10083
  tmpfs(),
10041
- { symlinks: true, chmod: true, ranges: true, attrTtl: 0 },
10084
+ { symlinks: true, chmod: true, linkTimes: true, ranges: true, attrTtl: 0 },
10042
10085
  { owned: true }
10043
10086
  );
10044
10087
  return {