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