2010-12-02 15:54:13 +03:00
|
|
|
.\" $NetBSD: vnfileops.9,v 1.16 2010/12/02 12:54:13 wiz Exp $
|
2002-10-14 08:56:48 +04:00
|
|
|
.\"
|
2006-01-29 06:09:19 +03:00
|
|
|
.\" Copyright (c) 2001, 2005, 2006 The NetBSD Foundation, Inc.
|
2002-10-14 08:56:48 +04:00
|
|
|
.\" 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.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
2008-04-10 08:43:02 +04:00
|
|
|
.Dd April 9, 2008
|
2002-10-14 08:56:48 +04:00
|
|
|
.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 ,
|
2008-05-31 20:24:59 +04:00
|
|
|
.Nm vn_write
|
2002-10-14 08:56:48 +04:00
|
|
|
.Nd vnode file descriptor operations
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In sys/param.h
|
|
|
|
.In sys/file.h
|
|
|
|
.In sys/vnode.h
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_closefile "file_t *fp"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_fcntl "file_t *fp" "u_int com" "void *data"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_ioctl "file_t *fp" "u_long com" "void *data"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_read "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_poll "file_t *fp" "int events"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_statfile "file_t *fp" "struct stat *sb"
|
2002-10-14 08:56:48 +04:00
|
|
|
.Ft int
|
2008-04-10 08:43:02 +04:00
|
|
|
.Fn vn_write "file_t *fp" "off_t *offset" "struct uio *uio" "kauth_cred_t cred" "int flags"
|
2002-10-14 08:56:48 +04:00
|
|
|
.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
|
2002-10-21 00:21:07 +04:00
|
|
|
in the file entries (see
|
|
|
|
.Xr file 9 ) .
|
2002-10-14 17:43:14 +04:00
|
|
|
They are described here only for completeness.
|
2002-10-14 08:56:48 +04:00
|
|
|
.Sh FUNCTIONS
|
|
|
|
.Bl -tag -width compact
|
2006-01-29 06:09:19 +03:00
|
|
|
.It Fn vn_closefile "fp" "l"
|
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
|
2006-01-29 06:09:19 +03:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2002-10-14 08:56:48 +04:00
|
|
|
.Fn vn_closefile
|
|
|
|
simply calls
|
2002-10-21 00:21:07 +04:00
|
|
|
.Xr vn_close 9
|
2002-10-14 08:56:48 +04:00
|
|
|
with the appropriate arguments.
|
2006-01-29 06:09:19 +03:00
|
|
|
.It Fn vn_fcntl "fp" "com" "data" "l"
|
2002-10-14 08:56:48 +04:00
|
|
|
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
|
2006-01-29 06:09:19 +03:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2002-10-14 08:56:48 +04:00
|
|
|
.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.
|
2006-01-29 06:09:19 +03:00
|
|
|
.It Fn vn_ioctl "fp" "com" "data" "l"
|
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
|
2006-01-29 06:09:19 +03:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp
|
2002-10-14 08:56:48 +04:00
|
|
|
.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.
|
2006-01-29 06:09:19 +03:00
|
|
|
.It Fn vn_poll "fp" "events" "l"
|
2002-10-14 08:56:48 +04:00
|
|
|
Common code for a file table vnode poll operation.
|
|
|
|
.Fn vn_poll
|
|
|
|
simply calls
|
|
|
|
.Xr VOP_POLL 9
|
|
|
|
with the events
|
|
|
|
.Fa events
|
2006-01-29 06:09:19 +03:00
|
|
|
and the calling lwp
|
|
|
|
.Fa l .
|
2007-05-17 21:47:10 +04:00
|
|
|
The function returns a bitmask of available events.
|
2006-01-29 06:09:19 +03:00
|
|
|
.It Fn vn_statfile "fp" "sb" "l"
|
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
|
2006-01-29 06:09:19 +03:00
|
|
|
.Fa l
|
|
|
|
is the calling lwp.
|
2002-10-14 08:56:48 +04:00
|
|
|
.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
|
|
|
|
The high-level convenience functions are implemented within the file
|
|
|
|
.Pa sys/kern/vfs_vnops.c .
|
|
|
|
.Sh SEE ALSO
|
2002-10-20 09:18:38 +04:00
|
|
|
.Xr file 9 ,
|
2002-10-20 14:37:36 +04:00
|
|
|
.Xr intro 9 ,
|
2002-10-14 08:56:48 +04:00
|
|
|
.Xr vnode 9 ,
|
2002-10-21 00:21:07 +04:00
|
|
|
.Xr vnodeops 9 ,
|
|
|
|
.Xr vnsubr 9
|