Skip to content

Commit

Permalink
posix: fs: create a separate Kconfig option for fsync
Browse files Browse the repository at this point in the history
Create CONFIG_POSIX_FSYNC to match the spec.

Signed-off-by: Chris Friedt <[email protected]>
  • Loading branch information
cfriedt authored and nashif committed May 8, 2024
1 parent 99f81ce commit b1e2e4a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/zephyr/posix/unistd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions lib/os/fdtable.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
{
Expand Down
11 changes: 10 additions & 1 deletion lib/posix/options/Kconfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit b1e2e4a

Please sign in to comment.