View | Details | Raw Unified | Return to bug 54451
Collapse All | Expand All

(-)i386_get_ldt.2 (-18 / +32 lines)
Lines 52-97 Link Here
52
The
52
The
53
.Fn i386_get_ldt
53
.Fn i386_get_ldt
54
system call
54
system call
55
will return the list of i386 descriptors that the process has in its
55
will copy the list of i386 descriptors that the process has in its
56
LDT.
56
LDT. It does so starting from the LDT entry index 
57
.Fa start_sel
58
into an arrary pointed to by
59
.Fa descs ,
60
which must be
61
.Fa num_sel
62
elements wide.
63
.Pp
57
The
64
The
58
.Fn i386_set_ldt
65
.Fn i386_set_ldt
59
system call
66
system call
60
will set a list of i386 descriptors for the current process in its
67
will set a list of i386 descriptors for the current process in its
61
LDT.
68
LDT, starting from the LDT entry index
62
Both routines accept a starting selector number
69
.Fa start_sel .
63
.Fa start_sel ,
70
It copies
64
an array of memory that
71
.Fa num_descs
65
will contain the descriptors to be set or returned
72
descriptors in the array pointed to by
66
.Fa descs ,
73
.Fa descs
67
and the number of entries to set or return
74
into the LDT.
68
.Fa num_sels .
69
.Pp
75
.Pp
70
The argument
76
The argument
71
.Fa descs
77
.Fa descs
72
can be either segment_descriptor or gate_descriptor and are defined in
78
can be either segment_descriptor or gate_descriptor and are defined in
73
.Aq Pa i386/segments.h .
79
.Aq Pa i386/segments.h .
74
These structures are defined by the architecture
80
These structures are defined by the architecture
75
as disjoint bit-fields, so care must be taken in constructing them.
81
as disjoint bit-fields, so you must take care in constructing them.
76
.Sh RETURN VALUES
82
.Sh RETURN VALUES
77
Upon successful completion,
83
If successful,
78
.Fn i386_get_ldt
84
.Fn i386_get_ldt
79
returns the number of descriptors currently in the LDT.
85
returns the number of descriptors currently in the LDT.
80
The
81
.Fn i386_set_ldt
86
.Fn i386_set_ldt
82
system call
87
returns the index first selector that it set on success.  If an error
83
returns the first selector set.
88
occurred, the procedures return a value of -1 and set the global
84
Otherwise, a value of -1 is returned and the global
85
variable
89
variable
86
.Va errno
90
.Va errno
87
is set to indicate the error.
91
to indicate the error.
92
.Sh EXAMPLES
93
To set the 
94
.Va "my_ldt_index"
95
th slot of the process's LDT to the value of 
96
.Va my_ldt_entry ,
97
use something like this:
98
.Bd -literal -offset indent
99
if (i386_set_ldt(my_ldt_index, &my_ldt_entry, 1) < 0) {
100
	perror("i386_set_ldt");
101
}
88
.Sh ERRORS
102
.Sh ERRORS
89
The
103
The
90
.Fn i386_get_ldt
104
.Fn i386_get_ldt
91
and
105
and
92
.Fn i386_set_ldt
106
.Fn i386_set_ldt
93
system calls
107
system calls
94
will fail if:
108
will fail with:
95
.Bl -tag -width Er
109
.Bl -tag -width Er
96
.It Bq Er EINVAL
110
.It Bq Er EINVAL
97
An inappropriate value was used for
111
An inappropriate value was used for

Return to bug 54451