unikraft / lib-musl

musl: A C standard library
Other
8 stars 27 forks source link

Use function declaration for getdents64 #31

Closed razvand closed 1 year ago

razvand commented 1 year ago

When defining getdents64 as a macro aliasing getdents, the syscall shim layer complains.

This patch uses a typical C-style declaration of getdents64(). This, combined with the LFS64(getdents), aliasing used in src/dirent/__getdents.c solves the issue with the syscall shim layer.

The getdents64 symbol is then provided to applications as an alias to getdents, while the uk_syscall_getdents64 syscall is provided by Unikraft:

razvan@yggdrasil:~/.../workdir/apps/app-nginx$ nm build/libmusl.o | grep getdents
00000000000002e0 W getdents
00000000000002e0 T __getdents
00000000000002e0 W getdents64
                 U uk_syscall_r_getdents64
razvan@yggdrasil:~/.../workdir/apps/app-nginx$ nm build/nginx_kvm-x86_64.dbg | grep getdents
000000000014d9a0 t getdents
000000000014d9a0 t __getdents
000000000014d9a0 t getdents64
0000000000144420 t uk_syscall_e_getdents
0000000000144600 t uk_syscall_e_getdents64
00000000001442b0 t __uk_syscall_r_getdents
00000000001443e0 t uk_syscall_r_getdents
0000000000144490 t __uk_syscall_r_getdents64
00000000001445c0 t uk_syscall_r_getdents64
razvand commented 1 year ago

This works fine when using getdents64, but when you specifically call getdents, getdents64 get called instead because of this macro.

This was an issue with the older version of this pr too, I just didn't catch it.

But that was the case at all times, right? I don't think it's a problem. Currently, the Musl functions (getdents and getdents64) and up calling SYS_getdents / uk_syscall_getdents (NOT uk_syscall_getdents64). So that's OK for this time.

So, I know it's messy, but it will be messy in all cases. And in all cases getdents and getdents64 end up calling SYS_getdents / uk_syscall_getdents.

We would focus on proper implementation for ..64 variants (cough you, @StefanJum cough) later on.

But anything we do now will not solve / improve this.