sync - Online Linux Manual PageSection : 2
Updated : 2023-02-05
Source : Linux man-pages 6.03

NAMEsync, syncfs − commit filesystem caches to disk

LIBRARYStandard C library (libc, −lc)

SYNOPSIS#include <unistd.h>void sync(void);int syncfs(int fd);Feature Test Macro Requirements for glibc (see feature_test_macros(7)): sync(): _XOPEN_SOURCE >= 500 || /* Since glibc 2.19: */ _DEFAULT_SOURCE || /* glibc <= 2.19: */ _BSD_SOURCEsyncfs(): _GNU_SOURCE

DESCRIPTIONsync() causes all pending modifications to filesystem metadata and cached file data to be written to the underlying filesystems. syncfs() is like sync(), but synchronizes just the filesystem containing file referred to by the open file descriptor fd.

RETURN VALUEsyncfs() returns 0 on success; on error, it returns −1 and sets errno to indicate the error.

ERRORSsync() is always successful. syncfs() can fail for at least the following reasons: EBADF  fd is not a valid file descriptor. EIO  An error occurred during synchronization. This error may relate to data written to any file on the filesystem, or on metadata related to the filesystem itself. ENOSPC  Disk space was exhausted while synchronizing. ENOSPC, EDQUOT  Data was written to a file on NFS or another filesystem which does not allocate space at the time of a write(2) system call, and some previous write failed due to insufficient storage space.

VERSIONSsyncfs() first appeared in Linux 2.6.39; library support was added in glibc 2.14.

STANDARDSsync(): POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. syncfs() is Linux-specific.

NOTESSince glibc 2.2.2, the Linux prototype for sync() is as listed above, following the various standards. In glibc 2.2.1 and earlier, it was "int sync(void)", and sync() always returned 0. According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before the actual writing is done. However Linux waits for I/O completions, and thus sync() or syncfs() provide the same guarantees as fsync() called on every file in the system or filesystem respectively. In mainline kernel versions prior to Linux 5.8, syncfs() will fail only when passed a bad file descriptor (EBADF). Since Linux 5.8, syncfs() will also report an error if one or more inodes failed to be written back since the last syncfs() call.

BUGSBefore Linux 1.3.20, Linux did not wait for I/O to complete before returning.

SEE ALSOsync(1), fdatasync(2), fsync(2)
0
Johanes Gumabo
Data Size   :   11,677 byte
man-syncfs.2Build   :   2024-12-05, 20:55   :  
Visitor Screen   :   x
Visitor Counter ( page / site )   :   2 / 184,128
Visitor ID   :     :  
Visitor IP   :   18.227.52.111   :  
Visitor Provider   :   AMAZON-02   :  
Provider Position ( lat x lon )   :   39.962500 x -83.006100   :   x
Provider Accuracy Radius ( km )   :   1000   :  
Provider City   :   Columbus   :  
Provider Province   :   Ohio ,   :   ,
Provider Country   :   United States   :  
Provider Continent   :   North America   :  
Visitor Recorder   :   Version   :  
Visitor Recorder   :   Library   :  
Online Linux Manual Page   :   Version   :   Online Linux Manual Page - Fedora.40 - march=x86-64 - mtune=generic - 24.12.05
Online Linux Manual Page   :   Library   :   lib_c - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Online Linux Manual Page   :   Library   :   lib_m - 24.10.03 - march=x86-64 - mtune=generic - Fedora.40
Data Base   :   Version   :   Online Linux Manual Page Database - 24.04.13 - march=x86-64 - mtune=generic - fedora-38
Data Base   :   Library   :   lib_c - 23.02.07 - march=x86-64 - mtune=generic - fedora.36

Very long time ago, I have the best tutor, Wenzel Svojanovsky . If someone knows the email address of Wenzel Svojanovsky , please send an email to johanes_gumabo@yahoo.co.id .
If error, please print screen and send to johanes_gumabo@yahoo.co.id
Under development. Support me via PayPal.