Summary
Under the fs-routing setup, ~9 coreutils tests fail at a hard-link step with /bin/ln: creating
hard link 'X' => 'Y': Function not implemented (ENOSYS). The same tests pass on the bare wasm
runtime.
Reproduction
./run_default_tests.sh --grate fs-routing-clamp ln/backup-1
/bin/ln: creating hard link `b~' => `b': Function not implemented
Root cause
imfs-grate/src/main.rs registers SYS_LINK (handlers::link_handler → imfs::link, which is fully
implemented at imfs/mod.rs:1530) — but does not register SYS_LINKAT. GNU ln (and cp -l, mv
across same-dir, install) issue linkat(AT_FDCWD, target, AT_FDCWD, linkname, 0), not the legacy
link. With no SYS_LINKAT handler, the call falls through and returns ENOSYS.
Affected tests (~9)
cp/link-preserve, dd/misc, du/hard-link, ln/backup-1, misc/ls-time, mv/force, mv/hard-4,
mv/hard-verbose, mv/i-4, mv/i-link-no.
Suggested fix
Add a linkat_handler in imfs-grate/src/handlers.rs and register SYS_LINKAT in main.rs. For the
common AT_FDCWD case it can dispatch straight to the existing imfs::link; for a real dirfd,
resolve the dirfd to its node and prepend its path before calling imfs::link. (AT_SYMLINK_FOLLOW
in flags should follow a symlink target; without it, hard-link the link itself.)
Summary
Under the fs-routing setup, ~9 coreutils tests fail at a hard-link step with /bin/ln: creating
hard link 'X' => 'Y': Function not implemented (ENOSYS). The same tests pass on the bare wasm
runtime.
Reproduction
Root cause
imfs-grate/src/main.rs registers SYS_LINK (handlers::link_handler → imfs::link, which is fully
implemented at imfs/mod.rs:1530) — but does not register SYS_LINKAT. GNU ln (and cp -l, mv
across same-dir, install) issue linkat(AT_FDCWD, target, AT_FDCWD, linkname, 0), not the legacy
link. With no SYS_LINKAT handler, the call falls through and returns ENOSYS.
Affected tests (~9)
cp/link-preserve, dd/misc, du/hard-link, ln/backup-1, misc/ls-time, mv/force, mv/hard-4,
mv/hard-verbose, mv/i-4, mv/i-link-no.
Suggested fix
Add a linkat_handler in imfs-grate/src/handlers.rs and register SYS_LINKAT in main.rs. For the
common AT_FDCWD case it can dispatch straight to the existing imfs::link; for a real dirfd,
resolve the dirfd to its node and prepend its path before calling imfs::link. (AT_SYMLINK_FOLLOW
in flags should follow a symlink target; without it, hard-link the link itself.)