
- Linux System Calls
- Linux System Calls - Home
- A
- accept
- access
- acct
- add_key
- adjtimex
- afs_syscall
- alarm
- alloc_hugepages
- arch_prctl
- B
- bdflush
- bind
- break
- brk
- C
- cacheflush
- chdir
- chmod
- chown
- chroot
- clone2
- clone
- close
- connect
- create_module
- creat
- D
- dup2
- dup
- E
- epoll_create
- epoll_ctl
- epoll_wait
- execve
- exit_group
- _exit
- exit
- _Exit
- F
- faccessat
- fattch
- fchdir
- fchmodat
- fchmod
- fchownat
- fchown
- fcntl
- fdatasync
- fdetach
- flock
- fork
- free_hugepages
- fstatat
- fstatfs
- fstat
- fstatvfs
- fsync
- ftruncate
- futex
- futimesat
- G
- getcontext
- getcwd
- getdents
- getdomainname
- getdtablesize
- getegid
- geteuid
- getgid
- getgroups
- gethostid
- gethostname
- getitimer
- get_kernel_syms
- get_mempolicy
- getmsg
- getpagesize
- getpeername
- getpgid
- getpgrp
- getpid
- getpmsg
- getppid
- getpriority
- getresgid
- getresuid
- getrlimit
- get_robust_list
- getrusage
- getsid
- getsockname
- getsockopt
- get_thread_area
- gettid
- gettimeofday
- getuid
- getunwind
- gtty
- I
- idle
- inb
- inb_p
- init_module
- inl
- inl_p
- inotify_add_watch
- inotify_init
- inotify_rm_watch
- insb
- insl
- insw
- intro
- inw
- inw_p
- io_cancel
- ioctl
- ioctl_list
- io_destroy
- io_getevents
- ioperm
- iopl
- ioprio_get
- ioprio_set
- io_setup
- io_submit
- ipc
- isastream
- K
- kexec_load
- keyctl
- kill
- killpg
- L
- lchown
- linkat
- link
- listen
- _llseek
- llseek
- lock
- lookup_dcookie
- lseek
- lstat
- M
- madvise
- mincore
- mkdirat
- mkdir
- mknodat
- mknod
- mlockall
- mlock
- mmap2
- mmap
- modify_ldt
- mount
- move_pages
- mprotect
- mpx
- mq_getsetattr
- mremap
- msgctl
- msgget
- msgop
- msgrcv
- msgsnd
- msync
- multiplexer
- munlockall
- munlock
- munmap
- N
- nanosleep
- _newselect
- nfsservctl
- nice
- O
- obsolete
- oldfstat
- oldlstat
- oldolduname
- oldstat
- olduname
- openat
- open
- outb
- outb_p
- outl
- outl_p
- outsb
- outsl
- outsw
- outw
- outw_p
- P
- path_resolution
- pause
- perfmonctl
- personality
- pipe
- pivot_root
- poll
- posix_fadvise
- ppoll
- prctl
- pread
- prof
- pselect
- ptrace
- putmsg
- putpmsg
- pwrite
- Q
- query_module
- quotactl
- R
- readahead
- readdir
- read
- readlinkat
- readlink
- readv
- reboot
- recvfrom
- recv
- recvmsg
- remap_file_pages
- renameat
- rename
- request_key
- restart_syscall
- rmdir
- rtas
- rt_sigaction
- rt_sigpending
- rt_sigprocmask
- rt_sigqueueinfo
- rt_sigreturn
- rt_sigsuspend
- rt_sigtimedwait
- S
- sbrk
- sched_getaffinity
- sched_getparam
- sched_get_priority_max
- sched_get_priority_min
- sched_getscheduler
- sched_rr_get_interval
- sched_setaffinity
- sched_setparam
- sched_setscheduler
- sched_yield
- security
- select
- select_tut
- semctl
- semget
- semop
- semtimedop
- sendfile
- send
- sendmsg
- sendto
- setcontext
- setdomainname
- setegid
- seteuid
- setfsgid
- setfsuid
- setgid
- setgroups
- sethostid
- sethostname
- setitimer
- setpgid
- setpgrp
- setpriority
- setregid
- setresgid
- setresuid
- setreuid
- setrlimit
- set_robust_list
- setsid
- setsockopt
- set_thread_area
- set_tid_address
- settimeofday
- setuid
- setup
- sgetmask
- shmat
- shmctl
- shmdt
- shmget
- shmop
- shutdown
- sigaction
- sigaltstack
- signal
- sigpending
- sigprocmask
- sigqueue
- sigreturn
- sigsuspend
- sigtimedwait
- sigwaitinfo
- socketcall
- socket
- socketpair
- splice
- spu_create
- spufs
- spu_run
- ssetmask
- statfs64
- statfs
- stat
- statvfs
- stime
- stty
- swapcontext
- swapoff
- swapon
- symlinkat
- symlink
- sync_file_range
- sync
- _syscall
- syscall
- syscalls
- _sysctl
- sysctl
- sysfs
- sysinfo
- syslog
- T
- tee
- tgkill
- time
- timer_create
- timer_delete
- timer_getoverrun
- timer_gettime
- timer_settime
- times
- tkill
- truncate
- tux
- U
- umask
- umount2
- umount
- uname
- undocumented
- unimplemented
- unlinkat
- unlink
- unshare
- uselib
- ustat
- utime
- utimes
- V
- vfork
- vhangup
- vm86
- vm86old
- vmsplice
- vserver
- W
- wait3
- wait4
- wait
- waitid
- waitpid
- write
- writev
chroot() System Call in Linux
NAME
chroot - change root directory
SYNOPSIS
#include <unistd.h> |
DESCRIPTION
chroot() changes the root directory to that specified in path. This directory will be used for pathnames beginning with /. The root directory is inherited by all children of the current process.
Only a privileged process (Linux: one with the CAP_SYS_CHROOT capability) may call chroot(2).This call changes an ingredient in the pathname resolution process and does nothing else.
This call does not change the current working directory, so that after the call . can be outside the tree rooted at /. In particular, the superuser can escape from a chroot jail by doing mkdir foo; chroot foo; cd ...
This call does not close open file descriptors, and such file descriptors may allow access to files outside the chroot tree.
RETURN VALUE
On success, zero is returned. On error, -1 is returned, and errno is set appropriately.
ERRORS
Depending on the file system, other errors can be returned. The more general errors are listed below:
Error Code | Description |
---|---|
EACCES | Search permission is denied on a component of the path prefix. (See also path_resolution(2).) |
EFAULT | path points outside your accessible address space. |
EIO | An I/O error occurred. |
ELOOP | Too many symbolic links were encountered in resolving path. |
ENAMETOOLONG | path is too long. |
ENOENT | The file does not exist. |
ENOMEM | Insufficient kernel memory was available. |
ENOTDIR | A component of path is not a directory. |
EPERM | The caller has insufficient privilege. |
CONFORMING TO
SVr4, 4.4BSD, SUSv2 (marked LEGACY). This function is not part of POSIX.1-2001.
NOTES
A child process created via fork(2) inherits its parents root directory. The root directory is left unchanged by execve(2).
FreeBSD has a stronger jail() system call.