vn_get Kernel Service

Purpose

Allocates a virtual node.

Syntax

#include <sys/types.h>
#include <sys/errno.h>

int vn_get ( vfsp,  gnp,  vpp)
struct vfs *vfsp;
struct gnode *gnp;
struct vnode **vpp;

Parameters

Item Description
vfsp Points to a vfs structure describing the virtual file system that is to contain the v-node. Any returned v-node belongs to this virtual file system.
gnp Points to the g-node for the object. This pointer is stored in the returned v-node. The new v-node is added to the list of v-nodes in the g-node.
vpp Points to the place in which to return the v-node pointer. This is set by the vn_get kernel service to point to the newly allocated v-node.

Description

The vn_get kernel service provides a mechanism for allocating v-node objects for use within the virtual file system environment. A v-node is first allocated from an effectively infinite pool of available v-nodes.

Upon successful return from the vn_get kernel service, the pointer to the v-node pointer provided (specified by the vpp parameter) has been set to the address of the newly allocated v-node.

The fields in this v-node have been initialized as follows:

Field Initial Value
v_count Set to 1.
v_vfsp Set to the value in the vfsp parameter.
v_gnode Set to the value in the gnp parameter.
v_next Set to list of others v-nodes with the same g-node.

All other fields in the v-node are zeroed.

Execution Environment

The vn_get kernel service can be called from the process environment only.

Return Values

Item Description
0 Indicates successful completion.
ENOMEM Indicates that the vn_get kernel service could not allocate memory for the v-node. (This is a highly unlikely occurrence.)