chroot()

Изменить корневую директорию

Прототип:

#include <unistd.h>
int chroot( const char *path );

Аргументы:

path
The name of the new root directory.

Библиотека:

libc

Описание:

The chroot() function causes the path directory to become the root directory, the starting point for path searches for path names beginning with /. The user's working directory is unaffected.

The .. entry in the root directory is interpreted to mean the root directory itself. Thus, you can't use .. to access files outside the subtree rooted at the root directory.

Возвращаемое значение:

0
Успешное завершение.
-1
Возникла ошибка. Код ошибки записан в errno.

Коды ошибок:

EACCES
Search permission is denied for a component of path.
EBADF
The descriptor isn't valid.
EFAULT
The path argument points to an illegal address.
EINTR
A signal was caught during the chroot() function.
EIO
An I/O error occurred while reading from or writing to the filesystem.
ELOOP
Too many symbolic links were encountered in translating path.
EMULTIHOP
Components of path require hopping to multiple remote machines, and the filesystem type doesn't allow it.
ENAMETOOLONG
The length of the path argument exceeds PATH_MAX, or the length of a path component exceeds NAME_MAX while _POSIX_NO_TRUNC is in effect.
ENOENT
The named directory doesn't exist or is a null pathname.
ENOLINK
The path points to a remote machine and the link to that machine is no longer active.
ENOTDIR
Any component of the path name isn't a directory.
EPERM
The effective user of the calling process isn't the superuser.

Классификация:

Legacy Unix

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Нет
В потоке
Да

Тематические ссылки:

chdir()




Предыдущий раздел: Описание API системной библиотеки