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