vnop_fsync, vnop_fsync_range Entry Points

Purpose

Flushes file data from memory to disk.

Syntax

int vnop_fsync ( vp, flags, vinfo, crp)
struct vnode *vp;
long flags;
long vinfo;
struct ucred *crp;

int vnop_fsync_range ( vp, flags, vinfo, offset, length, crp)
struct vnode *vp;
long flags;
long vinfo;
offset_t offset;
offset_t length;
struct ucred *crp;

Parameters

Item Description
vp Points to the virtual node (v-node) of the file.
flags Identifies flags from the open file plus flags that govern the action to be taken. It can be one of the following values:
FDATASYNC
Writes file data and metadata to retrieve the data for the specified range.
FFILESYNC
Writes all modified file data and metadata for the specified range.
FNOCACHE
Writes the data in the range and releases full memory pages in the byte range. The data will no longer be in the cache.
vinfo This parameter is currently not used.
offset Specifies the starting offset in the file of the data to be flushed.
length Specifies the length of the data to be flushed.
crp Points to the cred structure. This structure contains data that the file system can use to validate access permission.

Description

The vnop_fsync entry point is called by the logical file system to request that all modifications associated with a given v-node to be flushed out to permanent storage. This must be done synchronously so that the caller can assure that all I/O has completed successfully. The vnop_fsync_range entry point provides the same function but limits the data to be written to a specified range in the file.

Execution Environment

The vnop_fsync and vnop_fsync_range entry points can be called from the process environment only.

Return Values

Item Description
0 Indicates success.

Nonzero values are returned from the /usr/include/sys/errno.h file to indicate failure.