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 and the flags that govern the action to be taken. It can be one of the following values:
FDATASYNC
The changed data in the range specified by the offset and length parameters is written to the storage. If the metadata of the file is changed and this changed metadata must read the data, the metadata is also written to the storage. Otherwise, the metadata is not updated.
FFILESYNC
The changed data in the range specified by the offset and length parameters is written to the storage. If any metadata is changed, all of the changed user data is written to the storage. Metadata changes and file attributes including time stamps are also written to the storage.
FNOCACHE
The changed data is written to the storage similar to the FDATASYNC flag value. The full pages in the range specified by the offset and length parameters are removed from the memory cache. The pages are removed from the cache even if the pages are not changed. This operation is also applicable to the files that are open only for reading.
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. If you specify the value as zero, all cached data is 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.