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

fchown.3p (3640B)


  1. '\" et
  2. .TH FCHOWN "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. fchown
  12. \(em change owner and group of a file
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. int fchown(int \fIfildes\fP, uid_t \fIowner\fP, gid_t \fIgroup\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIfchown\fR()
  23. function shall be equivalent to
  24. \fIchown\fR()
  25. except that the file whose owner and group are changed is
  26. specified by the file descriptor
  27. .IR fildes .
  28. .SH "RETURN VALUE"
  29. Upon successful completion,
  30. \fIfchown\fR()
  31. shall return 0. Otherwise, it shall return \-1 and set
  32. .IR errno
  33. to indicate the error.
  34. .SH ERRORS
  35. The
  36. \fIfchown\fR()
  37. function shall fail if:
  38. .TP
  39. .BR EBADF
  40. The
  41. .IR fildes
  42. argument is not an open file descriptor.
  43. .TP
  44. .BR EPERM
  45. The effective user ID does not match the owner of the file or the
  46. process does not have appropriate privileges and _POSIX_CHOWN_RESTRICTED
  47. indicates that such privilege is required.
  48. .TP
  49. .BR EROFS
  50. The file referred to by
  51. .IR fildes
  52. resides on a read-only file system.
  53. .P
  54. The
  55. \fIfchown\fR()
  56. function may fail if:
  57. .TP
  58. .BR EINVAL
  59. The owner or group ID is not a value supported by the implementation.
  60. The
  61. .IR fildes
  62. argument refers to a pipe or socket
  63. or an
  64. \fIfattach\fR()-ed
  65. STREAM
  66. and the implementation disallows execution of
  67. \fIfchown\fR()
  68. on a pipe.
  69. .TP
  70. .BR EIO
  71. A physical I/O error has occurred.
  72. .TP
  73. .BR EINTR
  74. The
  75. \fIfchown\fR()
  76. function was interrupted by a signal which was caught.
  77. .LP
  78. .IR "The following sections are informative."
  79. .SH EXAMPLES
  80. .SS "Changing the Current Owner of a File"
  81. .P
  82. The following example shows how to change the owner of a file named
  83. .BR /home/cnd/mod1
  84. to ``jones'' and the group to ``cnd''.
  85. .P
  86. The numeric value for the user ID is obtained by extracting the user ID
  87. from the user database entry associated with ``jones''. Similarly, the
  88. numeric value for the group ID is obtained by extracting the group ID
  89. from the group database entry associated with ``cnd''. This example
  90. assumes the calling program has appropriate privileges.
  91. .sp
  92. .RS 4
  93. .nf
  94. #include <sys/types.h>
  95. #include <unistd.h>
  96. #include <fcntl.h>
  97. #include <pwd.h>
  98. #include <grp.h>
  99. .P
  100. struct passwd *pwd;
  101. struct group *grp;
  102. int fildes;
  103. \&...
  104. fildes = open("/home/cnd/mod1", O_RDWR);
  105. pwd = getpwnam("jones");
  106. grp = getgrnam("cnd");
  107. fchown(fildes, pwd->pw_uid, grp->gr_gid);
  108. .fi
  109. .P
  110. .RE
  111. .SH "APPLICATION USAGE"
  112. None.
  113. .SH RATIONALE
  114. None.
  115. .SH "FUTURE DIRECTIONS"
  116. None.
  117. .SH "SEE ALSO"
  118. .IR "\fIchown\fR\^(\|)"
  119. .P
  120. The Base Definitions volume of POSIX.1\(hy2017,
  121. .IR "\fB<unistd.h>\fP"
  122. .\"
  123. .SH COPYRIGHT
  124. Portions of this text are reprinted and reproduced in electronic form
  125. from IEEE Std 1003.1-2017, Standard for Information Technology
  126. -- Portable Operating System Interface (POSIX), The Open Group Base
  127. Specifications Issue 7, 2018 Edition,
  128. Copyright (C) 2018 by the Institute of
  129. Electrical and Electronics Engineers, Inc and The Open Group.
  130. In the event of any discrepancy between this version and the original IEEE and
  131. The Open Group Standard, the original IEEE and The Open Group Standard
  132. is the referee document. The original Standard can be obtained online at
  133. http://www.opengroup.org/unix/online.html .
  134. .PP
  135. Any typographical or formatting errors that appear
  136. in this page are most likely
  137. to have been introduced during the conversion of the source files to
  138. man page format. To report such errors, see
  139. https://www.kernel.org/doc/man-pages/reporting_bugs.html .