Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-UX Reference > F

fsync(2)

HP-UX 11i Version 3: February 2007
» 

Technical documentation

» Feedback
Content starts here

 » Table of Contents

 » Index

NAME

fsync, fdatasync — synchronize a file's in-core and on-disk states

SYNOPSIS

#include <unistd.h>

int fsync(int fildes);

int fdatasync(int fildes);

DESCRIPTION

fsync() and fdatasync() cause all modified data and attributes of fildes to be moved to a permanent storage device. This normally results in all in-core modified copies of buffers for the associated file to be written to a disk. fsync() and fdatasync() apply to ordinary files, and apply to block special devices on systems which permit I/O to block special devices.

fsync() and fdatasync() should be used by programs that require a file to be in a known state, such as when building a simple transaction facility.

fdatasync() causes all modified data and file attributes of fildes required to retrieve the data to be written to disk.

fsync() causes all modified data and all file attributes of fildes (including access time, modification time and status change time) to be written to disk.

Together, fsync() and fdatasync() constitute support for File Synchronization.

RETURN VALUE

fsync() and fdatasync() return 0 on success or -1 if an error occurs, and set errno to indicate the error.

ERRORS

fsync and fdatasync fail if any of the following conditions are encountered:

[EBADF]

fildes is not a valid descriptor.

[EINVAL]

fildes refers to a file type to which fsync() or fdatasync() does not apply.

WARNINGS

The current implementation of these functions is inefficient for large files.

AUTHOR

fsync() was developed by the University of California, Berkeley and HP.

STANDARDS CONFORMANCE

fsync(): AES, SVID3, XPG3, XPG4, POSIX.4

fdatasync(): POSIX.4

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1983-2007 Hewlett-Packard Development Company, L.P.