brintos

brintos / linux public Read only

0
0

wasm32: creat(2) unimplemented (ENOSYS) while open/openat work -> tar -cf <file> "Cannot open: Function not implemented" #13

Open dmitry opened this issue · 0 comments
D dmitry commented

Summary

On the wasm32-hwjs glibc arm, glibc creat() fails with ENOSYS ("Function not implemented"), while open()/openat() with O_CREAT succeed. Any program that creates a file via creat(2) rather than open(2) breaks. GNU tar's default archive-create path uses creat(), so tar -cf <file> ... fails:

a2$ tar -cf a.tar src
tar: a.tar: Cannot open: Function not implemented
tar: Error is not recoverable: exiting now

Confirmed differential (deployed core-image-brintos-emcraft, glibc)

  • tar -cf a.tar src -> ENOSYS (tar lib/rmt.h rmtcreat -> creat(name, mode))
  • tar -cWf b.tar src -> OK, 10240 B (--verify takes rmtopen -> open(name, O_RDWR|O_CREAT))
  • cp /etc/hostname /tmp/x -> OK (coreutils, open O_WRONLY|O_CREAT via openat)
  • busybox (exec 3<> /tmp/x) and (exec 3> /tmp/x) -> OK (openat O_RDWR|O_CREAT / O_WRONLY|O_CREAT)
  • tar -xf - < arc.tar extract -> OK, files created (extract.c opens output via openat)
  • tar -cf - src > arc.tar stream -> OK (tar writes stdout; the shell opens the file)

The failure is specific to the creat() entry point — not to file creation, O_CREAT, O_RDWR, or O_LARGEFILE (all succeed via open/openat). Consistent with asm-generic/unistd.h omitting __NR_creat (only __NR_openat = 56 is wired): glibc creat() on this port reaches an unimplemented path instead of falling back to openat.

Impact

  • GNU tar cannot create a named archive (tar -cf FILE ...) — the common form.
  • Any glibc program that calls creat(2) directly.
  • Does NOT affect dpkg-deb --build, which pipes tar -cf - | <compressor>.

Workaround

Use the stream form (the shell opens the output; tar writes stdout):

tar -cf - src > out.tar        # create
tar -tf - < out.tar            # list
tar -xf - < out.tar            # extract (+ --no-same-owner --no-same-permissions -m
                               #  to skip the chown/fchmod/utimes ENOSYS)

Or force the O_RDWR open path with --verify: tar -cWf out.tar src.

Suggested fix

Route glibc creat()/creat64() through openat(2) on the wasm32-hwjs port (as generic glibc creat.c does), or wire the creat path in the runtime's syscall table. open/openat already work.