1ce4a8bcbSPeter Wemm.\" 2ce4a8bcbSPeter Wemm.\" Copyright (c) 2008 Peter Wemm 3ce4a8bcbSPeter Wemm.\" All rights reserved. 4ce4a8bcbSPeter Wemm.\" 5ce4a8bcbSPeter Wemm.\" Redistribution and use in source and binary forms, with or without 6ce4a8bcbSPeter Wemm.\" modification, are permitted provided that the following conditions 7ce4a8bcbSPeter Wemm.\" are met: 8ce4a8bcbSPeter Wemm.\" 1. Redistributions of source code must retain the above copyright 9ce4a8bcbSPeter Wemm.\" notice, this list of conditions and the following disclaimer. 10ce4a8bcbSPeter Wemm.\" 2. Redistributions in binary form must reproduce the above copyright 11ce4a8bcbSPeter Wemm.\" notice, this list of conditions and the following disclaimer in the 12ce4a8bcbSPeter Wemm.\" documentation and/or other materials provided with the distribution. 13ce4a8bcbSPeter Wemm.\" 14ce4a8bcbSPeter Wemm.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15ce4a8bcbSPeter Wemm.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16ce4a8bcbSPeter Wemm.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17ce4a8bcbSPeter Wemm.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18ce4a8bcbSPeter Wemm.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19ce4a8bcbSPeter Wemm.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20ce4a8bcbSPeter Wemm.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21ce4a8bcbSPeter Wemm.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22ce4a8bcbSPeter Wemm.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23ce4a8bcbSPeter Wemm.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24ce4a8bcbSPeter Wemm.\" SUCH DAMAGE. 25ce4a8bcbSPeter Wemm.\" 26ce4a8bcbSPeter Wemm.\" $FreeBSD$ 27ce4a8bcbSPeter Wemm.\" 28ce4a8bcbSPeter Wemm.Dd December 6, 2008 29ce4a8bcbSPeter Wemm.Os 30ce4a8bcbSPeter Wemm.Dt KINFO_GETFILE 3 31ce4a8bcbSPeter Wemm.Sh NAME 32ce4a8bcbSPeter Wemm.Nm kinfo_getfile 33ce4a8bcbSPeter Wemm.Nd function for getting per-process file descriptor information 34ce4a8bcbSPeter Wemm.Sh LIBRARY 35ce4a8bcbSPeter Wemm.Lb libutil 36ce4a8bcbSPeter Wemm.Sh SYNOPSIS 37ce4a8bcbSPeter Wemm.In sys/types.h 38ce4a8bcbSPeter Wemm.In libutil.h 39ce4a8bcbSPeter Wemm.Ft struct kinfo_file * 40ce4a8bcbSPeter Wemm.Fn kinfo_getfile "pid_t pid" "int *cntp" 41ce4a8bcbSPeter Wemm.Sh DESCRIPTION 42ce4a8bcbSPeter WemmThis function is used for obtaining the file descriptor information 43ce4a8bcbSPeter Wemmof a particular process. 44ce4a8bcbSPeter Wemm.Pp 45ce4a8bcbSPeter WemmThe 46ce4a8bcbSPeter Wemm.Ar pid 47ce4a8bcbSPeter Wemmfield contains the process identifier. 48ce4a8bcbSPeter WemmThis should be the a process that you have privilige to access. 49ce4a8bcbSPeter WemmThe 50ce4a8bcbSPeter Wemm.Ar cntp 51ce4a8bcbSPeter Wemmfield is allows the caller to know how many records are returned. 52ce4a8bcbSPeter Wemm.Pp 53ce4a8bcbSPeter WemmThis function is a wrapper around 54ce4a8bcbSPeter Wemm.Xr sysctl 3 55ce4a8bcbSPeter Wemmwith the 56ce4a8bcbSPeter Wemm.Dv KERN_PROC_FILEDESC 57ce4a8bcbSPeter Wemmmib. 58ce4a8bcbSPeter WemmWhile the kernel returns a packed structure, this function expands the 59ce4a8bcbSPeter Wemmdata into a fixed record format. 60ce4a8bcbSPeter Wemm.Sh RETURN VALUES 616a3401c5SJohn BaldwinOn success the 62ce4a8bcbSPeter Wemm.Fn kinfo_getfile 63ce4a8bcbSPeter Wemmfunction returns a pointer to an array of 64ce4a8bcbSPeter Wemm.Vt struct kinfo_file 657b593c5dSJohn Baldwinstructures as defined by 667b593c5dSJohn Baldwin.In sys/user.h . 67ce4a8bcbSPeter WemmThe array was obtained by an internal call to 68ce4a8bcbSPeter Wemm.Xr malloc 3 69ce4a8bcbSPeter Wemmand must be freed by the caller with a call to 70ce4a8bcbSPeter Wemm.Xr free 3 . 716a3401c5SJohn BaldwinOn failure the 726a3401c5SJohn Baldwin.Fn kinfo_getfile 736a3401c5SJohn Baldwinfunction returns 746a3401c5SJohn Baldwin.Dv NULL . 75ce4a8bcbSPeter Wemm.Sh SEE ALSO 76ce4a8bcbSPeter Wemm.Xr free 3 , 77ce4a8bcbSPeter Wemm.Xr kinfo_getvmmap 3 , 78ce4a8bcbSPeter Wemm.Xr malloc 3 , 79ce4a8bcbSPeter Wemm.Xr sysctl 3 80