1LCHOWN(P)                  POSIX Programmer's Manual                 LCHOWN(P)
2
3
4

NAME

6       lchown - change the owner and group of a symbolic link
7

SYNOPSIS

9       #include <unistd.h>
10
11       int lchown(const char *path, uid_t owner, gid_t group);
12
13

DESCRIPTION

15       The  lchown()  function  shall  be equivalent to chown(), except in the
16       case where the named file is a symbolic link. In  this  case,  lchown()
17       shall  change  the  ownership  of  the symbolic link file itself, while
18       chown() changes the ownership of the file or  directory  to  which  the
19       symbolic link refers.
20

RETURN VALUE

22       Upon  successful  completion,  lchown()  shall  return 0. Otherwise, it
23       shall return -1 and set errno to indicate an error.
24

ERRORS

26       The lchown() function shall fail if:
27
28       EACCES Search permission is denied on a component of the path prefix of
29              path.
30
31       EINVAL The  owner or group ID is not a value supported by the implemen‐
32              tation.
33
34       ELOOP  A loop exists in symbolic links encountered during resolution of
35              the path argument.
36
37       ENAMETOOLONG
38              The length of a pathname exceeds {PATH_MAX} or a pathname compo‐
39              nent is longer than {NAME_MAX}.
40
41       ENOENT A component of path does not name an existing file or path is an
42              empty string.
43
44       ENOTDIR
45              A component of the path prefix of path is not a directory.
46
47       EOPNOTSUPP
48              The  path  argument names a symbolic link and the implementation
49              does not support setting the owner or group of a symbolic link.
50
51       EPERM  The effective user ID does not match the owner of the  file  and
52              the process does not have appropriate privileges.
53
54       EROFS  The file resides on a read-only file system.
55
56
57       The lchown() function may fail if:
58
59       EIO    An  I/O error occurred while reading or writing to the file sys‐
60              tem.
61
62       EINTR  A signal was caught during execution of the function.
63
64       ELOOP  More than {SYMLOOP_MAX} symbolic links were  encountered  during
65              resolution of the path argument.
66
67       ENAMETOOLONG
68              Pathname  resolution of a symbolic link produced an intermediate
69              result whose length exceeds {PATH_MAX}.
70
71
72       The following sections are informative.
73

EXAMPLES

75   Changing the Current Owner of a File
76       The following example shows how to change the ownership of the symbolic
77       link  named  /modules/pass1  to the user ID associated with "jones" and
78       the group ID associated with "cnd".
79
80       The numeric value for the user ID is obtained by using  the  getpwnam()
81       function.   The numeric value for the group ID is obtained by using the
82       getgrnam() function.
83
84
85              #include <sys/types.h>
86              #include <unistd.h>
87              #include <pwd.h>
88              #include <grp.h>
89
90
91              struct passwd *pwd;
92              struct group  *grp;
93              char          *path = "/modules/pass1";
94              ...
95              pwd = getpwnam("jones");
96              grp = getgrnam("cnd");
97              lchown(path, pwd->pw_uid, grp->gr_gid);
98

APPLICATION USAGE

100       On implementations which support symbolic links  as  directory  entries
101       rather than files, lchown() may fail.
102

RATIONALE

104       None.
105

FUTURE DIRECTIONS

107       None.
108

SEE ALSO

110       chown()    ,    symlink()    ,   the   Base   Definitions   volume   of
111       IEEE Std 1003.1-2001, <unistd.h>
112
114       Portions of this text are reprinted and reproduced in  electronic  form
115       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
116       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
117       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
118       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
119       event of any discrepancy between this version and the original IEEE and
120       The Open Group Standard, the original IEEE and The Open Group  Standard
121       is  the  referee document. The original Standard can be obtained online
122       at http://www.opengroup.org/unix/online.html .
123
124
125
126IEEE/The Open Group                  2003                            LCHOWN(P)
Impressum