Skip to content

Commit 7f7bba5

Browse files
committed
lib: posix: update option group of readdir_r()
`readdir_r()` belongs to the following option group POSIX_FILE_SYSTEM_R: Thread-Safe File System Create a new Kconfig `CONFIG_POSIX_FILE_SYSTEM_R` to compile it. Signed-off-by: Yong Cong Sin <ycsin@meta.com> Signed-off-by: Yong Cong Sin <yongcong.sin@gmail.com>
1 parent 34206f5 commit 7f7bba5

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

lib/posix/options/Kconfig.fs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,13 @@ config POSIX_FILE_SYSTEM_ALIAS_FSTAT
1717
help
1818
Select 'y' here and Zephyr will provide an alias for fstat() as _fstat().
1919

20+
config POSIX_FILE_SYSTEM_R
21+
bool "Thread-Safe File System"
22+
help
23+
Select 'y' here and Zephyr will provide an implementation of the POSIX_FILE_SYSTEM_R
24+
Option Group, consisting of readdir_r().
25+
26+
For more informnation, please see
27+
https://pubs.opengroup.org/onlinepubs/9699919799/xrat/V4_subprofiles.html
28+
2029
endif # POSIX_FILE_SYSTEM

lib/posix/options/Kconfig.pthread

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ config POSIX_THREAD_PRIO_PROTECT
156156

157157
config POSIX_THREAD_SAFE_FUNCTIONS
158158
bool "POSIX thread-safe functions"
159+
select POSIX_FILE_SYSTEM_R if POSIX_FILE_SYSTEM
159160
help
160161
Select 'y' here to enable POSIX thread-safe functions including asctime_r(), ctime_r(),
161162
flockfile(), ftrylockfile(), funlockfile(), getc_unlocked(), getchar_unlocked(),

lib/posix/options/fs.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ struct dirent *readdir(DIR *dirp)
314314
return &pdirent;
315315
}
316316

317-
#ifdef CONFIG_POSIX_THREAD_SAFE_FUNCTIONS
317+
#ifdef CONFIG_POSIX_FILE_SYSTEM_R
318318
int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
319319
{
320320
struct dirent *dir;
@@ -346,7 +346,7 @@ int readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result)
346346

347347
return 0;
348348
}
349-
#endif /* CONFIG_POSIX_THREAD_SAFE_FUNCTIONS */
349+
#endif /* CONFIG_POSIX_FILE_SYSTEM_R */
350350

351351
/**
352352
* @brief Rename a file.

0 commit comments

Comments
 (0)