logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

chdir.3p (3321B)


  1. '\" et
  2. .TH CHDIR "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. chdir
  12. \(em change working directory
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. int chdir(const char *\fIpath\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIchdir\fR()
  23. function shall cause the directory named by the pathname pointed to
  24. by the
  25. .IR path
  26. argument to become the current working directory; that is, the starting
  27. point for path searches for pathnames not beginning with
  28. .BR '/' .
  29. .SH "RETURN VALUE"
  30. Upon successful completion, 0 shall be returned. Otherwise, \-1 shall
  31. be returned, the current working directory shall remain unchanged, and
  32. .IR errno
  33. shall be set to indicate the error.
  34. .SH ERRORS
  35. The
  36. \fIchdir\fR()
  37. function shall fail if:
  38. .TP
  39. .BR EACCES
  40. Search permission is denied for any component of the pathname.
  41. .TP
  42. .BR ELOOP
  43. A loop exists in symbolic links encountered during resolution of the
  44. .IR path
  45. argument.
  46. .TP
  47. .BR ENAMETOOLONG
  48. .br
  49. The length of a component of a pathname is longer than
  50. {NAME_MAX}.
  51. .TP
  52. .BR ENOENT
  53. A component of
  54. .IR path
  55. does not name an existing directory or
  56. .IR path
  57. is an empty string.
  58. .TP
  59. .BR ENOTDIR
  60. A component of the pathname names an existing file that is neither
  61. a directory nor a symbolic link to a directory.
  62. .P
  63. The
  64. \fIchdir\fR()
  65. function may fail if:
  66. .TP
  67. .BR ELOOP
  68. More than
  69. {SYMLOOP_MAX}
  70. symbolic links were encountered during resolution of the
  71. .IR path
  72. argument.
  73. .TP
  74. .BR ENAMETOOLONG
  75. .br
  76. The length of a pathname exceeds
  77. {PATH_MAX},
  78. or pathname resolution of a symbolic link produced an intermediate
  79. result with a length that exceeds
  80. {PATH_MAX}.
  81. .LP
  82. .IR "The following sections are informative."
  83. .SH EXAMPLES
  84. .SS "Changing the Current Working Directory"
  85. .P
  86. The following example makes the value pointed to by
  87. .BR directory ,
  88. .BR /tmp ,
  89. the current working directory.
  90. .sp
  91. .RS 4
  92. .nf
  93. #include <unistd.h>
  94. \&...
  95. char *directory = "/tmp";
  96. int ret;
  97. .P
  98. ret = chdir (directory);
  99. .fi
  100. .P
  101. .RE
  102. .SH "APPLICATION USAGE"
  103. None.
  104. .SH RATIONALE
  105. The
  106. \fIchdir\fR()
  107. function only affects the working directory of the current process.
  108. .SH "FUTURE DIRECTIONS"
  109. None.
  110. .SH "SEE ALSO"
  111. .IR "\fIgetcwd\fR\^(\|)"
  112. .P
  113. The Base Definitions volume of POSIX.1\(hy2017,
  114. .IR "\fB<unistd.h>\fP"
  115. .\"
  116. .SH COPYRIGHT
  117. Portions of this text are reprinted and reproduced in electronic form
  118. from IEEE Std 1003.1-2017, Standard for Information Technology
  119. -- Portable Operating System Interface (POSIX), The Open Group Base
  120. Specifications Issue 7, 2018 Edition,
  121. Copyright (C) 2018 by the Institute of
  122. Electrical and Electronics Engineers, Inc and The Open Group.
  123. In the event of any discrepancy between this version and the original IEEE and
  124. The Open Group Standard, the original IEEE and The Open Group Standard
  125. is the referee document. The original Standard can be obtained online at
  126. http://www.opengroup.org/unix/online.html .
  127. .PP
  128. Any typographical or formatting errors that appear
  129. in this page are most likely
  130. to have been introduced during the conversion of the source files to
  131. man page format. To report such errors, see
  132. https://www.kernel.org/doc/man-pages/reporting_bugs.html .