I have no idea what is going on with syncfs.  There have been some recent changes:

   Documentation/ReleaseNotes/NuttX-12.1.0:*
   [#8092](https://github.com/apache/nuttx/pull/8092) fs: Map syncfs to
   fsync
   Documentation/ReleaseNotes/NuttX-12.3.0:*
   [#10764](https://github.com/apache/nuttx/pull/10764) add syncfs api
   for sync whole fs data

syncfs was very recently added:

   commit 2bce0f404c37826bf2eae59cfe42fe1c80bd0c22
   Author: guohao15 <guoha...@xiaomi.com>
   Date:   Fri Sep 15 16:22:13 2023 +0800

        fs:add syncfs api for sync whole fs data

        Signed-off-by: guohao15 <guoha...@xiaomi.com>

I suspect that syncfs is needed for some 3rd party file system, perhaps littlefs?  Or maybe it was just needed to port some application.

syncsfs() and fsync() would apparently be interchangeable on other filesystems based on these comments and changes.

   --- a/include/unistd.h
   +++ b/include/unistd.h
   @@ -258,7 +258,6 @@

     /* Helpers and legacy compatibility definitions */

   -#define syncfs(f)                        fsync(f)
     #define fdatasync(f)                     fsync(f)
     #define getdtablesize(f) ((int)sysconf(_SC_OPEN_MAX))
     #define getpagesize(f) ((int)sysconf(_SC_PAGESIZE))
   @@ -441,6 +440,7 @@ int     setregid(gid_t rgid, gid_t egid);
     int     getentropy(FAR void *buffer, size_t length);

     void    sync(void);
   +int     syncfs(int fd);

     #if CONFIG_FORTIFY_SOURCE > 0
     fortify_function(getcwd) FAR char *getcwd(FAR char *buf,

However, I think it it is mistake to put the hooks in for syncfs and not implement syncfs for other file systems that need it.   From what you say, syncfs() would be a no-op for those other file systems which is (usually) wrong. Perhaps they could just call fsync() from sync()?  Doing nothing would be an error.

If that is true, then you might want to open an issue.  Or perhaps just add to https://github.com/apache/nuttx/issues/3399

On 2/15/2024 3:16 AM, Saurav Pal wrote:
Hi Greg,

Thanks for the info! Can you tell me the reason why none of the existing
file systems in NuttX implement it?

Regards,
SP

On Wed, Feb 14, 2024 at 9:27 PM Gregory Nutt<spudan...@gmail.com>  wrote:

It implementes the syncfs file system interface:
https://linux.die.net/man/2/syncfs

On 2/14/2024 8:16 AM, Saurav Pal wrote:
Hi all,

I was going through the codebase of different file systems, and I haven't
yet understood the syncfs() method of mountpt operations.

There aren't any existing filesystems in the codebase that implement it,
and I couldn't understand what exactly is required from this method (like
what it does, what side effects it's supposed to have and what is the
intended reason for this method to exist).

Can you please help me understand it? Thanks in advance.

Regards,
SP


Reply via email to