posix: fs: create a separate Kconfig option for fsync

Create CONFIG_POSIX_FSYNC to match the spec.

Signed-off-by: Chris Friedt <cfriedt@tenstorrent.com>
This commit is contained in:
Chris Friedt 2024-05-02 19:26:41 -04:00 committed by Anas Nashif
parent 99f81ce5c6
commit b1e2e4ac2c
3 changed files with 13 additions and 2 deletions

View file

@ -42,7 +42,7 @@ extern "C" {
#define _POSIX_CHOWN_RESTRICTED (-1L)
#define _POSIX_CLOCK_SELECTION Z_SC_VAL_IFDEF(CONFIG_POSIX_CLOCK, _POSIX_VERSION)
#define _POSIX_CPUTIME (-1L)
#define _POSIX_FSYNC (-1L)
#define _POSIX_FSYNC Z_SC_VAL_IFDEF(CONFIG_POSIX_FSYNC, _POSIX_VERSION)
#define _POSIX_IPV6 Z_SC_VAL_IFDEF(CONFIG_NET_IPV6, _POSIX_VERSION)
#define _POSIX_JOB_CONTROL (-1L)
#define _POSIX_MAPPED_FILES _POSIX_VERSION

View file

@ -354,6 +354,7 @@ int close(int fd)
}
FUNC_ALIAS(close, _close, int);
#ifdef CONFIG_POSIX_FSYNC
int fsync(int fd)
{
if (_check_fd(fd) < 0) {
@ -363,6 +364,7 @@ int fsync(int fd)
return z_fdtable_call_ioctl(fdtable[fd].vtable, fdtable[fd].obj, ZFD_IOCTL_FSYNC);
}
FUNC_ALIAS(fsync, _fsync, int);
#endif /* CONFIG_POSIX_FSYNC */
off_t lseek(int fd, off_t offset, int whence)
{

View file

@ -10,10 +10,19 @@ menuconfig POSIX_FS
help
This enables POSIX style file system related APIs.
if POSIX_FS
config POSIX_MAX_OPEN_FILES
int "Maximum number of open file descriptors"
default 16
depends on POSIX_FS
help
Maximum number of open files. Note that this setting
is additionally bounded by CONFIG_POSIX_MAX_FDS.
config POSIX_FSYNC
bool "Support for fsync()"
default y
help
This enables fsync() support.
endif # POSIX_FS