204 lines
6.2 KiB
Groff
204 lines
6.2 KiB
Groff
.\" $NetBSD: vnfileops.9,v 1.8 2003/04/20 04:42:15 gmcgarry Exp $
|
|
.\"
|
|
.\" Copyright (c) 2001 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
.\" by Gregory McGarry.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\" 3. All advertising materials mentioning features or use of this software
|
|
.\" must display the following acknowledgement:
|
|
.\" This product includes software developed by the NetBSD
|
|
.\" Foundation, Inc. and its contributors.
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
.\" contributors may be used to endorse or promote products derived
|
|
.\" from this software without specific prior written permission.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd October 14, 2002
|
|
.Dt VNFILEOPS 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm vnfileops ,
|
|
.Nm vn_closefile ,
|
|
.Nm vn_fcntl ,
|
|
.Nm vn_ioctl ,
|
|
.Nm vn_read ,
|
|
.Nm vn_poll ,
|
|
.Nm vn_statfile ,
|
|
.Nm vn_write ,
|
|
.Nd vnode file descriptor operations
|
|
.Sh SYNOPSIS
|
|
.In sys/param.h
|
|
.In sys/file.h
|
|
.In sys/vnode.h
|
|
.Ft int
|
|
.Fn vn_closefile "struct file *fp" "struct proc *p"
|
|
.Ft int
|
|
.Fn vn_fcntl "struct file *fp" "u_int com" "void *data" "struct proc *p"
|
|
.Ft int
|
|
.Fn vn_ioctl "struct file *fp" "u_long com" "void *data" "struct proc *p"
|
|
.Ft int
|
|
.Fn vn_read "struct file *fp" "off_t *offset" "struct uio *uio" "struct ucred *cred" "int flags"
|
|
.Ft int
|
|
.Fn vn_poll "struct file *fp" "int events" "struct proc *p"
|
|
.Ft int
|
|
.Fn vn_statfile "struct file *fp" "struct stat *sb" "struct proc *p"
|
|
.Ft int
|
|
.Fn vn_write "struct file *fp" "off_t *offset" "struct uio *uio" "struct ucred *cred" "int flags"
|
|
.Sh DESCRIPTION
|
|
The functions described in this page are the vnode-specific file
|
|
descriptor operations.
|
|
They should only be accessed through the opaque function pointers
|
|
in the file entries (see
|
|
.Xr file 9 ) .
|
|
They are described here only for completeness.
|
|
.Sh FUNCTIONS
|
|
.Bl -tag -width compact
|
|
.It Fn vn_closefile "fp" "p"
|
|
Common code for a file table vnode close operation.
|
|
The file is described by
|
|
.Fa fp
|
|
and
|
|
.Fa p
|
|
is the calling process.
|
|
.Fn vn_closefile
|
|
simply calls
|
|
.Xr vn_close 9
|
|
with the appropriate arguments.
|
|
.It Fn vn_fcntl "fp" "com" "data" "p"
|
|
Common code for a file table vnode
|
|
.Xr fcntl 2
|
|
operation.
|
|
The file is specified by
|
|
.Fa fp .
|
|
The argument
|
|
.Fa p
|
|
is the calling process.
|
|
.Fn vn_fcntl
|
|
simply locks the vnode and invokes the vnode operation
|
|
.Xr VOP_FCNTL 9
|
|
with the command
|
|
.Fa com
|
|
and buffer
|
|
.Fa data .
|
|
The vnode is unlocked on return.
|
|
If the operation is successful zero is returned, otherwise an
|
|
appropriate error is returned.
|
|
.It Fn vn_ioctl "fp" "com" "data" "p"
|
|
Common code for a file table vnode ioctl operation.
|
|
The file is specified by
|
|
.Fa fp .
|
|
The argument
|
|
.Fa p
|
|
is the calling process.
|
|
.Fn vn_ioctl
|
|
simply locks the vnode and invokes the vnode operation
|
|
.Xr VOP_IOCTL 9
|
|
with the command
|
|
.Fa com
|
|
and buffer
|
|
.Fa data .
|
|
The vnode is unlocked on return.
|
|
If the operation is successful zero is returned, otherwise an
|
|
appropriate error is returned.
|
|
.It Fn vn_read "fp" "offset" "uio" "cred" "flags"
|
|
Common code for a file table vnode read.
|
|
The argument
|
|
.Fa fp
|
|
is the file structure, The argument
|
|
.Fa offset
|
|
is the offset into the file.
|
|
The argument
|
|
.Fa uio
|
|
is the uio structure describing the memory to read into.
|
|
The caller's credentials are specified in
|
|
.Fa cred .
|
|
The
|
|
.Fa flags
|
|
argument can define FOF_UPDATE_OFFSET to update the read position in
|
|
the file.
|
|
If the operation is successful zero is returned, otherwise an
|
|
appropriate error is returned.
|
|
.It Fn vn_poll "fp" "events" "p"
|
|
Common code for a file table vnode poll operation.
|
|
.Fn vn_poll
|
|
simply calls
|
|
.Xr VOP_POLL 9
|
|
with the events
|
|
.Fa events
|
|
and the calling process
|
|
.Fa p .
|
|
If the operation is success zero is returned, otherwise an appropriate
|
|
error code is returned.
|
|
.It Fn vn_statfile "fp" "sb" "p"
|
|
Common code for a stat operation.
|
|
The file descriptor is specified by the argument
|
|
.Fa fp
|
|
and
|
|
.Fa sb
|
|
is the buffer to return the stat information.
|
|
The argument
|
|
.Fa p
|
|
is the calling process.
|
|
.Fn vn_statfile
|
|
basically calls the vnode operation
|
|
.Xr VOP_GETATTR 9
|
|
and transfer the contents of a vattr structure into a struct stat.
|
|
If the operation is successful zero is returned, otherwise an
|
|
appropriate error code is returned.
|
|
.It Fn vn_write "fp" "offset" "uio" "cred" "flags"
|
|
Common code for a file table vnode write.
|
|
The argument
|
|
.Fa fp
|
|
is the file structure, The argument
|
|
.Fa offset
|
|
is the offset into the file.
|
|
The argument
|
|
.Fa uio
|
|
is the uio structure describing the memory to read from.
|
|
The caller's credentials are specified in
|
|
.Fa cred .
|
|
The
|
|
.Fa flags
|
|
argument can define FOF_UPDATE_OFFSET to update the read position in
|
|
the file.
|
|
If the operation is successful zero is returned, otherwise an
|
|
appropriate error is returned.
|
|
.El
|
|
.Sh CODE REFERENCES
|
|
This section describes places within the
|
|
.Nx
|
|
source tree where actual code implementing or using the vnode
|
|
framework can be found.
|
|
All pathnames are relative to
|
|
.Pa /usr/src .
|
|
.Pp
|
|
The high-level convenience functions are implemented within the file
|
|
.Pa sys/kern/vfs_vnops.c .
|
|
.Sh SEE ALSO
|
|
.Xr file 9 ,
|
|
.Xr intro 9 ,
|
|
.Xr vnode 9 ,
|
|
.Xr vnodeops 9 ,
|
|
.Xr vnsubr 9
|