Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (f - i) fsync(2)
NAME
fsync - Writes modified data and file attributes to permanent storage
LIBRARY
G-series native OSS processes: system library
H-series and J-series OSS processes: implicit libraries
32-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/zputdll
64-bit H-series and J-series OSS processes that use the POSIX User Thread Model library:
/G/system/zdllnnn/yputdll
SYNOPSIS
#include <unistd.h>
int fsync(
int filedes);
PARAMETERS
filedes Specifies an open file descriptor obtained from a successful call to the accept(),
creat(), dup( ), dup2( ), fcntl(), open(), pipe(), socket(),orsocketpair() func-
tion.
When the function is thread-aware, specifies an open file descriptor obtained
from a successful call to the creat(), creat64(), dup(), open(), open64(),
pipe( ), socket(),orsocketpair() function, or the thread-aware accept(),
dup2( ),orfcntl( ) function.
DESCRIPTION
The fsync() function saves all modifications for the file open specified by the filedes parameter.
On return from the fsync( ) function, all updated data and file attributes have been saved on per-
manent storage.
Use on Guardian Objects
The filedes parameter can specify any regular file in /G including Guardian EDIT files. Time
values are not saved for other file types in /G, such as terminal files.
Use From a Threaded Application
If this function must wait for an I/O operation to complete on an open file, this function blocks
the thread (instead of the entire process) that called it, while it waits for the I/O operation to com-
plete.
NOTES
The fsync() function offers an alternative to the O_SYNC file status flag. Using fsync() calls
gives an application control over the performance trade offs involved in guaranteeing data
integrity. OSS file-system caching can be used for files that are protected only by fsync( ) func-
tion calls.
To use the fsync( ) functionality in a threaded application that uses the Standard POSIX Threads
library, see spt_fsyncz(2).
To use this function in a threaded application that uses the POSIX User Thread Model library on
systems running H06.21 or later RVUs or J06.10 or later RVUs, you must perform all of the fol-
lowing tasks to make the function thread-aware in a multi-threaded application:
• Compile the application using the _PUT_MODEL_ feature test macro or equivalent
compiler command option.
• Link the application to the zputdll library (/G/system/zdllnnn/zputdll).
527186-023 Hewlett-Packard Company 3−61