ibm-information-center/dist/eclipse/plugins/i5OS.ic.apis_5.4.0.1/lchownu.htm

193 lines
6.0 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Copyright" content="Copyright (c) 2006 by IBM Corporation">
<title>QlgLchown()--Change Owner and Group of Symbolic Link (using NLS-enabled
path name)</title>
<!-- Begin Header Records -->
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<!-- Change History: -->
<!-- YYMMDD USERID Change description -->
<!-- Created by Yvonne Griffin for V5R1-->
<!-- This file has undergone html cleanup June 2002 by JET -->
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
</head>
<body>
<!-- End Header Records --><!--Java sync-link-->
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
</script>
<a name="Top_Of_Page"></a>
<h2>QlgLchown()--Change Owner and Group of Symbolic Link (using NLS-enabled
path name)</h2>
<div class="box" style="width: 70%;">
<br>
&nbsp;&nbsp;Syntax<br>
<pre>
#include &lt;unistd.h&gt;
int QlgLchown(Qlg_Path_Name_T <em>*path</em>, uid_t <em>owner</em>,gid_t
<em>group</em>);
</pre>
&nbsp;&nbsp;Service Program Name: QP0LLIB1<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Default Public Authority: *USE<br>
<!-- iddvc RMBR -->
<br>
&nbsp;&nbsp;Threadsafe: Conditional; see Usage Notes for <a href=
"lchown.htm">lchown()</a>.<br>
<!-- iddvc RMBR -->
<br>
</div>
<p>The <strong>QlgLchown()</strong> function, like the <strong>
lchown()</strong> function, changes the owner and group of a file. The
difference is that the <strong>QlgLchown()</strong> function takes a pointer to
a Qlg_Path_Name_T structure, while <strong>lchown()</strong> takes a pointer to
a character string.</p>
<p>Limited information on the <em>path</em> parameter is provided here. For
more on the <em>path</em> parameter and for a discussion of other parameters,
authorities required, return values, and related information, see <a href=
"lchown.htm">lchown()</a>--Change Owner and Group of Symbolic Link.</p>
<br>
<h3>Parameters</h3>
<dl>
<dt><strong><em>path</em></strong></dt>
<dd>(Input) A pointer to a Qlg_Path_Name_T structure that contains a path name
or a pointer to a path name of the file whose owner and group are being
changed. For more information on the Qlg_Path_Name_T structure, see <a href=
"../apiref/pns.htm">Path name format</a>.</dd>
</dl>
<br>
<h3>Related Information</h3>
<ul>
<li><a href="lchown.htm">lchown()</a>--Change Owner and Group of Symbolic
Link<br>
<br>
</li>
<li><a href="chmodu.htm">QlgChmod()</a>--Change File Authorizations<br>
<br>
</li>
<li><a href="lstatu.htm">QlgLstat()</a>--Get File or Link Information<br>
<br>
</li>
<li><a href="statu.htm">QlgStat()</a>--Get File Information</li>
</ul>
<br>
<h3>Example</h3>
<p>See <a href="../apiref/aboutapis.htm#codedisclaimer">Code disclaimer information</a>
for information pertaining to code examples.</p>
<p>The following example changes the owner and group of a file:</p>
<pre>
#include &lt;stdio.h&gt;
#include &lt;unistd.h&gt;
#include &lt;sys/stat.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;Qp0lstdi.h&gt;
main() {
#define mypath_link_name "temp.link"
#define mypath_fn "temp.file"
const char US_const]3[= "US";
const char Language_const]4[="ENU";
struct stat info;
typedef struct pnstruct
{
Qlg_Path_Name_T qlg_struct;
char pn]100[; /* This array size must be &gt;= the */
/* length of the path name or this must */
/* be a pointer to the path name. */
};
struct pnstruct path_link;
struct pnstruct path_fn;
/***************************************************************/
/* Initialize Qlg_Path_Name_T parameters */
/***************************************************************/
memset((void*)&amp;path_link, 0x00, sizeof(struct pnstruct));
path_link.qlg_struct.CCSID = 37;
memcpy(path_link.qlg_struct.Country_ID,US_const,2);
memcpy(path_link.qlg_struct.Language_ID,Language_const,3);
path_link.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path_link.qlg_struct.Path_Length = sizeof(mypath_link_name)-1;
path_link.qlg_struct.Path_Name_Delimiter]0[ = '/';
memcpy(path_link.pn,mypath_link_name,sizeof(mypath_link_name)-1);
memset((void*)&amp;path_fn, 0x00, sizeof(struct pnstruct));
path_fn.qlg_struct.CCSID = 37;
memcpy(path_fn.qlg_struct.Country_ID,US_const,2);
memcpy(path_fn.qlg_struct.Language_ID,Language_const,3);
path_fn.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
path_fn.qlg_struct.Path_Length = sizeof(mypath_fn)-1;
path_fn.qlg_struct.Path_Name_Delimiter]0[ = '/';
memcpy(path_fn.pn,mypath_fn,sizeof(mypath_fn)-1);
if (QlgSymlink((Qlg_Path_Name_T *)&amp;path_fn,
(Qlg_Path_Name_T *)&amp;path_link) == -1)
perror("QlgSymlink() error");
else {
QlgLstat((Qlg_Path_Name_T *)&amp;path_link, &amp;info);
printf("original owner was %d and group was %d\n", info.st_uid,
info.st_gid);
if (QlgLchown((Qlg_Path_Name_T *)&amp;path_link, 152, 0) != 0)
perror("QlgLchown() error");
else {
QlgLstat((Qlg_Path_Name_T *)&amp;path_link, &amp;info);
printf("after QlgLchown(), owner is %d and group is %d\n",
info.st_uid, info.st_gid);
}
QlgUnlink((Qlg_Path_Name_T *)&amp;path_link);
}
}
</pre>
<p><strong>Output:</strong></p>
<pre>
original owner was 137 and group was 0
after QlgLchown(), owner is 152 and group is 0
</pre>
<hr>
API introduced: V5R1
<hr>
<center>
<table cellpadding="2" cellspacing="2">
<tr align="center">
<td valign="middle" align="center"><a href="#Top_Of_Page">Top</a> | <a href=
"unix.htm">UNIX-Type APIs</a> | <a href="aplist.htm">APIs by category</a></td>
</tr>
</table>
</center>
</body>
</html>