Skip to content

imfs grate: readlink/readlinkat stubbed to ENOSYS — breaks Perl File::Temp and the test harness, ~40 tests #176

@vidyalakshmir

Description

@vidyalakshmir

Summary

Under the fs-routing setup, ~40 Perl-driven coreutils tests fail with Use of uninitialized value
$fname in pattern match (m//) at //lib/perl5/5.40.4/File/Temp.pm line 964 followed by a wave of
: cannot unlink X.E.orig: No such file or directory. The same tests pass on the bare wasm
runtime.

Reproduction

  ./run_default_tests.sh --grate fs-routing-clamp misc/factor
  Use of uninitialized value $fname in pattern match (m//) at //lib/perl5/5.40.4/File/Temp.pm line
   964.
  factor: cannot unlink 1.E.orig: No such file or directory

Root cause

imfs-grate/src/main.rs:83-84 registers both SYS_READLINK and SYS_READLINKAT to
handlers::enosys_handler — i.e. readlink always returns ENOSYS inside the imfs.

Perl's File::Temp calls readlink while resolving / validating temp paths; an ENOSYS return
leaves $fname uninitialized (File/Temp.pm:964), which then poisons the harness's Coreutils.pm
rename-and-compare logic (rename $out, $orig then unlink), producing the cascade of cannot
unlink *.E.orig errors. The test bodies never actually run.

Affected tests (~40)

dd/skip-seek, dd/unblock, misc/base64, misc/basename, misc/comm, misc/date-next-dow,
misc/dircolors, misc/dirname, misc/expand, misc/expr, misc/factor, misc/fmt, misc/fold,
misc/head, misc/head-elide-tail, misc/md5sum, misc/mktemp, misc/od, misc/paste, misc/pr,
misc/ptx, misc/sha1sum, misc/sha1sum-vec, misc/sha224sum, misc/sha256sum, misc/sha384sum,
misc/sha512sum, misc/stat-printf, misc/sum, misc/tac, misc/tail, misc/tr, misc/tsort, misc/uniq,
misc/wc, misc/xstrtol, mv/i-1, pr/pr-tests, rm/unreadable.

Suggested fix

Replace the enosys_handler registrations for SYS_READLINK/SYS_READLINKAT with real handlers that resolve the path (without following the final component) and, if the target is a Lnk node, copy its stored target string back to the cage buffer; return EINVAL for non-symlinks and
ENOENT/ENOTDIR as appropriate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions