xref: /illumos-gate/usr/src/man/man3proc/Pldt.3proc (revision 01a00981)
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.
64For example, callers could allocate space as:
65.Pp
66.Dl pldt = malloc(sizeof (struct ssd) * nldt);
67.Pp
68For more information on the LDT and the
69.Sy struct ssd ,
70see
71.Xr proc 4 .
72.Pp
73The
74.Fn proc_get_ldt
75function is similar to the
76.Fn Pldt
77function; however, rather than reading from a process handle, it reads
78the
79.Sy ldt
80file from the /proc file system for the process
81.Fa pid .
82.Sh RETURN VALUES
83Upon successful completion, the
84.Fn Pldt
85and
86.Fn proc_get_ldt
87functions return the number of LDT entries written to
88.Fa pldt .
89If
90.Fa pldt
91is
92.Dv NULL
93or
94.Fa nldt
95is zero, then no data will be written.
96Otherwise,
97.Sy -1
98is returned.
99The
100.Fn Pldt
101function sets
102.Sy errno
103to indicate the error that occurred.
104.Sh ERRORS
105For a full list of possible errors see the
106.Sy DIAGNOSTICS
107section in
108.Xr proc 4 .
109.Pp
110The
111.Fn Pldt
112function will fail if:
113.Bl -tag -width Er
114.It Er ENODATA
115No LDT information is available in the process handle
116.Fa P .
117.El
118.Sh ARCHITECTURE
119The
120.Fn Pldt
121and
122.Fn proc_get_ldt
123functions are only available on
124.Sy x86
125platforms.
126.Sh INTERFACE STABILITY
127.Sy Uncommitted
128.Sh MT-LEVEL
129See
130.Sy LOCKING
131in
132.Xr libproc 3LIB .
133.Sh SEE ALSO
134.Xr libproc 3LIB ,
135.Xr proc 4
136