1CHDIR(2)                   Linux Programmer's Manual                  CHDIR(2)
2
3
4

NAME

6       chdir, fchdir - change working directory
7

SYNOPSIS

9       #include <unistd.h>
10
11       int chdir(const char *path);
12       int fchdir(int fd);
13

DESCRIPTION

15       chdir()  changes  the  current  working  directory to that specified in
16       path.
17
18       fchdir() is identical to chdir();  the  only  difference  is  that  the
19       directory is given as an open file descriptor.
20

RETURN VALUE

22       On  success,  zero is returned.  On error, -1 is returned, and errno is
23       set appropriately.
24

ERRORS

26       Depending on the file system, other errors can be returned.   The  more
27       general errors for chdir() are listed below:
28
29       EACCES Search  permission  is  denied for one of the directories in the
30              path prefix of path.  (See also path_resolution(2).)
31
32       EFAULT path points outside your accessible address space.
33
34       EIO    An I/O error occurred.
35
36       ELOOP  Too many symbolic links were encountered in resolving path.
37
38       ENAMETOOLONG
39              path is too long.
40
41       ENOENT The file does not exist.
42
43       ENOMEM Insufficient kernel memory was available.
44
45       ENOTDIR
46              A component of path is not a directory.
47
48       The general errors for fchdir() are listed below:
49
50       EACCES Search permission was denied on the directory open on fd.
51
52       EBADF  fd is not a valid file descriptor.
53

NOTES

55       A child process created via fork(2) inherits its parent's current work‐
56       ing  directory.   The  current  working  directory is left unchanged by
57       execve(2).
58
59       The prototype for fchdir() is only available if _BSD_SOURCE is defined,
60       or _XOPEN_SOURCE is defined with the value 500.
61

CONFORMING TO

63       SVr4, 4.4BSD, POSIX.1-2001.
64

SEE ALSO

66       chroot(2), path_resolution(2), getcwd(3)
67
68
69
70Linux 2.6.7                       2004-06-23                          CHDIR(2)
Impressum