libsel4muslcsys: Add fstat syscall#100
libsel4muslcsys: Add fstat syscall#100dasch8-neutrality wants to merge 5 commits intoseL4:masterfrom
Conversation
The implementation only sets the file mode. It is also only implemented for STDIN, STDOUT and STDERR. This is to support libraries that insist on calling fstat on file descriptors before doing I/O. Signed-off-by: Daniel Schwyn <[email protected]>
3ff410c to
b28b020
Compare
musllibc does not define the fstat syscall number for some architectures (e.g. RISCV32). In addition, also install the syscall for the explicit 64bit version if its syscall number is defined. The implementation does not depend on the word size. Signed-off-by: Daniel Schwyn <[email protected]>
b28b020 to
a86970c
Compare
|
I've fixed the Gitlint issue with the 2nd commit. |
libsel4muslcsys/src/sys_io.c
Outdated
| long sys_fstat(va_list ap) | ||
| { | ||
| int fd = va_arg(ap, int); | ||
| struct stat *statbuf = va_arg(ap, struct stat *); |
There was a problem hiding this comment.
I think this type may need to be struct kstat because muslc uses a separate user type than the abi type it uses for the kernel.
There was a problem hiding this comment.
Ah yes, I think you are right, thanks. This makes it a bit trickier though as the kstat.h header is not exported by musllibc. The cleanest solution I can think of is to add another interface library to the musllibc CMake build that has arch/${muslc_arch}/ and arch/generic as include directories. Probably copied to the muslc build directory to exclude the bits subdirectories that are already part of musllibc's public includes. What do you think?
There was a problem hiding this comment.
Or alternatively to keep the changes local use the MUSLLIBC_CURRENT_DIR variable set in Findmusllibc.cmake to add the include directories.
There was a problem hiding this comment.
I implemented the first option and opened the corresponding pull request in the muslc repo: seL4/musllibc#25
musllibc expects fstat to return the internal type struct kstat. Signed-off-by: Daniel Schwyn <[email protected]>
|
Is the library with the internal musllibc headers an acceptable solution? Let me know if there is something I should still do to get this merged. |
|
Where are we on this? Let me know if something needs doing to merge seL4/musllibc#25 and this. |
Indanz
left a comment
There was a problem hiding this comment.
A bit of a hack to get stdio working to be honest.
But I doubt that propagating this all the way to the UART driver or whoever takes care of stdio is any better/easier though.
|
Not sure what I'm doing wrong with the "Test-with: seL4/musllibc#25", I thought that would fix the build errors. |
The syntax is |
|
Hmm, this fails sometimes (or always on Aarch64?) with: |
Thanks. Is this documented anywhere btw? Now that other commit is merged, I removed the line again. |
Like all totally intuitive almost natural language commands of course this one didn't need any documentation, because we would never get it wrong :) By which I mean, I've been lazy and haven't found a good place to put it, so deferred it indefinitely. Where would you first look for docs for it? Would the README of the ci-actions repo be a good place? Or would a page on the docsite be better? Edit: the "spec", i.e. tests are here: https://github.com/seL4/ci-actions/blob/996e12ca25fde30ef6567c840cfd63697d202cb8/scripts/get-prs#L74 |
In the past I think I've gone to ci-actions. I don't tend to look at the docsite much, personally... Mostly because also I know that if I search the strings I'll find get-prs. |
I don't think this is caused by this, but I think was actually because of seL4/musllibc#25 as I saw it on another PR. |
Ah, I overlooked that |
Yes please, otherwise I'll revert that other commit. |
I've opened a pull request with the fix: seL4/musllibc#27 |
The implementation only sets the file mode.
It is also only implemented for STDIN, STDOUT and STDERR.
This is to support libraries that insist on calling fstat on file descriptors before doing I/O.