xref: /illumos-gate/usr/src/man/man3proc/Pldt.3proc (revision 3ba944265c4ae1fcf23ef758537c2e4f4feec16e)
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 SYNOPSIS
22.Lb libproc
23.In libproc.h
24.Ft int
25.Fo Pldt
26.Fa "struct ps_prochandle *P"
27.Fa "struct ssd *pldt"
28.Fa "int nldt"
29.Fc
30.Ft int
31.Fo proc_get_ldt
32.Fa "pid_t pid"
33.Fa "struct ssd *pldt"
34.Fa "int nldt"
35.Fc
36.Sh DESCRIPTION
37The
38.Fn Pldt
39function reads the local descriptor table (LDT) of the process handle
40.Fa P
41into the buffer
42.Fa pldt .
43Up to
44.Fa nldt
45entries will be read.
46.Pp
47If either
48.Fa pldt
49is
50.Dv NULL
51or
52.Fa nldt
53is
54.Fa 0 ,
55then rather than filling in
56.Fa pldt ,
57only the number of entries currently in the LDT is returned.
58.Pp
59The buffer
60.Fa pldt
61should contain sufficient space for
62.Fa nldt
63entries. For example, callers could allocate space as:
64.Pp
65.Dl pldt = malloc(sizeof (struct ssd) * nldt);
66.Pp
67For more information on the LDT and the
68.Sy struct ssd ,
69see
70.Xr proc 4 .
71.Pp
72The
73.Fn proc_get_ldt
74function is similar to the
75.Fn Pldt
76function; however, rather than reading from a process handle, it reads
77the
78.Sy ldt
79file from the /proc file system for the process
80.Fa pid .
81.Sh RETURN VALUES
82Upon successful completion, the
83.Fn Pldt
84and
85.Fn proc_get_ldt
86functions return the number of LDT entries written to
87.Fa pldt .
88If
89.Fa pldt
90is
91.Dv NULL
92or
93.Fa nldt
94is zero, then no data will be written. Otherwise,
95.Sy -1
96is returned. The
97.Fn Pldt
98function sets
99.Sy errno
100to indicate the error that occurred.
101.Sh ERRORS
102For a full list of possible errors see the
103.Sy DIAGNOSTICS
104section in
105.Xr proc 4 .
106.Pp
107The
108.Fn Pldt
109function will fail if:
110.Bl -tag -width Er
111.It Er ENODATA
112No LDT information is available in the process handle
113.Fa P .
114.El
115.Sh ARCHITECTURE
116The
117.Fn Pldt
118and
119.Fn proc_get_ldt
120functions are only available on
121.Sy x86
122platforms.
123.Sh INTERFACE STABILITY
124.Sy Uncommitted
125.Sh MT-LEVEL
126See
127.Sy LOCKING
128in
129.Xr libproc 3LIB .
130.Sh SEE ALSO
131.Xr libproc 3LIB ,
132.Xr proc 4
133