214 lines
6.6 KiB
HTML
214 lines
6.6 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<html>
|
|
<head>
|
|
<meta name="generator" content="HTML Tidy, see www.w3.org">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
|
<link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 -->
|
|
<!-- Copyright (c) 2001 The Open Group, All Rights Reserved -->
|
|
<title>lchown</title>
|
|
</head>
|
|
<body bgcolor="white">
|
|
<script type="text/javascript" language="JavaScript" src="../jscript/codes.js">
|
|
</script>
|
|
|
|
<basefont size="3"> <a name="lchown"></a> <a name="tag_03_327"></a><!-- lchown -->
|
|
<!--header start-->
|
|
<center><font size="2">The Open Group Base Specifications Issue 6<br>
|
|
IEEE Std 1003.1-2001<br>
|
|
Copyright © 2001 The IEEE and The Open Group, All Rights reserved.</font></center>
|
|
|
|
<!--header end-->
|
|
<hr size="2" noshade>
|
|
<h4><a name="tag_03_327_01"></a>NAME</h4>
|
|
|
|
<blockquote>lchown - change the owner and group of a symbolic link</blockquote>
|
|
|
|
<h4><a name="tag_03_327_02"></a>SYNOPSIS</h4>
|
|
|
|
<blockquote class="synopsis">
|
|
<div class="box"><code><tt><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt=
|
|
"[Option Start]" border="0"> #include <<a href="../basedefs/unistd.h.html">unistd.h</a>><br>
|
|
<br>
|
|
int lchown(const char *</tt><i>path</i><tt>, uid_t</tt> <i>owner</i><tt>, gid_t</tt> <i>group</i><tt>); <img src=
|
|
"../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div>
|
|
|
|
<tt><br>
|
|
</tt></blockquote>
|
|
|
|
<h4><a name="tag_03_327_03"></a>DESCRIPTION</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>lchown</i>() function shall be equivalent to <a href="../functions/chown.html"><i>chown</i>()</a>, except in the case
|
|
where the named file is a symbolic link. In this case, <i>lchown</i>() shall change the ownership of the symbolic link file itself,
|
|
while <a href="../functions/chown.html"><i>chown</i>()</a> changes the ownership of the file or directory to which the symbolic
|
|
link refers.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_04"></a>RETURN VALUE</h4>
|
|
|
|
<blockquote>
|
|
<p>Upon successful completion, <i>lchown</i>() shall return 0. Otherwise, it shall return -1 and set <i>errno</i> to indicate an
|
|
error.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_05"></a>ERRORS</h4>
|
|
|
|
<blockquote>
|
|
<p>The <i>lchown</i>() function shall fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EACCES]</dt>
|
|
|
|
<dd>Search permission is denied on a component of the path prefix of <i>path</i>.</dd>
|
|
|
|
<dt>[EINVAL]</dt>
|
|
|
|
<dd>The owner or group ID is not a value supported by the implementation.</dd>
|
|
|
|
<dt>[ELOOP]</dt>
|
|
|
|
<dd>A loop exists in symbolic links encountered during resolution of the <i>path</i> argument.</dd>
|
|
|
|
<dt>[ENAMETOOLONG]</dt>
|
|
|
|
<dd>
|
|
The length of a pathname exceeds {PATH_MAX} or a pathname component is longer than {NAME_MAX}.</dd>
|
|
|
|
<dt>[ENOENT]</dt>
|
|
|
|
<dd>A component of <i>path</i> does not name an existing file or <i>path</i> is an empty string.</dd>
|
|
|
|
<dt>[ENOTDIR]</dt>
|
|
|
|
<dd>A component of the path prefix of <i>path</i> is not a directory.</dd>
|
|
|
|
<dt>[EOPNOTSUPP]</dt>
|
|
|
|
<dd>The <i>path</i> argument names a symbolic link and the implementation does not support setting the owner or group of a symbolic
|
|
link.</dd>
|
|
|
|
<dt>[EPERM]</dt>
|
|
|
|
<dd>The effective user ID does not match the owner of the file and the process does not have appropriate privileges.</dd>
|
|
|
|
<dt>[EROFS]</dt>
|
|
|
|
<dd>The file resides on a read-only file system.</dd>
|
|
</dl>
|
|
|
|
<p>The <i>lchown</i>() function may fail if:</p>
|
|
|
|
<dl compact>
|
|
<dt>[EIO]</dt>
|
|
|
|
<dd>An I/O error occurred while reading or writing to the file system.</dd>
|
|
|
|
<dt>[EINTR]</dt>
|
|
|
|
<dd>A signal was caught during execution of the function.</dd>
|
|
|
|
<dt>[ELOOP]</dt>
|
|
|
|
<dd>More than {SYMLOOP_MAX} symbolic links were encountered during resolution of the <i>path</i> argument.</dd>
|
|
|
|
<dt>[ENAMETOOLONG]</dt>
|
|
|
|
<dd>
|
|
Pathname resolution of a symbolic link produced an intermediate result whose length exceeds {PATH_MAX}.</dd>
|
|
</dl>
|
|
</blockquote>
|
|
|
|
<hr>
|
|
<div class="box"><em>The following sections are informative.</em></div>
|
|
|
|
<h4><a name="tag_03_327_06"></a>EXAMPLES</h4>
|
|
|
|
<blockquote>
|
|
<h5><a name="tag_03_327_06_01"></a>Changing the Current Owner of a File</h5>
|
|
|
|
<p>The following example shows how to change the ownership of the symbolic link named <b>/modules/pass1</b> to the user ID
|
|
associated with "jones" and the group ID associated with "cnd".</p>
|
|
|
|
<p>The numeric value for the user ID is obtained by using the <a href="../functions/getpwnam.html"><i>getpwnam</i>()</a> function.
|
|
The numeric value for the group ID is obtained by using the <a href="../functions/getgrnam.html"><i>getgrnam</i>()</a>
|
|
function.</p>
|
|
|
|
<pre>
|
|
<tt>#include <sys/types.h>
|
|
#include <unistd.h>
|
|
#include <pwd.h>
|
|
#include <grp.h>
|
|
<br>
|
|
struct passwd *pwd;
|
|
struct group *grp;
|
|
char *path = "/modules/pass1";
|
|
...
|
|
pwd = getpwnam("jones");
|
|
grp = getgrnam("cnd");
|
|
lchown(path, pwd->pw_uid, grp->gr_gid);
|
|
</tt>
|
|
</pre>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_07"></a>APPLICATION USAGE</h4>
|
|
|
|
<blockquote>
|
|
<p>On implementations which support symbolic links as directory entries rather than files, <i>lchown</i>() may fail.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_08"></a>RATIONALE</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_09"></a>FUTURE DIRECTIONS</h4>
|
|
|
|
<blockquote>
|
|
<p>None.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_10"></a>SEE ALSO</h4>
|
|
|
|
<blockquote>
|
|
<p><a href="chown.html"><i>chown</i>()</a> , <a href="symlink.html"><i>symlink</i>()</a> , the Base Definitions volume of
|
|
IEEE Std 1003.1-2001, <a href="../basedefs/unistd.h.html"><i><unistd.h></i></a></p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_11"></a>CHANGE HISTORY</h4>
|
|
|
|
<blockquote>
|
|
<p>First released in Issue 4, Version 2.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_12"></a>Issue 5</h4>
|
|
|
|
<blockquote>
|
|
<p>Moved from X/OPEN UNIX extension to BASE.</p>
|
|
</blockquote>
|
|
|
|
<h4><a name="tag_03_327_13"></a>Issue 6</h4>
|
|
|
|
<blockquote>
|
|
<p>The wording of the mandatory [ELOOP] error condition is updated, and a second optional [ELOOP] error condition is added.</p>
|
|
|
|
<p>The Open Group Base Resolution bwg2001-013 is applied, adding wording to the APPLICATION USAGE.</p>
|
|
</blockquote>
|
|
|
|
<div class="box"><em>End of informative text.</em></div>
|
|
|
|
<hr>
|
|
<hr size="2" noshade>
|
|
<center><font size="2"><!--footer start-->
|
|
UNIX ® is a registered Trademark of The Open Group.<br>
|
|
POSIX ® is a registered Trademark of The IEEE.<br>
|
|
[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href=
|
|
"../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>
|
|
]</font></center>
|
|
|
|
<!--footer end-->
|
|
<hr size="2" noshade>
|
|
</body>
|
|
</html>
|
|
|