2002-10-14 17:43:14 +04:00
|
|
|
.\" $NetBSD: vnfileops.9,v 1.2 2002/10/14 13:43:36 wiz Exp $
|
2002-10-14 08:56:48 +04:00
|
|
|
.\"
|
|
|
|
.\" 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
|
|
|
|
.Fd #include \*[Lt]sys/param.h\*[Gt]
|
|
|
|
.Fd #include \*[Lt]sys/file.h\*[Gt]
|
|
|
|
.Fd #include \*[Lt]sys/vnode.h\*[Gt]
|
|
|
|
.Ft int
|
|
|
|
.Fn vn_closefile "struct file *fp" "struct proc *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn vn_fcntl "struct file *fp" "u_int com" "caddr_t data" "struct proc *p"
|
|
|
|
.Ft int
|
|
|
|
.Fn vn_ioctl "struct file *fp" "u_long com" "caddr_t 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
|
2002-10-14 17:43:14 +04:00
|
|
|
descriptor operations.
|
|
|
|
They should only be accessed through the opaque function pointers
|
|
|
|
in the file descriptor entries.
|
|
|
|
They are described here only for completeness.
|
2002-10-14 08:56:48 +04:00
|
|
|
.Sh FUNCTIONS
|
|
|
|
.Bl -tag -width compact
|
|
|
|
.It Fn vn_closefile "fp" "p"
|
2002-10-14 17:43:14 +04:00
|
|
|
Common code for a file table vnode close operation.
|
|
|
|
The file is described by
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa fp
|
|
|
|
and
|
|
|
|
.Fa p
|
|
|
|
is the calling process.
|
|
|
|
.Fn vn_closefile
|
|
|
|
simply calls
|
|
|
|
.Fn vn_close
|
|
|
|
with the appropriate arguments.
|
|
|
|
.It Fn vn_fcntl "fp" "com" "data" "p"
|
|
|
|
Common code for a file table vnode
|
|
|
|
.Xr fcntl 2
|
2002-10-14 17:43:14 +04:00
|
|
|
operation.
|
|
|
|
The file is specified by
|
2002-10-14 08:56:48 +04:00
|
|
|
.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 .
|
2002-10-14 17:43:14 +04:00
|
|
|
The vnode is unlocked on return.
|
|
|
|
If the operation is successful zero is returned, otherwise an
|
|
|
|
appropriate error is returned.
|
2002-10-14 08:56:48 +04:00
|
|
|
.It Fn vn_ioctl "fp" "com" "data" "p"
|
2002-10-14 17:43:14 +04:00
|
|
|
Common code for a file table vnode ioctl operation.
|
|
|
|
The file is specified by
|
2002-10-14 08:56:48 +04:00
|
|
|
.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 .
|
2002-10-14 17:43:14 +04:00
|
|
|
The vnode is unlocked on return.
|
|
|
|
If the operation is successful zero is returned, otherwise an
|
|
|
|
appropriate error is returned.
|
2002-10-14 08:56:48 +04:00
|
|
|
.It Fn vn_read "fp" "offset" "uio" "cred" "flags"
|
2002-10-14 17:43:14 +04:00
|
|
|
Common code for a file table vnode read.
|
|
|
|
The argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa fp
|
|
|
|
is the file structure, The argument
|
|
|
|
.Fa offset
|
2002-10-14 17:43:14 +04:00
|
|
|
is the offset into the file.
|
|
|
|
The argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa uio
|
2002-10-14 17:43:14 +04:00
|
|
|
is the uio structure describing the memory to read into.
|
|
|
|
The caller's credentials are specified in
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa cred .
|
|
|
|
The
|
|
|
|
.Fa flags
|
|
|
|
argument can define FOF_UPDATE_OFFSET to update the read position in
|
2002-10-14 17:43:14 +04:00
|
|
|
the file.
|
|
|
|
If the operation is successful zero is returned, otherwise an
|
|
|
|
appropriate error is returned.
|
2002-10-14 08:56:48 +04:00
|
|
|
.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"
|
2002-10-14 17:43:14 +04:00
|
|
|
Common code for a stat operation.
|
|
|
|
The file descriptor is specified by the argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa fp
|
|
|
|
and
|
|
|
|
.Fa sb
|
2002-10-14 17:43:14 +04:00
|
|
|
is the buffer to return the stat information.
|
|
|
|
The argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.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"
|
2002-10-14 17:43:14 +04:00
|
|
|
Common code for a file table vnode write.
|
|
|
|
The argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa fp
|
|
|
|
is the file structure, The argument
|
|
|
|
.Fa offset
|
2002-10-14 17:43:14 +04:00
|
|
|
is the offset into the file.
|
|
|
|
The argument
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa uio
|
2002-10-14 17:43:14 +04:00
|
|
|
is the uio structure describing the memory to read from.
|
|
|
|
The caller's credentials are specified in
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fa cred .
|
|
|
|
The
|
|
|
|
.Fa flags
|
|
|
|
argument can define FOF_UPDATE_OFFSET to update the read position in
|
2002-10-14 17:43:14 +04:00
|
|
|
the file.
|
|
|
|
If the operation is successful zero is returned, otherwise an
|
|
|
|
appropriate error is returned.
|
2002-10-14 08:56:48 +04:00
|
|
|
.El
|
|
|
|
.Sh CODE REFERENCES
|
|
|
|
This section describes places within the
|
|
|
|
.Nx
|
|
|
|
source tree where actual code implementing or utilising the vnode
|
2002-10-14 17:43:14 +04:00
|
|
|
framework can be found.
|
|
|
|
All pathnames are relative to
|
2002-10-14 08:56:48 +04:00
|
|
|
.Pa /usr/src .
|
|
|
|
.Pp
|
|
|
|
The high-level convenience functions are implemented within the file
|
|
|
|
.Pa sys/kern/vfs_vnops.c .
|
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr intro 9 ,
|
|
|
|
.\" file 9 ,
|
|
|
|
.Xr vnode 9 ,
|
|
|
|
.Xr vnodeops 9
|