Open System Services System Calls Reference Manual (G06.25+, H06.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 OSS processes: implicit libraries
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.
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.
NOTES
The fsync() function offers an alternative to the O_SYNC file status flag and the S_NONSTOP
file attribute. Using fsync() calls gives an application control over the performance tradeoffs
involved in guaranteeing data integrity. OSS file-system caching can be used for files 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 filedes parameter is not a valid file descriptor.
[EINTR] The fsync() function was interrupted by a signal that was caught.
[EINVAL] The filedes parameter, although valid, does not refer to a file on which this opera-
tion is possible.
[EIO] An I/O error occurred during a write to the fileset.
[EISGUARDIAN]
The value used for the filedes parameter is appropriate only in the Guardian
environment.
[ENETDOWN]
The filedes parameter specifies a file on a remote HP NonStop node, but com-
munication with the remote node has been lost.
527186-003 Hewlett-Packard Company 3−31