FreeBSD/sys/cddl/contrib/opensolaris/uts/common/fs/gfs.c
/*
 * gfs_file_create(): create a new GFS file
 *
 *   size	- size of private data structure (v_data)
 *   pvp	- parent vnode (GFS directory)
 *   ops	- vnode operations vector
 *
 * In order to use this interface, the parent vnode must have been created by
 * gfs_dir_create(), and the private data stored in v_data must have a
 * 'gfs_file_t' as its first field.
 *
 * Given these constraints, this routine will automatically:
 *
 * 	- Allocate v_data for the vnode
 * 	- Initialize necessary fields in the vnode
 * 	- Hold the parent
 */
create a new GFS file
size       - size of private data structure (v_data)
pvp        - parent vnode (GFS directory)
ops        - vnode operations vector

In order to use this interface, the parent vnode must have been created by
gfs_dir_create(), and the private data stored in v_data must have a
'gfs_file_t' as its first field.

Given these constraints, this routine will automatically.

- Allocate v_data for the vnode
- Initialize necessary fields in the vnode
- Hold the parent
create a new GFS file size - size of private data structure ( v_data ) pvp - parent vnode ( GFS directory ) ops - vnode operations vector In order to use this interface the parent vnode must have been created by gfs_dir_create () and the private data stored in v_data must have a ' gfs_file_t ' as its first field . Given these constraints this routine will automatically . - Allocate v_data for the vnode - Initialize necessary fields in the vnode - Hold the parent
vnode_t *
gfs_file_create(size_t size, vnode_t *pvp, vfs_t *vfsp, vnodeops_t *ops)
{
	gfs_file_t *fp;
	vnode_t *vp;
	int error;
	fp = kmem_zalloc(size, KM_SLEEP);
	error = getnewvnode("zfs_gfs", vfsp, ops, &vp);
	ASSERT(error == 0);
	vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
	vp->v_data = (caddr_t)fp;
	fp->gfs_vnode = vp;
	fp->gfs_parent = pvp;
	fp->gfs_size = size;
	fp->gfs_type = GFS_FILE;
	vp->v_vflag |= VV_FORCEINSMQ;
	error = insmntque(vp, vfsp);
	vp->v_vflag &= ~VV_FORCEINSMQ;
	KASSERT(error == 0, ("insmntque() failed: error %d", error));
	if (pvp)
		VN_HOLD(pvp);
	return (vp);
}
vnode_t * gfs_file_create ( size_t size , vnode_t * pvp , vfs_t * vfsp , vnodeops_t * ops ) { gfs_file_t * fp ; vnode_t * vp ; int error ; fp = kmem_zalloc ( size , KM_SLEEP ) ; error = getnewvnode ( " " , vfsp , ops , & vp ) ; ASSERT ( error == 0 ) ; vn_lock ( vp , LK_EXCLUSIVE | LK_RETRY ) ; vp -> v_data = ( caddr_t ) fp ; fp -> gfs_vnode = vp ; fp -> gfs_parent = pvp ; fp -> gfs_size = size ; fp -> gfs_type = GFS_FILE ; vp -> v_vflag |= VV_FORCEINSMQ ; error = insmntque ( vp , vfsp ) ; vp -> v_vflag &= ~ VV_FORCEINSMQ ; KASSERT ( error == 0 , ( " " , error ) ) ; if ( pvp ) VN_HOLD ( pvp ) ; return ( vp ) ; }
gfs_file_create(): create a new GFS file
   size       - size of private data structure (v_data)
   pvp        - parent vnode (GFS directory)
   ops        - vnode operations vector
gfs_file_create () : create a new GFS file size - size of private data structure ( v_data ) pvp - parent vnode ( GFS directory ) ops - vnode operations vector
/*
	 * Allocate vnode and internal data structure
	 */ /*
	 * Set up various pointers
	 */ /*
	 * Initialize vnode and hold parent.
	 */