xref: /f-stack/tools/libutil/kinfo_getfile.3 (revision 22ce4aff)
11eaf0ac3Slogwang.\"
21eaf0ac3Slogwang.\" Copyright (c) 2008 Peter Wemm
31eaf0ac3Slogwang.\" All rights reserved.
41eaf0ac3Slogwang.\"
51eaf0ac3Slogwang.\" Redistribution and use in source and binary forms, with or without
61eaf0ac3Slogwang.\" modification, are permitted provided that the following conditions
71eaf0ac3Slogwang.\" are met:
81eaf0ac3Slogwang.\" 1. Redistributions of source code must retain the above copyright
91eaf0ac3Slogwang.\"    notice, this list of conditions and the following disclaimer.
101eaf0ac3Slogwang.\" 2. Redistributions in binary form must reproduce the above copyright
111eaf0ac3Slogwang.\"    notice, this list of conditions and the following disclaimer in the
121eaf0ac3Slogwang.\"    documentation and/or other materials provided with the distribution.
131eaf0ac3Slogwang.\"
141eaf0ac3Slogwang.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
151eaf0ac3Slogwang.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
161eaf0ac3Slogwang.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
171eaf0ac3Slogwang.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
181eaf0ac3Slogwang.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
191eaf0ac3Slogwang.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
201eaf0ac3Slogwang.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
211eaf0ac3Slogwang.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
221eaf0ac3Slogwang.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
231eaf0ac3Slogwang.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
241eaf0ac3Slogwang.\" SUCH DAMAGE.
251eaf0ac3Slogwang.\"
261eaf0ac3Slogwang.\" $FreeBSD$
271eaf0ac3Slogwang.\"
281eaf0ac3Slogwang.Dd May 27, 2015
291eaf0ac3Slogwang.Dt KINFO_GETFILE 3
301eaf0ac3Slogwang.Os
311eaf0ac3Slogwang.Sh NAME
321eaf0ac3Slogwang.Nm kinfo_getfile
331eaf0ac3Slogwang.Nd function for getting per-process file descriptor information
341eaf0ac3Slogwang.Sh LIBRARY
351eaf0ac3Slogwang.Lb libutil
361eaf0ac3Slogwang.Sh SYNOPSIS
371eaf0ac3Slogwang.In sys/types.h
381eaf0ac3Slogwang.In sys/user.h
391eaf0ac3Slogwang.In libutil.h
401eaf0ac3Slogwang.Ft struct kinfo_file *
411eaf0ac3Slogwang.Fn kinfo_getfile "pid_t pid" "int *cntp"
421eaf0ac3Slogwang.Sh DESCRIPTION
431eaf0ac3SlogwangThis function is used for obtaining the file descriptor information
441eaf0ac3Slogwangof a particular process.
451eaf0ac3Slogwang.Pp
461eaf0ac3SlogwangThe
471eaf0ac3Slogwang.Ar pid
481eaf0ac3Slogwangfield contains the process identifier.
491eaf0ac3SlogwangThis should be the a process that you have privilege to access.
501eaf0ac3SlogwangThe
511eaf0ac3Slogwang.Ar cntp
521eaf0ac3Slogwangfield allows the caller to know how many records are returned.
531eaf0ac3Slogwang.Pp
541eaf0ac3SlogwangThis function is a wrapper around
551eaf0ac3Slogwang.Xr sysctl 3
561eaf0ac3Slogwangwith the
571eaf0ac3Slogwang.Dv KERN_PROC_FILEDESC
581eaf0ac3Slogwangmib.
591eaf0ac3SlogwangWhile the kernel returns a packed structure, this function expands the
601eaf0ac3Slogwangdata into a fixed record format.
611eaf0ac3Slogwang.Sh RETURN VALUES
621eaf0ac3SlogwangOn success the
631eaf0ac3Slogwang.Fn kinfo_getfile
641eaf0ac3Slogwangfunction returns a pointer to an array of
651eaf0ac3Slogwang.Vt struct kinfo_file
661eaf0ac3Slogwangstructures as defined by
671eaf0ac3Slogwang.In sys/user.h .
681eaf0ac3SlogwangThe array was obtained by an internal call to
691eaf0ac3Slogwang.Xr malloc 3
701eaf0ac3Slogwangand must be freed by the caller with a call to
711eaf0ac3Slogwang.Xr free 3 .
721eaf0ac3SlogwangOn failure the
731eaf0ac3Slogwang.Fn kinfo_getfile
741eaf0ac3Slogwangfunction returns
751eaf0ac3Slogwang.Dv NULL .
761eaf0ac3Slogwang.Sh SEE ALSO
771eaf0ac3Slogwang.Xr free 3 ,
781eaf0ac3Slogwang.Xr kinfo_getvmmap 3 ,
791eaf0ac3Slogwang.Xr malloc 3 ,
801eaf0ac3Slogwang.Xr sysctl 3
81*22ce4affSfengbojiang.Sh HISTORY
82*22ce4affSfengbojiangThe
83*22ce4affSfengbojiang.Fn kinfo_getfile
84*22ce4affSfengbojiangfunction first appeared in
85*22ce4affSfengbojiang.Fx 7.0 .
86