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

lchown.3p (4546B)


  1. '\" et
  2. .TH LCHOWN "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. lchown
  12. \(em change the owner and group of a symbolic link
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. int lchown(const char *\fIpath\fP, uid_t \fIowner\fP, gid_t \fIgroup\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fIlchown\fR()
  23. function shall be equivalent to
  24. \fIchown\fR(),
  25. except in the case where the named file is a symbolic link. In this
  26. case,
  27. \fIlchown\fR()
  28. shall change the ownership of the symbolic link file itself, while
  29. \fIchown\fR()
  30. changes the ownership of the file or directory to which the symbolic
  31. link refers.
  32. .SH "RETURN VALUE"
  33. Upon successful completion,
  34. \fIlchown\fR()
  35. shall return 0. Otherwise, it shall return \-1 and set
  36. .IR errno
  37. to indicate an error.
  38. .SH ERRORS
  39. The
  40. \fIlchown\fR()
  41. function shall fail if:
  42. .TP
  43. .BR EACCES
  44. Search permission is denied on a component of the path prefix of
  45. .IR path .
  46. .TP
  47. .BR EINVAL
  48. The owner or group ID is not a value supported by the implementation.
  49. .TP
  50. .BR ELOOP
  51. A loop exists in symbolic links encountered during resolution of the
  52. .IR path
  53. argument.
  54. .TP
  55. .BR ENAMETOOLONG
  56. .br
  57. The length of a component of a pathname is longer than
  58. {NAME_MAX}.
  59. .TP
  60. .BR ENOENT
  61. A component of
  62. .IR path
  63. does not name an existing file or
  64. .IR path
  65. is an empty string.
  66. .TP
  67. .BR ENOTDIR
  68. A component of the path prefix names an existing file that is neither
  69. a directory nor a symbolic link to a directory, or the
  70. .IR path
  71. argument contains at least one non-\c
  72. <slash>
  73. character and ends with one or more trailing
  74. <slash>
  75. characters and the last pathname component names an existing file
  76. that is neither a directory nor a symbolic link to a directory.
  77. .TP
  78. .BR EPERM
  79. The effective user ID does not match the owner of the file and the
  80. process does not have appropriate privileges.
  81. .TP
  82. .BR EROFS
  83. The file resides on a read-only file system.
  84. .P
  85. The
  86. \fIlchown\fR()
  87. function may fail if:
  88. .TP
  89. .BR EIO
  90. An I/O error occurred while reading or writing to the file system.
  91. .TP
  92. .BR EINTR
  93. A signal was caught during execution of the function.
  94. .TP
  95. .BR ELOOP
  96. More than
  97. {SYMLOOP_MAX}
  98. symbolic links were encountered during resolution of the
  99. .IR path
  100. argument.
  101. .TP
  102. .BR ENAMETOOLONG
  103. .br
  104. The length of a pathname exceeds
  105. {PATH_MAX},
  106. or pathname resolution of a symbolic link produced an intermediate
  107. result with a length that exceeds
  108. {PATH_MAX}.
  109. .LP
  110. .IR "The following sections are informative."
  111. .SH EXAMPLES
  112. .SS "Changing the Current Owner of a File"
  113. .P
  114. The following example shows how to change the ownership of the symbolic
  115. link named
  116. .BR /modules/pass1
  117. to the user ID associated with ``jones'' and the group ID associated
  118. with ``cnd''.
  119. .P
  120. The numeric value for the user ID is obtained by using the
  121. \fIgetpwnam\fR()
  122. function. The numeric value for the group ID is obtained by using the
  123. \fIgetgrnam\fR()
  124. function.
  125. .sp
  126. .RS 4
  127. .nf
  128. #include <sys/types.h>
  129. #include <unistd.h>
  130. #include <pwd.h>
  131. #include <grp.h>
  132. .P
  133. struct passwd *pwd;
  134. struct group *grp;
  135. char *path = "/modules/pass1";
  136. \&...
  137. pwd = getpwnam("jones");
  138. grp = getgrnam("cnd");
  139. lchown(path, pwd->pw_uid, grp->gr_gid);
  140. .fi
  141. .P
  142. .RE
  143. .SH "APPLICATION USAGE"
  144. On implementations which support symbolic links as directory entries
  145. rather than files,
  146. \fIlchown\fR()
  147. may fail.
  148. .SH RATIONALE
  149. None.
  150. .SH "FUTURE DIRECTIONS"
  151. None.
  152. .SH "SEE ALSO"
  153. .IR "\fIchown\fR\^(\|)",
  154. .IR "\fIsymlink\fR\^(\|)"
  155. .P
  156. The Base Definitions volume of POSIX.1\(hy2017,
  157. .IR "\fB<unistd.h>\fP"
  158. .\"
  159. .SH COPYRIGHT
  160. Portions of this text are reprinted and reproduced in electronic form
  161. from IEEE Std 1003.1-2017, Standard for Information Technology
  162. -- Portable Operating System Interface (POSIX), The Open Group Base
  163. Specifications Issue 7, 2018 Edition,
  164. Copyright (C) 2018 by the Institute of
  165. Electrical and Electronics Engineers, Inc and The Open Group.
  166. In the event of any discrepancy between this version and the original IEEE and
  167. The Open Group Standard, the original IEEE and The Open Group Standard
  168. is the referee document. The original Standard can be obtained online at
  169. http://www.opengroup.org/unix/online.html .
  170. .PP
  171. Any typographical or formatting errors that appear
  172. in this page are most likely
  173. to have been introduced during the conversion of the source files to
  174. man page format. To report such errors, see
  175. https://www.kernel.org/doc/man-pages/reporting_bugs.html .