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

fchmod.3p (3783B)


  1. '\" et
  2. .TH FCHMOD "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. fchmod
  12. \(em change mode of a file
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <sys/stat.h>
  17. .P
  18. int fchmod(int \fIfildes\fP, mode_t \fImode\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIfchmod\fR()
  23. function shall be equivalent to
  24. \fIchmod\fR()
  25. except that the file whose permissions are changed is specified
  26. by the file descriptor
  27. .IR fildes .
  28. .P
  29. If
  30. .IR fildes
  31. references a shared memory object, the
  32. \fIfchmod\fR()
  33. function need only affect the S_IRUSR, S_IWUSR, S_IRGRP, S_IWGRP,
  34. S_IROTH, and S_IWOTH file permission bits.
  35. .P
  36. If
  37. .IR fildes
  38. references a typed memory object, the behavior of
  39. \fIfchmod\fR()
  40. is unspecified.
  41. .P
  42. If
  43. .IR fildes
  44. refers to a socket, the behavior of
  45. \fIfchmod\fR()
  46. is unspecified.
  47. .P
  48. If
  49. .IR fildes
  50. refers to a STREAM (which is
  51. \fIfattach\fR()-ed
  52. into the file system name space) the call returns successfully, doing
  53. nothing.
  54. .SH "RETURN VALUE"
  55. Upon successful completion,
  56. \fIfchmod\fR()
  57. shall return 0. Otherwise, it shall return \-1 and set
  58. .IR errno
  59. to indicate the error.
  60. .SH ERRORS
  61. The
  62. \fIfchmod\fR()
  63. function shall fail if:
  64. .TP
  65. .BR EBADF
  66. The
  67. .IR fildes
  68. argument is not an open file descriptor.
  69. .TP
  70. .BR EPERM
  71. The effective user ID does not match the owner of the file and the
  72. process does not have appropriate privileges.
  73. .TP
  74. .BR EROFS
  75. The file referred to by
  76. .IR fildes
  77. resides on a read-only file system.
  78. .P
  79. The
  80. \fIfchmod\fR()
  81. function may fail if:
  82. .TP
  83. .BR EINTR
  84. The
  85. \fIfchmod\fR()
  86. function was interrupted by a signal.
  87. .TP
  88. .BR EINVAL
  89. The value of the
  90. .IR mode
  91. argument is invalid.
  92. .TP
  93. .BR EINVAL
  94. The
  95. .IR fildes
  96. argument refers to a pipe and the implementation disallows execution of
  97. \fIfchmod\fR()
  98. on a pipe.
  99. .LP
  100. .IR "The following sections are informative."
  101. .SH EXAMPLES
  102. .SS "Changing the Current Permissions for a File"
  103. .P
  104. The following example shows how to change the permissions for a
  105. file named
  106. .BR /home/cnd/mod1
  107. so that the owner and group have read/write/execute permissions, but
  108. the world only has read/write permissions.
  109. .sp
  110. .RS 4
  111. .nf
  112. #include <sys/stat.h>
  113. #include <fcntl.h>
  114. .P
  115. mode_t mode;
  116. int fildes;
  117. \&...
  118. fildes = open("/home/cnd/mod1", O_RDWR);
  119. fchmod(fildes, S_IRWXU | S_IRWXG | S_IROTH | S_IWOTH);
  120. .fi
  121. .P
  122. .RE
  123. .SH "APPLICATION USAGE"
  124. None.
  125. .SH RATIONALE
  126. None.
  127. .SH "FUTURE DIRECTIONS"
  128. None.
  129. .SH "SEE ALSO"
  130. .IR "\fIchmod\fR\^(\|)",
  131. .IR "\fIchown\fR\^(\|)",
  132. .IR "\fIcreat\fR\^(\|)",
  133. .IR "\fIfcntl\fR\^(\|)",
  134. .IR "\fIfstatat\fR\^(\|)",
  135. .IR "\fIfstatvfs\fR\^(\|)",
  136. .IR "\fImknod\fR\^(\|)",
  137. .IR "\fIopen\fR\^(\|)",
  138. .IR "\fIread\fR\^(\|)",
  139. .IR "\fIwrite\fR\^(\|)"
  140. .P
  141. The Base Definitions volume of POSIX.1\(hy2017,
  142. .IR "\fB<sys_stat.h>\fP"
  143. .\"
  144. .SH COPYRIGHT
  145. Portions of this text are reprinted and reproduced in electronic form
  146. from IEEE Std 1003.1-2017, Standard for Information Technology
  147. -- Portable Operating System Interface (POSIX), The Open Group Base
  148. Specifications Issue 7, 2018 Edition,
  149. Copyright (C) 2018 by the Institute of
  150. Electrical and Electronics Engineers, Inc and The Open Group.
  151. In the event of any discrepancy between this version and the original IEEE and
  152. The Open Group Standard, the original IEEE and The Open Group Standard
  153. is the referee document. The original Standard can be obtained online at
  154. http://www.opengroup.org/unix/online.html .
  155. .PP
  156. Any typographical or formatting errors that appear
  157. in this page are most likely
  158. to have been introduced during the conversion of the source files to
  159. man page format. To report such errors, see
  160. https://www.kernel.org/doc/man-pages/reporting_bugs.html .