]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man2/modify_ldt.2
getent.1, _syscall.2, acct.2, adjtimex.2, bdflush.2, brk.2, cacheflush.2, getsid...
[thirdparty/man-pages.git] / man2 / modify_ldt.2
CommitLineData
fea681da
MK
1.\" Copyright (c) 1995 Michael Chastain (mec@duracef.shout.net), 22 July 1995.
2.\"
6a8d8745 3.\" %%%LICENSE_START(GPLv2+_doc_full)
fea681da
MK
4.\" This is free documentation; you can redistribute it and/or
5.\" modify it under the terms of the GNU General Public License as
6.\" published by the Free Software Foundation; either version 2 of
7.\" the License, or (at your option) any later version.
8.\"
9.\" The GNU General Public License's references to "object code"
10.\" and "executables" are to be interpreted as the output of any
11.\" document formatting or typesetting system, including
12.\" intermediate and printed output.
13.\"
14.\" This manual is distributed in the hope that it will be useful,
15.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
16.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17.\" GNU General Public License for more details.
18.\"
19.\" You should have received a copy of the GNU General Public
c715f741
MK
20.\" License along with this manual; if not, see
21.\" <http://www.gnu.org/licenses/>.
6a8d8745 22.\" %%%LICENSE_END
fea681da 23.\"
45c99e3e 24.TH MODIFY_LDT 2 2012-07-13 "Linux" "Linux Programmer's Manual"
fea681da
MK
25.SH NAME
26modify_ldt \- get or set ldt
27.SH SYNOPSIS
16718a1c 28.nf
527d9933 29.B #include <sys/types.h>
fea681da
MK
30.sp
31.BI "int modify_ldt(int " "func" ", void *" "ptr" ", unsigned long " "bytecount" );
16718a1c 32.fi
45c99e3e
MK
33
34.IR Note :
35There is no glibc wrapper for this system call; see NOTES.
fea681da 36.SH DESCRIPTION
e511ffb6 37.BR modify_ldt ()
fea681da
MK
38reads or writes the local descriptor table (ldt) for a process.
39The ldt is a per-process memory management table used by the i386 processor.
40For more information on this table, see an Intel 386 processor handbook.
41.PP
42When
43.I func
44is 0,
e511ffb6 45.BR modify_ldt ()
fea681da
MK
46reads the ldt into the memory pointed to by
47.IR ptr .
48The number of bytes read is the smaller of
49.I bytecount
50and the actual size of the ldt.
51.PP
52When
53.I func
54is 1,
e511ffb6 55.BR modify_ldt ()
fea681da
MK
56modifies one ldt entry.
57.I ptr
58points to a
5a16bf48
MK
59.I user_desc
60structure
61and
fea681da
MK
62.I bytecount
63must equal the size of this structure.
5a16bf48 64.\"
0e1ad98c 65.\" FIXME ? say something about func == 2 and func == 0x11?
5a16bf48
MK
66.\" In Linux 2.4, func == 2 returned "the default ldt"
67.\" In Linux 2.6, func == 2 is a nop, returning a zeroed out structure.
68.\" Linux 2.4 and 2.6 implement an operation for func == 0x11
69
70The
71.I user_desc
c84371c6 72structure is defined in \fI<asm/ldt.h>\fP as:
088a639b 73.in +4n
5a16bf48
MK
74.nf
75
76struct user_desc {
77 unsigned int entry_number;
78 unsigned long base_addr;
79 unsigned int limit;
80 unsigned int seg_32bit:1;
81 unsigned int contents:2;
82 unsigned int read_exec_only:1;
83 unsigned int limit_in_pages:1;
84 unsigned int seg_not_present:1;
85 unsigned int useable:1;
86};
87.fi
88.in
89.PP
90In Linux 2.4 and earlier, this structure was named
91.IR modify_ldt_ldt_s .
fea681da
MK
92.\" .PP
93.\" The ldt is specific for the calling process. Any attempts to change
94.\" the ldt to include the address space of another process or the kernel
95.\" will result in a segmentation violation when trying to access the memory
96.\" outside of the process address space. The memory protection is enforced
97.\" at the paging layer.
47297adb 98.SH RETURN VALUE
fea681da 99On success,
e511ffb6 100.BR modify_ldt ()
fea681da
MK
101returns either the actual number of bytes read (for reading)
102or 0 (for writing).
103On failure,
e511ffb6 104.BR modify_ldt ()
fea681da 105returns \-1 and sets
0daa9e92 106.I errno
5a16bf48 107to indicate the error.
fea681da
MK
108.SH ERRORS
109.TP
110.B EFAULT
111.I ptr
112points outside the address space.
113.TP
114.B EINVAL
115.I ptr
116is 0,
117or
118.I func
119is 1 and
120.I bytecount
121is not equal to the size of the structure
122.IR modify_ldt_ldt_s ,
123or
124.I func
125is 1 and the new ldt entry has invalid values.
126.TP
127.B ENOSYS
128.I func
129is neither 0 nor 1.
47297adb 130.SH CONFORMING TO
8382f16d 131This call is Linux-specific and should not be used in programs intended
fea681da 132to be portable.
c12fd10d
MK
133.SH NOTES
134Glibc does not provide a wrapper for this system call; call it using
135.BR syscall (2).
47297adb 136.SH SEE ALSO
fea681da 137.BR vm86 (2)