.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved .TH "LCHOWN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual" .\" lchown .SH NAME lchown \- change the owner and group of a symbolic link .SH SYNOPSIS .LP \fB#include .br .sp int lchown(const char *\fP\fIpath\fP\fB, uid_t\fP \fIowner\fP\fB, gid_t\fP \fIgroup\fP\fB); \fP \fB .br \fP .SH DESCRIPTION .LP The \fIlchown\fP() function shall be equivalent to \fIchown\fP(), except in the case where the named file is a symbolic link. In this case, \fIlchown\fP() shall change the ownership of the symbolic link file itself, while \fIchown\fP() changes the ownership of the file or directory to which the symbolic link refers. .SH RETURN VALUE .LP Upon successful completion, \fIlchown\fP() shall return 0. Otherwise, it shall return -1 and set \fIerrno\fP to indicate an error. .SH ERRORS .LP The \fIlchown\fP() function shall fail if: .TP 7 .B EACCES Search permission is denied on a component of the path prefix of \fIpath\fP. .TP 7 .B EINVAL The owner or group ID is not a value supported by the implementation. .TP 7 .B ELOOP A loop exists in symbolic links encountered during resolution of the \fIpath\fP argument. .TP 7 .B ENAMETOOLONG The length of a pathname exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}. .TP 7 .B ENOENT A component of \fIpath\fP does not name an existing file or \fIpath\fP is an empty string. .TP 7 .B ENOTDIR A component of the path prefix of \fIpath\fP is not a directory. .TP 7 .B EOPNOTSUPP The \fIpath\fP argument names a symbolic link and the implementation does not support setting the owner or group of a symbolic link. .TP 7 .B EPERM The effective user ID does not match the owner of the file and the process does not have appropriate privileges. .TP 7 .B EROFS The file resides on a read-only file system. .sp .LP The \fIlchown\fP() function may fail if: .TP 7 .B EIO An I/O error occurred while reading or writing to the file system. .TP 7 .B EINTR A signal was caught during execution of the function. .TP 7 .B ELOOP More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the \fIpath\fP argument. .TP 7 .B ENAMETOOLONG Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}. .sp .LP \fIThe following sections are informative.\fP .SH EXAMPLES .SS Changing the Current Owner of a File .LP The following example shows how to change the ownership of the symbolic link named \fB/modules/pass1\fP to the user ID associated with "jones" and the group ID associated with "cnd". .LP The numeric value for the user ID is obtained by using the \fIgetpwnam\fP() function. The numeric value for the group ID is obtained by using the \fIgetgrnam\fP() function. .sp .RS .nf \fB#include #include #include #include .sp struct passwd *pwd; struct group *grp; char *path = "/modules/pass1"; \&... pwd = getpwnam("jones"); grp = getgrnam("cnd"); lchown(path, pwd->pw_uid, grp->gr_gid); \fP .fi .RE .SH APPLICATION USAGE .LP On implementations which support symbolic links as directory entries rather than files, \fIlchown\fP() may fail. .SH RATIONALE .LP None. .SH FUTURE DIRECTIONS .LP None. .SH SEE ALSO .LP \fIchown\fP() , \fIsymlink\fP() , the Base Definitions volume of IEEE\ Std\ 1003.1-2001, \fI\fP .SH COPYRIGHT Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .