xref: /freebsd/lib/libutil/kinfo_getfile.3 (revision 965cd3b0c509ff0405f056bddc65d6c041483178)
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.\"
28*965cd3b0SJohn Baldwin.Dd May 27, 2015
29ce4a8bcbSPeter Wemm.Dt KINFO_GETFILE 3
30aa12cea2SUlrich Spörlein.Os
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
38*965cd3b0SJohn Baldwin.In sys/user.h
39ce4a8bcbSPeter Wemm.In libutil.h
40ce4a8bcbSPeter Wemm.Ft struct kinfo_file *
41ce4a8bcbSPeter Wemm.Fn kinfo_getfile "pid_t pid" "int *cntp"
42ce4a8bcbSPeter Wemm.Sh DESCRIPTION
43ce4a8bcbSPeter WemmThis function is used for obtaining the file descriptor information
44ce4a8bcbSPeter Wemmof a particular process.
45ce4a8bcbSPeter Wemm.Pp
46ce4a8bcbSPeter WemmThe
47ce4a8bcbSPeter Wemm.Ar pid
48ce4a8bcbSPeter Wemmfield contains the process identifier.
49799162a6SJoel DahlThis should be the a process that you have privilege to access.
50ce4a8bcbSPeter WemmThe
51ce4a8bcbSPeter Wemm.Ar cntp
520eca77fdSMark Johnstonfield allows the caller to know how many records are returned.
53ce4a8bcbSPeter Wemm.Pp
54ce4a8bcbSPeter WemmThis function is a wrapper around
55ce4a8bcbSPeter Wemm.Xr sysctl 3
56ce4a8bcbSPeter Wemmwith the
57ce4a8bcbSPeter Wemm.Dv KERN_PROC_FILEDESC
58ce4a8bcbSPeter Wemmmib.
59ce4a8bcbSPeter WemmWhile the kernel returns a packed structure, this function expands the
60ce4a8bcbSPeter Wemmdata into a fixed record format.
61ce4a8bcbSPeter Wemm.Sh RETURN VALUES
626a3401c5SJohn BaldwinOn success the
63ce4a8bcbSPeter Wemm.Fn kinfo_getfile
64ce4a8bcbSPeter Wemmfunction returns a pointer to an array of
65ce4a8bcbSPeter Wemm.Vt struct kinfo_file
667b593c5dSJohn Baldwinstructures as defined by
677b593c5dSJohn Baldwin.In sys/user.h .
68ce4a8bcbSPeter WemmThe array was obtained by an internal call to
69ce4a8bcbSPeter Wemm.Xr malloc 3
70ce4a8bcbSPeter Wemmand must be freed by the caller with a call to
71ce4a8bcbSPeter Wemm.Xr free 3 .
726a3401c5SJohn BaldwinOn failure the
736a3401c5SJohn Baldwin.Fn kinfo_getfile
746a3401c5SJohn Baldwinfunction returns
756a3401c5SJohn Baldwin.Dv NULL .
76ce4a8bcbSPeter Wemm.Sh SEE ALSO
77ce4a8bcbSPeter Wemm.Xr free 3 ,
78ce4a8bcbSPeter Wemm.Xr kinfo_getvmmap 3 ,
79ce4a8bcbSPeter Wemm.Xr malloc 3 ,
80ce4a8bcbSPeter Wemm.Xr sysctl 3
81