From 65ad32b3ca9bf28bb9805a5fff8bb53b658b7a6d Mon Sep 17 00:00:00 2001 From: Karthikeyan Krishnasamy Date: Sat, 13 Apr 2024 13:12:12 +0530 Subject: [PATCH] lib: os: fdtable: add support for fsync Add support for fsync in existing posix ioctl call Signed-off-by: Karthikeyan Krishnasamy --- include/zephyr/posix/unistd.h | 1 + lib/os/fdtable.c | 1 + lib/posix/options/fs.c | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/include/zephyr/posix/unistd.h b/include/zephyr/posix/unistd.h index 0865a8e131c..d5782200275 100644 --- a/include/zephyr/posix/unistd.h +++ b/include/zephyr/posix/unistd.h @@ -237,6 +237,7 @@ int close(int file); ssize_t write(int file, const void *buffer, size_t count); ssize_t read(int file, void *buffer, size_t count); off_t lseek(int file, off_t offset, int whence); +int fsync(int fd); /* File System related operations */ int rename(const char *old, const char *newp); diff --git a/lib/os/fdtable.c b/lib/os/fdtable.c index 757ebf4361f..1fd42ad1208 100644 --- a/lib/os/fdtable.c +++ b/lib/os/fdtable.c @@ -362,6 +362,7 @@ int fsync(int fd) return z_fdtable_call_ioctl(fdtable[fd].vtable, fdtable[fd].obj, ZFD_IOCTL_FSYNC); } +FUNC_ALIAS(fsync, _fsync, int); off_t lseek(int fd, off_t offset, int whence) { diff --git a/lib/posix/options/fs.c b/lib/posix/options/fs.c index ca861a729b1..d7203d150e9 100644 --- a/lib/posix/options/fs.c +++ b/lib/posix/options/fs.c @@ -144,6 +144,10 @@ static int fs_ioctl_vmeth(void *obj, unsigned int request, va_list args) struct posix_fs_desc *ptr = obj; switch (request) { + case ZFD_IOCTL_FSYNC: { + rc = fs_sync(&ptr->file); + break; + } case ZFD_IOCTL_LSEEK: { off_t offset; int whence;