@ai-ecoverse/slicc-kernel 1.32.1 → 1.32.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/README.md CHANGED
@@ -410,7 +410,7 @@ OPFS stores names, bytes, sizes and modification times, nothing else. Everything
410
410
  - mode bits (`chmod`);
411
411
  - access and change times, and a modification time set explicitly with `utime` (it holds until the file is written again);
412
412
  - inode numbers that stay stable across renames;
413
- - symbolic links (`symlink`, `readlink`, `lstat`, and following them in paths), which exist only in the sidecar, with their own times: `touch -h`, `lutimes` and `utimensat` with `AT_SYMLINK_NOFOLLOW` set the link's, never the target's.
413
+ - symbolic links (`symlink`, `readlink`, `lstat`, and following them in paths), which exist only in the sidecar, with their own times: `touch -h`, `lutimes` and `utimensat` with `AT_SYMLINK_NOFOLLOW` set the link's, never the target's. A link's own mode can't be changed, as on Linux: `chmod -h`, `lchmod` and `fchmodat` with `AT_SYMLINK_NOFOLLOW` fail with `EOPNOTSUPP` (which `chmod -h` and `tar` ignore for links) and never follow it, and `open` with `O_PATH | O_NOFOLLOW` gives a descriptor for the link itself.
414
414
 
415
415
  OPFS stays authoritative: an entry is consulted only for a path that exists in OPFS (symlinks only for paths that don't), so files written straight to OPFS, for example by the BIOS installer or a page, get the defaults: directories `0755`, files `0644`, and files under `node_modules/*/bin/` `0755`. A file deleted through the OPFS API disappears at once; its leftover entry is ignored and removed when the next kernel starts. Changes go to OPFS first and then to the sidecar, so a crash in between at worst loses the metadata of that one change. Each change is a read-modify-write inside one IndexedDB transaction, so two kernels (two tabs) on the same origin don't lose each other's updates.
416
416
 
@@ -781,6 +781,7 @@ function createNodeOps(h) {
781
781
  }
782
782
  const path = liveNodePath(node);
783
783
  if (attr2.mode !== void 0 && attr2.mode !== null) {
784
+ if (Fs.isLink(node.mode)) throw new Fs.ErrnoError(wasiErrno("EOPNOTSUPP"));
784
785
  const perm = attr2.mode & PERM_MASK;
785
786
  if (perm !== (node.mode & PERM_MASK)) {
786
787
  metadataCall(() => bridgeOf(node).chmod(path, perm));
@@ -2086,6 +2087,12 @@ function wrapCloexecSyscalls(imports, glue, deps) {
2086
2087
  }
2087
2088
  }
2088
2089
  }
2090
+ function pathOpensLinks(Fs) {
2091
+ const fs = Fs;
2092
+ const { mayOpen, isLink } = fs;
2093
+ if (!mayOpen || !isLink) return;
2094
+ fs.mayOpen = (node, flags) => flags & O_PATH && isLink.call(fs, node.mode) ? 0 : mayOpen.call(fs, node, flags);
2095
+ }
2089
2096
  function noFollowUtimes(imports, fs, glue) {
2090
2097
  for (const namespace of namespaces(imports)) {
2091
2098
  const key = Object.keys(namespace).find(
@@ -2403,7 +2410,7 @@ function useMounts(Fs, env = {}, live = false) {
2403
2410
  }
2404
2411
  };
2405
2412
  }
2406
- var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE, O_CREAT2, field, NAME;
2413
+ var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE, O_CREAT2, field, NAME;
2407
2414
  var init_process_fds = __esm({
2408
2415
  "src/process/process-fds.ts"() {
2409
2416
  "use strict";
@@ -2430,6 +2437,7 @@ var init_process_fds = __esm({
2430
2437
  EBADF = 8;
2431
2438
  AT_SYMLINK_NOFOLLOW = 256;
2432
2439
  EMSCRIPTEN_EPERM = 63;
2440
+ O_PATH = 2097152;
2433
2441
  DIR_MODE = 16749;
2434
2442
  LINK_MODE = 41408;
2435
2443
  CHAR_DEVICE = 8630;
@@ -3750,6 +3758,7 @@ async function runWasmProcess(init, port2, deps = {}) {
3750
3758
  if (!hasStreams(m)) return;
3751
3759
  const fs = m.FS;
3752
3760
  trackCloseOnExec(fs);
3761
+ pathOpensLinks(fs);
3753
3762
  try {
3754
3763
  fs.mkdirTree(init.cwd);
3755
3764
  fs.chdir(init.cwd);