Skip to content

Latest commit

History

History
33 lines (21 loc) 路 962 Bytes

chroot.md

File metadata and controls

33 lines (21 loc) 路 962 Bytes

Name

chroot, chroot_with_mount_flags - change filesystem root

Synopsis

#include <unistd.h>

int chroot(const char* path);
int chroot_with_mount_flags(const char* path, int mount_flags);

Description

chroot() changes the filesystem root of the current process to a new directory specified by path.

chroot_with_mount_flags() additionally applies the given mount_flags to the new root directory of the current process as if it was a separate mount. All the same flags as for mount(2) are accepted, except MS_BIND doesn't make sense for chroots. Additionally, the value -1 is accepted, and makes chroot_with_mount_flags() behave like regular chroot().

Errors

  • EPERM: The current process does not have superuser privileges.
  • EFAULT: path is not in readable memory.

All of the usual path resolution errors may also occur.

See also