xref: /illumos-gate/usr/src/man/man3proc/Pldt.3proc (revision 8a2b682e57a046b828f37bcde1776f131ef4629f)
1.\"
2.\" This file and its contents are supplied under the terms of the
3.\" Common Development and Distribution License ("CDDL"), version 1.0.
4.\" You may only use this file in accordance with the terms of version
5.\" 1.0 of the CDDL.
6.\"
7.\" A full copy of the text of the CDDL should have accompanied this
8.\" source.  A copy of the CDDL is also available via the Internet at
9.\" http://www.illumos.org/license/CDDL.
10.\"
11.\"
12.\" Copyright 2015 Joyent, Inc.
13.\"
14.Dd May 11, 2016
15.Dt PLDT 3PROC
16.Os
17.Sh NAME
18.Nm Pldt ,
19.Nm proc_get_ldt
20.Nd obtain local descriptor table of a process
21.Sh LIBRARY
22.Lb libproc
23.Sh SYNOPSIS
24.In libproc.h
25.Ft int
26.Fo Pldt
27.Fa "struct ps_prochandle *P"
28.Fa "struct ssd *pldt"
29.Fa "int nldt"
30.Fc
31.Ft int
32.Fo proc_get_ldt
33.Fa "pid_t pid"
34.Fa "struct ssd *pldt"
35.Fa "int nldt"
36.Fc
37.Sh DESCRIPTION
38The
39.Fn Pldt
40function reads the local descriptor table (LDT) of the process handle
41.Fa P
42into the buffer
43.Fa pldt .
44Up to
45.Fa nldt
46entries will be read.
47.Pp
48If either
49.Fa pldt
50is
51.Dv NULL
52or
53.Fa nldt
54is
55.Fa 0 ,
56then rather than filling in
57.Fa pldt ,
58only the number of entries currently in the LDT is returned.
59.Pp
60The buffer
61.Fa pldt
62should contain sufficient space for
63.Fa nldt
64entries.
65For example, callers could allocate space as:
66.Pp
67.Dl pldt = malloc(sizeof (struct ssd) * nldt);
68.Pp
69For more information on the LDT and the
70.Sy struct ssd ,
71see
72.Xr proc 4 .
73.Pp
74The
75.Fn proc_get_ldt
76function is similar to the
77.Fn Pldt
78function; however, rather than reading from a process handle, it reads
79the
80.Sy ldt
81file from the /proc file system for the process
82.Fa pid .
83.Sh RETURN VALUES
84Upon successful completion, the
85.Fn Pldt
86and
87.Fn proc_get_ldt
88functions return the number of LDT entries written to
89.Fa pldt .
90If
91.Fa pldt
92is
93.Dv NULL
94or
95.Fa nldt
96is zero, then no data will be written.
97Otherwise,
98.Sy -1
99is returned.
100The
101.Fn Pldt
102function sets
103.Sy errno
104to indicate the error that occurred.
105.Sh ERRORS
106For a full list of possible errors see the
107.Sy DIAGNOSTICS
108section in
109.Xr proc 4 .
110.Pp
111The
112.Fn Pldt
113function will fail if:
114.Bl -tag -width Er
115.It Er ENODATA
116No LDT information is available in the process handle
117.Fa P .
118.El
119.Sh ARCHITECTURE
120The
121.Fn Pldt
122and
123.Fn proc_get_ldt
124functions are only available on
125.Sy x86
126platforms.
127.Sh INTERFACE STABILITY
128.Sy Uncommitted
129.Sh MT-LEVEL
130See
131.Sy LOCKING
132in
133.Xr libproc 3LIB .
134.Sh SEE ALSO
135.Xr libproc 3LIB ,
136.Xr proc 4
137