@ai-ecoverse/slicc-kernel 1.89.0 → 1.90.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.
@@ -3876,7 +3876,7 @@ var KERNEL_VERSION, OS_RELEASE;
3876
3876
  var init_version = __esm({
3877
3877
  "src/version.ts"() {
3878
3878
  "use strict";
3879
- KERNEL_VERSION = true ? "1.89.0" : "0.0.0-dev";
3879
+ KERNEL_VERSION = true ? "1.90.0" : "0.0.0-dev";
3880
3880
  OS_RELEASE = "6.0.0-slicc";
3881
3881
  }
3882
3882
  });
@@ -6428,6 +6428,50 @@ function useLiveChown(Fs) {
6428
6428
  Fs.chown(target, uid, gid);
6429
6429
  };
6430
6430
  }
6431
+ function flushOne(Fs, node) {
6432
+ const s = node.live;
6433
+ if (!s.dirty || s.orphan || !(s.data || s.ranged)) return;
6434
+ try {
6435
+ if (s.ranged) s.ranged.flush();
6436
+ else {
6437
+ const bytes = s.data.slice(0, s.len);
6438
+ pinnedIo2(node.mount.opts.bridge, s.handle).writeFile(liveNodePath(node), bytes, true);
6439
+ }
6440
+ } catch (err) {
6441
+ throw toErrno(Fs, err);
6442
+ }
6443
+ s.dirty = false;
6444
+ s.stat = void 0;
6445
+ }
6446
+ function linkable(bridge, path) {
6447
+ try {
6448
+ return bridge.lstat(path).linkable === true;
6449
+ } catch {
6450
+ return false;
6451
+ }
6452
+ }
6453
+ function linkLive(Fs, from, to, follow2) {
6454
+ const target = to.replace(/\/+$/, "");
6455
+ const slash = target.lastIndexOf("/");
6456
+ const name2 = target.slice(slash + 1);
6457
+ const source = Fs.lookupPath(from, { follow: follow2 }).node;
6458
+ const parent = Fs.lookupPath(target.slice(0, slash) || "/", { follow: true }).node;
6459
+ if (!source.live || !parent.live) return false;
6460
+ flushOne(Fs, source);
6461
+ const base = liveNodePath(parent);
6462
+ const bridge = source.mount.opts.bridge;
6463
+ const path = liveNodePath(source);
6464
+ try {
6465
+ bridge.link(path, base === "/" ? `/${name2}` : `${base}/${name2}`);
6466
+ } catch (err) {
6467
+ const refused2 = toErrno(Fs, err);
6468
+ if (refused2.errno !== wasiErrno("EPERM") || linkable(bridge, path)) throw refused2;
6469
+ throw new Fs.ErrnoError(wasiErrno("EMLINK"));
6470
+ }
6471
+ source.live.stat = void 0;
6472
+ parent.live.listed = void 0;
6473
+ return true;
6474
+ }
6431
6475
  function readingLinks(Fs) {
6432
6476
  const readlink = Fs.readlink?.bind(Fs);
6433
6477
  if (!readlink) return;
@@ -7138,6 +7182,32 @@ function kernelAccess(imports, fs, memory, glue) {
7138
7182
  }
7139
7183
  });
7140
7184
  }
