OSDN Git Service

c445ce2f7dc925aae7ce53e31890fa9ce47d4057
[linuxjm/LDP_man-pages.git] / original / man2 / modify_ldt.2
1 .\" Copyright (c) 1995 Michael Chastain (mec@duracef.shout.net), 22 July 1995.
2 .\"
3 .\" %%%LICENSE_START(GPLv2+_DOC_FULL)
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
20 .\" License along with this manual; if not, see
21 .\" <http://www.gnu.org/licenses/>.
22 .\" %%%LICENSE_END
23 .\"
24 .TH MODIFY_LDT 2 2012-07-13 "Linux" "Linux Programmer's Manual"
25 .SH NAME
26 modify_ldt \- get or set ldt
27 .SH SYNOPSIS
28 .nf
29 .B #include <sys/types.h>
30 .sp
31 .BI "int modify_ldt(int " "func" ", void *" "ptr" ", unsigned long " "bytecount" );
32 .fi
33
34 .IR Note :
35 There is no glibc wrapper for this system call; see NOTES.
36 .SH DESCRIPTION
37 .BR modify_ldt ()
38 reads or writes the local descriptor table (ldt) for a process.
39 The ldt is a per-process memory management table used by the i386 processor.
40 For more information on this table, see an Intel 386 processor handbook.
41 .PP
42 When
43 .I func
44 is 0,
45 .BR modify_ldt ()
46 reads the ldt into the memory pointed to by
47 .IR ptr .
48 The number of bytes read is the smaller of
49 .I bytecount
50 and the actual size of the ldt.
51 .PP
52 When
53 .I func
54 is 1,
55 .BR modify_ldt ()
56 modifies one ldt entry.
57 .I ptr
58 points to a
59 .I user_desc
60 structure
61 and
62 .I bytecount
63 must equal the size of this structure.
64 .\"
65 .\" FIXME Should this page say something about func == 2 and func == 0x11?
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
70 The
71 .I user_desc
72 structure is defined in \fI<asm/ldt.h>\fP as:
73 .in +4n
74 .nf
75
76 struct 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
90 In Linux 2.4 and earlier, this structure was named
91 .IR modify_ldt_ldt_s .
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.
98 .SH RETURN VALUE
99 On success,
100 .BR modify_ldt ()
101 returns either the actual number of bytes read (for reading)
102 or 0 (for writing).
103 On failure,
104 .BR modify_ldt ()
105 returns \-1 and sets
106 .I errno
107 to indicate the error.
108 .SH ERRORS
109 .TP
110 .B EFAULT
111 .I ptr
112 points outside the address space.
113 .TP
114 .B EINVAL
115 .I ptr
116 is 0,
117 or
118 .I func
119 is 1 and
120 .I bytecount
121 is not equal to the size of the structure
122 .IR modify_ldt_ldt_s ,
123 or
124 .I func
125 is 1 and the new ldt entry has invalid values.
126 .TP
127 .B ENOSYS
128 .I func
129 is neither 0 nor 1.
130 .SH CONFORMING TO
131 This call is Linux-specific and should not be used in programs intended
132 to be portable.
133 .SH NOTES
134 Glibc does not provide a wrapper for this system call; call it using
135 .BR syscall (2).
136 .SH SEE ALSO
137 .BR vm86 (2)
138 .SH COLOPHON
139 This page is part of release 3.79 of the Linux
140 .I man-pages
141 project.
142 A description of the project,
143 information about reporting bugs,
144 and the latest version of this page,
145 can be found at
146 \%http://www.kernel.org/doc/man\-pages/.