SYNCFS(3C) Standard C Library Functions SYNCFS(3C)

NAME


syncfs - synchronize file system to disk

LIBRARY


Standard C Library (libc, -lc)

SYNOPSIS


#include <unistd.h>

int
syncfs(int fd);

DESCRIPTION


The syncfs() function instructs the file system associated with the
file descriptor, fd, to ensure that all pending data and metadata
updates that are still in-memory are synchronized back to the file
system's underlying storage devices. This function will block until
all such writes are completed.

Not all file systems support this request. This may happen either
because the file system has not been enhanced yet to support this
request or because the file system does not support the idea of
synchronizing data to a backing store such as the underlying socket
file system or the read-only bootfs(4FS) file system.

If an application only cares about the state of a single file and its
metadata, then it should use the fsync(3C) function instead. The
traditional sync(2) function has two primary differences from the
syncfs(function:) sync(2) instructs the system to schedule all I/O
across all file systems to be synchronized and it does not guarantee
that all that I/O is completed prior to returning. There is no non-
blocking way to force I/O to be synchronized to a specific file system.

RETURN VALUES


Upon successful completion, the syncfs() function returns 0 and ensures
that the file system data and metadata synchronization has already
completed. Otherwise -1 is returned and errno is set to indicate the
error and outstanding file system data and metadata is not guaranteed
to have been synchronized.

ERRORS


The syncfs() functions will fail if:

EBADF The fd argument is not a valid open file descriptor
in the calling process.

EDQUOT, ENOSPC There was no free space remaining on the file
system's backing store or a quota was hit.

EIO An I/O error occurred while reading or writing.

ENOSYS The file system backing the file descriptor, fd,
does not support file system-wide synchronization.

It is possible that a remote file system (e.g. NFS) may fail with
additional errors that are unique to the network based nature of the
file system.

INTERFACE STABILITY


Committed

MT-LEVEL
Safe

SEE ALSO


sync(2), fsync(3C)

illumos July 13, 2024 illumos

tribblix@gmail.com :: GitHub :: Privacy