modify_ldt (2) manual page

Table of Contents


modify_ldt - get or set ldt


#include <sys/types.h>
#include <linux/unistd.h>
#include <errno.h>

_syscall3(int, modify_ldt, int, func, void *, ptr, unsigned long, bytecount)
/* Using syscall(2) may be preferable; see intro(2) */

int modify_ldt(int func, void *ptr, unsigned long bytecount);


modify_ldt() reads or writes the local descriptor table (ldt) for a process. The ldt is a per-process memory management table used by the i386 processor. For more information on this table, see an Intel 386 processor handbook.

When func is 0, modify_ldt() reads the ldt into the memory pointed to by ptr. The number of bytes read is the smaller of bytecount and the actual size of the ldt.

When func is 1, modify_ldt() modifies one ldt entry. ptr points to a modify_ldt_ldt_s structure and bytecount must equal the size of this structure.

Return Value

On success, modify_ldt() returns either the actual number of bytes read (for reading) or 0 (for writing). On failure, modify_ldt() returns -1 and sets errno.


EFAULT ptr points outside the address space.

EINVAL ptr is 0, or func is 1 and bytecount is not equal to the size of the structure modify_ldt_ldt_s, or func is 1 and the new ldt entry has invalid values.

ENOSYS func is neither 0 nor 1.

Conforming to

This call is Linux-specific and should not be used in programs intended to be portable.

See Also


Table of Contents