xref: /netbsd/lib/libc/sys/fhopen.2 (revision c4a72b64)
1.\"	$NetBSD: fhopen.2,v 1.7 2002/10/02 10:36:45 wiz Exp $
2.\"
3.\" Copyright (c) 1999 National Aeronautics & Space Administration
4.\" All rights reserved.
5.\"
6.\" This software was written by William Studenmund of the
7.\" Numerical Aerospace Simulation Facility, NASA Ames Research Center.
8.\"
9.\" Redistribution and use in source and binary forms, with or without
10.\" modification, are permitted provided that the following conditions
11.\" are met:
12.\" 1. Redistributions of source code must retain the above copyright
13.\"    notice, this list of conditions and the following disclaimer.
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\"    notice, this list of conditions and the following disclaimer in the
16.\"    documentation and/or other materials provided with the distribution.
17.\" 3. Neither the name of the National Aeronautics & Space Administration
18.\"    nor the names of its contributors may be used to endorse or promote
19.\"    products derived from this software without specific prior written
20.\"    permission.
21.\"
22.\" THIS SOFTWARE IS PROVIDED BY THE NATIONAL AERONAUTICS & SPACE ADMINISTRATION
23.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
24.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE ADMINISTRATION OR CONTRIB-
26.\" UTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
27.\" OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32.\" POSSIBILITY OF SUCH DAMAGE.
33.\"/
34.Dd June 29, 1999
35.Dt FHOPEN 2
36.Os
37.Sh NAME
38.Nm fhopen ,
39.Nm fhstat ,
40.Nm fhstatfs
41.Nd access file via file handle
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.Fd #include \*[Lt]sys/types.h\*[Gt]
46.Fd #include \*[Lt]sys/stat.h\*[Gt]
47.Ft int
48.Fn fhopen "const fhandle_t *fhp" "int flags"
49.Ft int
50.Fn fhstat "const fhandle_t *fhp" "struct stat *sb"
51.Ft int
52.Fn fhstatfs "const fhandle_t *fhp" "struct statfs *buf"
53.Sh DESCRIPTION
54These functions provide a means to access a file given the file handle
55.Fa fhp .
56As this method bypasses directory access restrictions, these calls are
57restricted to the superuser.
58.Pp
59.Fn fhopen
60opens the file referenced by
61.Fa fhp
62for reading and/or writing as specified by the argument
63.Fa flags
64and returns the file descriptor to the calling process.
65The
66.Fa flags
67are specified by
68.Em or Ns 'ing
69together the flags used for the
70.Xr open 2
71call.
72All said flags are valid except for
73.Dv O_CREAT .
74.Pp
75.Fn fhstat
76and
77.Fn fhstatfs
78provide the functionality of the
79.Xr fstat 2
80and
81.Xr fstatfs 2
82calls except that they return information for the file referred to by
83.Fa fhp
84rather than an open file.
85.Sh RETURN VALUES
86Upon successful completion,
87.Fn fhopen
88returns the file descriptor for the opened file, while
89.Fn fhstat
90and
91.Fn fhstatfs
92return 0.
93Otherwise, -1 is returned and
94.Va errno
95is set to indicate the error.
96.Sh ERRORS
97In addition to the errors returned by
98.Xr open 2 ,
99.Xr fstat 2 ,
100and
101.Xr fstatfs 2
102respectively,
103.Fn fhopen ,
104.Fn fhstat ,
105and
106.Fn fhstatfs
107will return
108.Bl -tag -width Er
109.It Bq Er EINVAL
110Calling
111.Fn fhopen
112with
113.Dv O_CREAT
114set.
115.It Bq Er ESTALE
116The file handle
117.Fa fhp
118is no longer valid.
119.El
120.Sh SEE ALSO
121.Xr fstat 2 ,
122.Xr fstatfs 2 ,
123.Xr getfh 2 ,
124.Xr open 2
125.Sh HISTORY
126The
127.Fn fhopen ,
128.Fn fhstat ,
129and
130.Fn fhstatfs
131functions first appeared in
132.Nx 1.5 .
133