Closed qianxichen233 closed 6 days ago
We talked about this briefly at some point with @JustinCappos and I'm tagging him to clarify. The struct thats actually passed to the native kernel has a defined structure, and we want to match that. I believe the best way is to change the libc struct to match?
The stat struct in glibc does not match rawposix.
Why is this the case? Isn't glibc what is used by Rust's libc which rawposix calls?
rawposix has its own statData definition (https://github.com/Lind-Project/RawPOSIX/blob/main/src/interface/types.rs#L55) So the stat_syscall in rawposix basically defines a libc_statbuf and pass to libc::stat, then assigns the corresponding field in libc_statbuf to rawposix statData
When implementing RawPOSIX, there were conflicts between NaCl stat
struct and libc stat
struct. I think the issue is cause by pre-allocated memory region in 32-bit NaCl doesn't fit 64-bit kernel results. To integrate NaCl, I chose to manually copy out rust libc stat
result to NaCl's structure at that time
When implementing RawPOSIX, there were conflicts between NaCl
stat
struct and libcstat
struct. I think the issue is cause by pre-allocated memory region in 32-bit NaCl doesn't fit 64-bit kernel results. To integrate NaCl, I chose to manually copy out rust libcstat
result to NaCl's structure at that time
Right, that makes sense. There is most likely problems with the struct layout when translating from 32 to 64 bit, hence the weird nacl layout.
@robinyuan1002 this issue got fixed in the last merge, correct?
@rennergade there is still a minor issue with stat stuff when compile bash, so I guess let's leave this issue until this has been figured out
@rennergade Yes, the problem of 64bit and 32bit is solved for stat.
The stat struct in glibc does not match rawposix. This causes the value assigned to stat struct in rawposix failed to update in glibc. Now all the testsuite that is using stat-related syscalls are running and will not yield any error, but the information in stat struct is incorrectly updated. I've talked with Alice about this, and in nacl, there seems to be some kind of transformation happened in nacl runtime on stat struct to make it work. And after discussion with Nick, we decided to make the stat struct in rawposix match glibc, so no extra steps should be involved in wasmtime.