~ubuntu-branches/ubuntu/precise/manpages-posix/precise

1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
1
.\" Copyright (c) 2001-2003 The Open Group, All Rights Reserved 
2 by Francesco Paolo Lovergine
* Alligned to linux main manpages edition.
2
.TH "LCHOWN" P 2003 "IEEE/The Open Group" "POSIX Programmer's Manual"
1 by Francesco Paolo Lovergine
rules: linking manpages-posix not manpages.
3
.\" lchown 
4
.SH NAME
5
lchown \- change the owner and group of a symbolic link
6
.SH SYNOPSIS
7
.LP
8
\fB#include <unistd.h>
9
.br
10
.sp
11
int lchown(const char *\fP\fIpath\fP\fB, uid_t\fP \fIowner\fP\fB,
12
gid_t\fP \fIgroup\fP\fB); \fP
13
\fB
14
.br
15
\fP
16
.SH DESCRIPTION
17
.LP
18
The \fIlchown\fP() function shall be equivalent to \fIchown\fP(),
19
except in the case
20
where the named file is a symbolic link. In this case, \fIlchown\fP()
21
shall change the ownership of the symbolic link file itself,
22
while \fIchown\fP() changes the ownership of the file or directory
23
to which the symbolic
24
link refers.
25
.SH RETURN VALUE
26
.LP
27
Upon successful completion, \fIlchown\fP() shall return 0. Otherwise,
28
it shall return -1 and set \fIerrno\fP to indicate an
29
error.
30
.SH ERRORS
31
.LP
32
The \fIlchown\fP() function shall fail if:
33
.TP 7
34
.B EACCES
35
Search permission is denied on a component of the path prefix of \fIpath\fP.
36
.TP 7
37
.B EINVAL
38
The owner or group ID is not a value supported by the implementation.
39
.TP 7
40
.B ELOOP
41
A loop exists in symbolic links encountered during resolution of the
42
\fIpath\fP argument.
43
.TP 7
44
.B ENAMETOOLONG
45
The length of a pathname exceeds {PATH_MAX} or a pathname component
46
is longer than {NAME_MAX}.
47
.TP 7
48
.B ENOENT
49
A component of \fIpath\fP does not name an existing file or \fIpath\fP
50
is an empty string.
51
.TP 7
52
.B ENOTDIR
53
A component of the path prefix of \fIpath\fP is not a directory.
54
.TP 7
55
.B EOPNOTSUPP
56
The \fIpath\fP argument names a symbolic link and the implementation
57
does not support setting the owner or group of a symbolic
58
link.
59
.TP 7
60
.B EPERM
61
The effective user ID does not match the owner of the file and the
62
process does not have appropriate privileges.
63
.TP 7
64
.B EROFS
65
The file resides on a read-only file system.
66
.sp
67
.LP
68
The \fIlchown\fP() function may fail if:
69
.TP 7
70
.B EIO
71
An I/O error occurred while reading or writing to the file system.
72
.TP 7
73
.B EINTR
74
A signal was caught during execution of the function.
75
.TP 7
76
.B ELOOP
77
More than {SYMLOOP_MAX} symbolic links were encountered during resolution
78
of the \fIpath\fP argument.
79
.TP 7
80
.B ENAMETOOLONG
81
Pathname resolution of a symbolic link produced an intermediate result
82
whose length exceeds {PATH_MAX}.
83
.sp
84
.LP
85
\fIThe following sections are informative.\fP
86
.SH EXAMPLES
87
.SS Changing the Current Owner of a File
88
.LP
89
The following example shows how to change the ownership of the symbolic
90
link named \fB/modules/pass1\fP to the user ID
91
associated with "jones" and the group ID associated with "cnd".
92
.LP
93
The numeric value for the user ID is obtained by using the \fIgetpwnam\fP()
94
function.
95
The numeric value for the group ID is obtained by using the \fIgetgrnam\fP()
96
function.
97
.sp
98
.RS
99
.nf
100
101
\fB#include <sys/types.h>
102
#include <unistd.h>
103
#include <pwd.h>
104
#include <grp.h>
105
.sp
106
107
struct passwd *pwd;
108
struct group  *grp;
109
char          *path = "/modules/pass1";
110
\&...
111
pwd = getpwnam("jones");
112
grp = getgrnam("cnd");
113
lchown(path, pwd->pw_uid, grp->gr_gid);
114
\fP
115
.fi
116
.RE
117
.SH APPLICATION USAGE
118
.LP
119
On implementations which support symbolic links as directory entries
120
rather than files, \fIlchown\fP() may fail.
121
.SH RATIONALE
122
.LP
123
None.
124
.SH FUTURE DIRECTIONS
125
.LP
126
None.
127
.SH SEE ALSO
128
.LP
129
\fIchown\fP() , \fIsymlink\fP() , the Base Definitions volume of
130
IEEE\ Std\ 1003.1-2001, \fI<unistd.h>\fP
131
.SH COPYRIGHT
132
Portions of this text are reprinted and reproduced in electronic form
133
from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
134
-- Portable Operating System Interface (POSIX), The Open Group Base
135
Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
136
Electrical and Electronics Engineers, Inc and The Open Group. In the
137
event of any discrepancy between this version and the original IEEE and
138
The Open Group Standard, the original IEEE and The Open Group Standard
139
is the referee document. The original Standard can be obtained online at
140
http://www.opengroup.org/unix/online.html .