1.\" $NetBSD: fhopen.2,v 1.15 2006/08/03 19:17:49 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 July 17, 2006 35.Dt FHOPEN 2 36.Os 37.Sh NAME 38.Nm fhopen , 39.Nm fhstat , 40.Nm fhstatvfs 41.Nd access file via file handle 42.Sh LIBRARY 43.Lb libc 44.Sh SYNOPSIS 45.In sys/types.h 46.Ft int 47.Fn fhopen "const void *fhp" "size_t fh_size" "int flags" 48.In sys/stat.h 49.Ft int 50.Fn fhstat "const void *fhp" "size_t fh_size" "struct stat *sb" 51.In sys/statvfs.h 52.Ft int 53.Fn fhstatvfs "const void *fhp" "size_t fh_size" "struct statvfs *buf" 54.Ft int 55.Fn fhstatvfs1 "const void *fhp" "size_t fh_size" "struct statvfs *buf" "int flags" 56.Sh DESCRIPTION 57These functions provide a means to access a file given the opaque file handle 58.Fa fhp 59and the size 60.Fa fh_size 61of the opaque object as returned by 62.Xr getfh 2 . 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 fhstatvfs , 84and 85.Fn fhstatvfs1 86provide the functionality of the 87.Xr fstat 2 , 88.Xr fstatvfs 2 , 89and 90.Xr fstatvfs1 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, while 98.Fn fhstat , 99.Fn fhstatvfs , 100and 101.Fn fhstatvfs1 102return 0. 103Otherwise, \-1 is returned and 104.Va errno 105is set to indicate the error. 106.Sh ERRORS 107In addition to the errors returned by 108.Xr open 2 , 109.Xr fstat 2 , 110.Xr fstatvfs 2 , 111and 112.Xr fstatvfs1 2 , 113respectively, 114.Fn fhopen , 115.Fn fhstat , 116.Fn fhstatvfs , 117and 118.Fn fhstatvfs1 119will return 120.Bl -tag -width Er 121.It Bq Er EINVAL 122Calling 123.Fn fhopen 124with 125.Dv O_CREAT 126set or invalid 127.Fa fh_size . 128.It Bq Er ESTALE 129The file handle 130.Fa fhp 131is no longer valid. 132.El 133.Sh SEE ALSO 134.Xr fstat 2 , 135.Xr fstatvfs 2 , 136.Xr fstatvfs1 2 , 137.Xr getfh 2 , 138.Xr open 2 139.Sh HISTORY 140The 141.Fn fhopen , 142and 143.Fn fhstat 144functions first appeared in 145.Nx 1.5 . 146The 147.Fn fhstatvfs 148function replaced 149.Fn fhstatfs 150in 151.Nx 3.0 . 152