Open System Services System Calls Reference Manual (G06.25+, H06.03+)

System Functions (f - i) fsync(2)
NAME
fsync - Writes modied data and le attributes to permanent storage
LIBRARY
G-series native OSS processes: system library
H-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
int fsync(
int ledes);
PARAMETERS
filedes Species an open le descriptor obtained from a successful call to the accept(),
creat(), dup( ), dup2( ), fcntl( ), open(), pipe( ), socket(),orsocketpair() func-
tion.
DESCRIPTION
The fsync() function saves all modications for the le open specied by the ledes parameter.
On return from the fsync() function, all updated data and le attributes have been saved on per-
manent storage.
Use on Guardian Objects
The ledes parameter can specify any regular le in /G including Guardian EDIT les. Time
values are not saved for other le types in /G, such as terminal les.
NOTES
The fsync() function offers an alternative to the O_SYNC le status ag and the S_NONSTOP
le attribute. Using fsync() calls gives an application control over the performance tradeoffs
involved in guaranteeing data integrity. OSS le-system caching can be used for les that are
protected only by fsync() function calls.
RETURN VALUES
Upon successful completion, the fsync() function returns the value 0 (zero). Otherwise, it returns
the value -1, and errno is set to indicate the error.
ERRORS
If any of these conditions occurs, the fsync() function sets errno to the value that corresponds to
the condition:
[EBADF] The ledes parameter is not a valid le descriptor.
[EINTR] The fsync() function was interrupted by a signal that was caught.
[EINVAL] The ledes parameter, although valid, does not refer to a le on which this opera-
tion is possible.
[EIO] An I/O error occurred during a write to the leset.
[EISGUARDIAN]
The value used for the ledes parameter is appropriate only in the Guardian
environment.
[ENETDOWN]
The ledes parameter species a le on a remote HP NonStop node, but com-
munication with the remote node has been lost.
527186-003 Hewlett-Packard Company 331