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

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       lchown — change the owner and group of a symbolic link
14

SYNOPSIS

16       #include <unistd.h>
17
18       int lchown(const char *path, uid_t owner, gid_t group);
19

DESCRIPTION

21       The lchown() function shall be equivalent to  chown(),  except  in  the
22       case  where  the  named file is a symbolic link. In this case, lchown()
23       shall change the ownership of the  symbolic  link  file  itself,  while
24       chown()  changes  the  ownership  of the file or directory to which the
25       symbolic link refers.
26

RETURN VALUE

28       Upon successful completion, lchown()  shall  return  0.  Otherwise,  it
29       shall return −1 and set errno to indicate an error.
30

ERRORS

32       The lchown() function shall fail if:
33
34       EACCES Search permission is denied on a component of the path prefix of
35              path.
36
37       EINVAL The owner or group ID is not a value supported by the  implemen‐
38              tation.
39
40       ELOOP  A loop exists in symbolic links encountered during resolution of
41              the path argument.
42
43       ENAMETOOLONG
44              The  length  of  a  component  of  a  pathname  is  longer  than
45              {NAME_MAX}.
46
47       ENOENT A component of path does not name an existing file or path is an
48              empty string.
49
50       ENOTDIR
51              A component of the path prefix names an existing  file  that  is
52              neither  a  directory nor a symbolic link to a directory, or the
53              path argument contains at least one  non-<slash>  character  and
54              ends  with  one or more trailing <slash> characters and the last
55              pathname component names an existing  file  that  is  neither  a
56              directory nor a symbolic link to a directory.
57
58       EPERM  The  effective  user ID does not match the owner of the file and
59              the process does not have appropriate privileges.
60
61       EROFS  The file resides on a read-only file system.
62
63       The lchown() function may fail if:
64
65       EIO    An I/O error occurred while reading or writing to the file  sys‐
66              tem.
67
68       EINTR  A signal was caught during execution of the function.
69
70       ELOOP  More  than  {SYMLOOP_MAX} symbolic links were encountered during
71              resolution of the path argument.
72
73       ENAMETOOLONG
74              The length of a pathname exceeds {PATH_MAX}, or pathname resolu‐
75              tion  of  a symbolic link produced an intermediate result with a
76              length that exceeds {PATH_MAX}.
77
78       The following sections are informative.
79

EXAMPLES

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

APPLICATION USAGE

104       On implementations which support symbolic links  as  directory  entries
105       rather than files, lchown() may fail.
106

RATIONALE

108       None.
109

FUTURE DIRECTIONS

111       None.
112

SEE ALSO

114       chown(), symlink()
115
116       The Base Definitions volume of POSIX.1‐2008, <unistd.h>
117
119       Portions  of  this text are reprinted and reproduced in electronic form
120       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
121       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
122       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
123       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
124       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
125       event of any discrepancy between this version and the original IEEE and
126       The Open Group Standard, the original IEEE and The Open Group  Standard
127       is  the  referee document. The original Standard can be obtained online
128       at http://www.unix.org/online.html .
129
130       Any typographical or formatting errors that appear  in  this  page  are
131       most likely to have been introduced during the conversion of the source
132       files to man page format. To report such errors,  see  https://www.ker
133       nel.org/doc/man-pages/reporting_bugs.html .
134
135
136
137IEEE/The Open Group                  2013                           LCHOWN(3P)
Impressum