CHDIR(2)                         System Calls                         CHDIR(2)




NAME

       chdir, fchdir - change current working directory


SYNOPSIS

       #include <unistd.h>

       int chdir (const char *path);
       int fchdir (int fd);


DESCRIPTION

       The  path  argument  points  to the pathname of a directory.  The chdir
       function causes the named  directory  to  become  the  current  working
       directory,  that  is, the starting point for path searches of pathnames
       not beginning with a slash (/), a colon (:), or a device name.

       The fchdir function causes the directory referenced by fd to become the
       current  working  directory,  the  starting  point for path searches of
       pathnames not beginning with a slash (/), a  colon  (:),  or  a  device
       name.

       Under  GNO,  these  calls are wrappers to the GS/OS SetPrefix call.  If
       the length of path is equal to or less than 64 characters,  both  GS/OS
       prefix  0  (zero)  and 8 will be set.  If the length of path is over 64
       characters, then GS/OS prefix 0 is set to a zero length string and pre-
       fix 8 is set to the value of path.

       If  an  error occurs in setting prefix 8 or both prefixes 0 and 8, then
       neither prefix will be set and these calls fail.   If  the  setting  of
       prefix  8 succeeds but an error occurs when setting prefix 0, then pre-
       fix 0 is set to a zero length string.  In the latter case  these  calls
       are considered to have succeeded.

       In  order  for  a  directory to become the current directory, a process
       must have execute (search) access to the directory.


RETURN VALUES

       Upon successful completion, a value of 0  is  returned.   Otherwise,  a
       value of -1 is returned and errno is set to indicate the error.


SEE ALSO

       chroot(2)


STANDARDS

       chdir is expected to conform to IEEE Std 1003.1-1988 (POSIX).


HISTORY

       The fchdir function call appeared in 4.2BSD.



GNO                             26 January 1997                       CHDIR(2)

Man(1) output converted with man2html