SYNCFS(3C) | Standard C Library Functions | SYNCFS(3C) |
syncfs
—
synchronize file system to disk
Standard C Library (libc, -lc)
#include
<unistd.h>
int
syncfs
(int fd);
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.
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.
The syncfs
() functions will fail if:
EBADF
EDQUOT,
ENOSPC
EIO
ENOSYS
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.
July 13, 2024 | OmniOS |