7185
+ function kernelLink(imports, fs, memory, glue) {
7186
+ wrapImport(
7187
+ imports,
7188
+ "linkat",
7189
+ glue,
7190
+ (own) => (olddirfd, oldpath, newdirfd, newpath, flags) => {
7191
+ const Fs = fs();
7192
+ const heap = memory();
7193
+ if (!Fs?.lookupPath || !heap) return own(olddirfd, oldpath, newdirfd, newpath, flags);
7194
+ const at = (dirfd, ptr) => {
7195
+ const name2 = cString(heap, ptr);
7196
+ return name2.startsWith("/") ? name2 : `${baseOf(Fs, dirfd)}/${name2}`;
7197
+ };
7198
+ try {
7199
+ const from = at(olddirfd, oldpath);
7200
+ const to = at(newdirfd, newpath);
7201
+ const follow2 = (flags & AT_SYMLINK_FOLLOW) !== 0;
7202
+ if (linkLive(Fs, from, to, follow2)) return 0;
7203
+ } catch (err) {
7204
+ return -errnoOf(err);
7205
+ }
7206
+ return own(olddirfd, oldpath, newdirfd, newpath, flags);
7207
+ },
7208
+ true
7209
+ );
7210
+ }
7141
7211
  function kernelChdir(Fs) {
7142
7212
  const { chdir, lookupPath, ErrnoError } = Fs;
7143
7213
  if (!chdir || !lookupPath || !ErrnoError) return;
@@ -7165,7 +7235,7 @@ function linuxDevices(Fs) {
7165
7235
  }
7166
7236
  }
7167
7237
  }
7168
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, W_ACCESS, X_ACCESS, DEVICE_MODES;
7238
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW2, EMSCRIPTEN_EPERM, O_PATH2, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY4, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS2, W_ACCESS, X_ACCESS, AT_SYMLINK_FOLLOW, DEVICE_MODES;
7169
7239
  var init_process_fds = __esm({
7170
7240
  "src/process/process-fds.ts"() {
7171
7241
  "use strict";
@@ -7200,6 +7270,7 @@ var init_process_fds = __esm({
7200
7270
  mknodat: "__syscall_mknodat",
7201
7271
  umask: "__syscall_umask",
7202
7272
  faccessat: "__syscall_faccessat",
7273
+ linkat: "__syscall_linkat",
7203
7274
  utimensat: "__syscall_utimensat",
7204
7275
  getppid: "slicc_getppid_js",
7205
7276
  resizeHeap: "emscripten_resize_heap",
@@ -7226,6 +7297,7 @@ var init_process_fds = __esm({
7226
7297
  AT_EACCESS2 = 512;
7227
7298
  W_ACCESS = 2;
7228
7299
  X_ACCESS = 1;
7300
+ AT_SYMLINK_FOLLOW = 1024;
7229
7301
  DEVICE_MODES = [
7230
7302
  ["/", 493],
7231
7303
  ["/dev", 493],
@@ -10997,6 +11069,7 @@ function kernelWrappers(imports, module, deps) {
10997
11069
  const fsOf = () => ownValue(module, "FS");
10998
11070
  noFollowUtimes(imports, fsOf, kernelGlue?.utimensat ?? utimensatOf(module), memory);
10999
11071
  kernelAccess(imports, fsOf, memory, kernelGlue);
11072
+ kernelLink(imports, fsOf, memory, kernelGlue);
11000
11073
  const glue = ownValue(module, "sliccFdImports");
11001
11074
  syncFsync(imports, fsOf, glue);
11002
11075
  positionalIo(imports, { glue, fs: fsOf, sys, memory });
@@ -11295,6 +11368,7 @@ var init_process_runtime = __esm({
11295
11368
  " mknodat: typeof ___syscall_mknodat === 'function' ? ___syscall_mknodat : undefined,",
11296
11369
  " umask: typeof ___syscall_umask === 'function' ? ___syscall_umask : undefined,",
11297
11370
  " faccessat: typeof ___syscall_faccessat === 'function' ? ___syscall_faccessat : undefined,",
11371
+ " linkat: typeof ___syscall_linkat === 'function' ? ___syscall_linkat : undefined,",
11298
11372
  " utimensat: typeof ___syscall_utimensat === 'function' ? ___syscall_utimensat : undefined,",
11299
11373
  " getppid: typeof _slicc_getppid_js === 'function' ? _slicc_getppid_js : undefined,",
11300
11374
  " resizeHeap: typeof _emscripten_resize_heap === 'function' ? _emscripten_resize_heap : undefined,",