-
Notifications
You must be signed in to change notification settings - Fork 7.6k
posix: implement FILE_LOCKING, SYSTEM_DATABASE, SYSTEM_DATABASE_R #83368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
posix: implement FILE_LOCKING, SYSTEM_DATABASE, SYSTEM_DATABASE_R #83368
Conversation
b69c332
to
0126d05
Compare
checkpatch false positives 🙄 int dirfd(DIR *dirp);
DIR *fdopendir(int fd); SPACING: need consistent spacing around '*' (ctx:WxV)
File:include/zephyr/posix/dirent.h
Line:22
SPACING: need consistent spacing around '*' (ctx:WxV)
File:include/zephyr/posix/dirent.h
Line:24 |
cca3776
to
fdbfb54
Compare
4e17db6
to
fb1cb22
Compare
fb1cb22
to
6b79e37
Compare
6b79e37
to
e3a983e
Compare
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
Newlib currently relies on calling stat() indirectly via _fstat_r() when performing certain stdio file operations (e.g. reading a file). However, that results in errno being set to 95 (EOPNOTSUPP) in unexpected places, which causes non-determinism and unpredictability, and it is inconsistent with both picolibc and the minimal libc. Normally, it would be a great opportunity to implement zvfs_stat() via fs_stat(). However, the current implementation of fs_stat() is not particularly useful to call from zvfs_stat() since fs_state() relies on an absolute path passed as the first parameter and it is currently _difficult_ to get that from an integer file descriptor. In the ideal world, it would be possible to extrapolate the absolute path of a filename from a fs_file_t oobject or some other filesystem subsystem API. Since it is not practical to modify Newlib to change the way it performs standard C I/O, simply add a no-op operations for the fs subsystem vtable. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Previously, there was an implicit assumption that Zephyr's internal struct fd_entry * was synonymous with FILE * from the C library. This is generally not the case and aliasing these two distinct types was preventing a fair bit of functionality from Just Working - namely stdio function calls like fgets() and fopen(). The problem can be seen directly when trying to use a function like zvfs_fdopen(). Instead of aliasing the two types, require that all Zephyr C libraries provide a z_libc_file_alloc() function that allocates and populates the required fields of a FILE object. Zephyr currently only provides the integer file descriptor to the C library for initializing FILE objects. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Provide an implementation for the POSIX_SYSTEM_DATABASE_R Option Group. This group is required for all conforming implementations and is therefore required for PSE51, PSE52, PSE53, PSE54, and all other possible subprofiles. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a teststuite to exercise the POSIX_SYSTEM_DATABASE_R Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark the POSIX_SYSTEM_DATABASE_R Option Group as supported. This Option Group is required for all conformant implementations as part of the _POSIX_THREAD_SAFE_FUNCTIONS Option. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Provide an implementation for the POSIX_SYSTEM_DATABASE Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a testsuite for the POSIX_SYSTEM_DATABASE Option Group Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark the POSIX_SYSTEM_DATABASE Option Group as supported. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Provide an implementation of the POSIX_FILE_LOCKING Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Add a testsuite for the POSIX_FILE_LOCKING Option Group. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark POSIX_FILE_LOCKING as supported. This Option Group is part of the _POSIX_THREAD_SAFE_FUNCTIONS Option and is mandatory for all conforming implementations. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
The functions associated with the _POSIX_THREAD_SAFE_FUNCTIONS Option are members of other POSIX Option Groups. Specifically, POSIX_C_LANG_SUPPORT_R, POSIX_FILE_LOCKING, POSIX_FILE_SYSTEM_R, and POSIX_SYSTEM_DATABASE_R. Moreover, _POSIX_THREAD_SAFE_FUNCTIONS is required to be available with any conforming implementation. Therefore, it does not make sense to have a Kconfig option to turn it off or on; it should be enabled or disabled based on whether the required POSIX Option Groups are active. Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
Mark the _POSIX_THREAD_SAFE_FUNCTIONS Option as supported. This Option is required mandatory for any conformant implementation and is comprised of functions belonging to the following Option Groups: - POSIX_C_LANG_SUPPORT_R - POSIX_FILE_LOCKING - POSIX_FILE_SYSTEM_R - POSIX_SYSTEM_DATABASE_R Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
e3a983e
to
694c739
Compare
|
|
This will get split into multiple PRs.
Note
This has been split out to separate PRs (#84858, #84859, #84860) which are all currently blocked on #83386. Additionally, several PRs by others are also blocked on #83386.
Doc Preview
Addresses #81489, #74467, #74466, #74465, #74464, #74463, #74462, #74461, #74100, #74099, #74098, #74097.