Summary
On the wasm32-hwjs runtime, the file-attribute syscalls fchmod/fchown/utimes and
unlink return ENOSYS ("Function not implemented"). This breaks bzip2's default
(named-file) compress/decompress mode and rm.
Evidence
Machine: dmitry/bzip2-glibc; observed on the fra2 hardwarejs run-machine.mjs harness as root with a writable /tmp (so this is not a permissions issue).
bzip2 named-file mode:
$ echo the-quick-brown-fox-bzip2 > /tmp/b.txt
$ bzip2 -kf /tmp/b.txt
bzip2: I/O or other error, bailing out. Possible reason follows.
bzip2: Function not implemented
Input file = /tmp/b.txt, output file = /tmp/b.txt.bz2
bzip2: Deleting output file /tmp/b.txt.bz2, if it exists.
bzip2: WARNING: deletion of output file (apparently) failed.
bzip2 compresses the data (a valid 68-byte .bz2 is written) but then bails at the post-write attribute restoration — applySavedFileAttrToOutputFile() does fchmod()/fchown() on the output fd (and utime() after close), and one of those returns ENOSYS, so bzip2 reports an I/O error and tries to delete the output.
unlink:
$ rm -f /tmp/somefile
rm: can't remove '/tmp/somefile': Function not implemented
Not affected
The bzip2 -c stream form does no attribute restoration and exits clean:
$ bzip2 -c /tmp/b.txt > /tmp/b.bz2 && echo RC=$? -> RC=0
$ bzip2 -t /tmp/b.bz2 && echo OK -> OK
$ bunzip2 -c /tmp/b.bz2 ; bzcat /tmp/b.bz2 -> recover the original
Suggested fix
Implement these syscalls on wasm32-hwjs — even as accept-and-succeed no-ops for fchmod/fchown/utimes (the wasm image has no meaningful ownership/mode semantics), and a working unlink/unlinkat — so bzip2's default file mode and rm succeed instead of failing with ENOSYS.