Sunday, October 16, 2011

chdir c

chdir system call unix
NAME

chdir, fchdir – change current directory

SYNOPSIS

#include <unistd.h>
int chdir(const char * path);
int fchdir(int fd);

FEATURES  

MSDOSFS, NFS_CLIENT, UFS

DESCRIPTION

path points to the path name of a directory. chdir causes the named directory to become the current working directory of the calling c_actor, the starting point for path searches for pathnames not beginning with a slash ( / ).

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

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 both chdir , and fchdir return 0; otherwise they return -1 and set errno to indicate one of the following error conditions:

[ENOTDIR]      A component of the path name is not a directory.
[ENOENT]       The named directory does not exist.
[EACCES]       Search permission is denied for a component of the path name.
[EFAULT]       path points outside the allocated address space of  the c_actor.
[ENAMETOOLONG] The length of a component of path exceeds NAME_MAX characters or the length of path exceeds PATH_MAX characters.
[ELOOP]        Too many symbolic links were encountered during analysis of path .
[EIO]          An I/O error occurred while reading from the file  system. fchdir will fail and the current working directory will be unchanged if one or more of the following are true:
[EACCES]       Search permission is denied for the directory
referenced by the file descriptor.
[ENOTDIR]      The file descriptor does not reference a directory.
[EBADF]        The fd argument is not a valid file descriptor


ATTRIBUTES
See attributes(5) for descriptions of the following attributes:

ATTRIBUTE TYPE
ATTRIBUTE VALUE
Interface Stability
Evolving

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

HISTORY  
The fchdir function call appeared in 4.2 BSD.

2 comments:

  1. I think this is among the most important info for me.

    And i am glad reading your article. But wanna remark on few general things, The website style is great, the articles is really great : D.

    Good job, cheers
    My web-site :: Computer Repair In Charlotte NC

    ReplyDelete