184 lines
5.6 KiB
HTML
184 lines
5.6 KiB
HTML
|
<!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>QlgChmod()--Change File Authorizations (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-->
|
||
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
||
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
||
|
<!-- 020829 RTHEIS S_ISVTX mode bit, V5R3 -->
|
||
|
<!-- End Header Records -->
|
||
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
||
|
</head>
|
||
|
<body>
|
||
|
<!--Java sync-link-->
|
||
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
||
|
</script>
|
||
|
|
||
|
<a name="Top_Of_Page"></a>
|
||
|
|
||
|
<h2>QlgChmod()--Change File Authorizations (using NLS-enabled path name)</h2>
|
||
|
|
||
|
<div class="box" style="width: 70%;">
|
||
|
<br>
|
||
|
Syntax<br>
|
||
|
|
||
|
|
||
|
<pre>
|
||
|
#include <sys/stat.h>
|
||
|
|
||
|
int QlgChmod(Qlg_Path_Name_T <em>*path</em>, mode_t <em>mode</em>);
|
||
|
</pre>
|
||
|
|
||
|
Service Program Name: QP0LLIB1<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Default Public Authority: *USE<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
Threadsafe: Conditional; see Usage Notes for <a href="chmod.htm">chmod()</a>.<br>
|
||
|
<!-- iddvc RMBR -->
|
||
|
<br>
|
||
|
</div>
|
||
|
<p>The <strong>QlgChmod()</strong> function, like the <strong>chmod()</strong>
|
||
|
function, changes S_ISUID, S_ISGID,
|
||
|
S_ISVTX,
|
||
|
and the permission bits of the file or
|
||
|
directory specified in <em>path</em> to the corresponding bits specified in
|
||
|
<em>mode</em>. The difference
|
||
|
is that the <strong>QlgChmod()</strong> function takes a pointer to a
|
||
|
Qlg_Path_Name_T structure, while <strong>chmod()</strong> takes a pointer to a
|
||
|
character string.</p>
|
||
|
|
||
|
<p>Limited information on the <em>path</em> parameter is provided here. For
|
||
|
more information on the <em>path</em> parameter and for a discussion of other
|
||
|
parameters, authorities required, return values, and related information, see
|
||
|
<a href="chmod.htm">chmod()</a>--Change File Authorizations.</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 the path
|
||
|
name or a pointer to the path name of the file whose mode is 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="chmod.htm">chmod()</a>--Change File Authorizations<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="chownu.htm">QlgChown()</a>--Change Owner and Group of File (using
|
||
|
NLS-enabled path name)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="mkdiru.htm">QlgMkdir()</a>--Make Directory (using NLS-enabled path
|
||
|
name)<br>
|
||
|
<br>
|
||
|
</li>
|
||
|
|
||
|
<li><a href="statu.htm">QlgStat()</a>--Get File Information (using NLS-enabled
|
||
|
path name)</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 permissions for a file:</p>
|
||
|
|
||
|
<br>
|
||
|
<pre>
|
||
|
#include <stdio.h>
|
||
|
#include <sys/stat.h>
|
||
|
#include <sys/types.h>
|
||
|
#include <fcntl.h>
|
||
|
#include <Qp0lstdi.h>
|
||
|
|
||
|
main() {
|
||
|
int file_descriptor;
|
||
|
struct stat info;
|
||
|
|
||
|
#define mypath "temp.file"
|
||
|
const char US_const[3]= "US";
|
||
|
const char Language_const[4] ="ENU";
|
||
|
typedef struct pnstruct
|
||
|
{
|
||
|
Qlg_Path_Name_T qlg_struct;
|
||
|
char pn[100]; /* This array size must be >= the */
|
||
|
/* length of the path name or this must */
|
||
|
/* be a pointer to the path name. */
|
||
|
};
|
||
|
struct pnstruct path;
|
||
|
|
||
|
/***************************************************************/
|
||
|
/* Initialize Qlg_Path_Name_T parameters */
|
||
|
/***************************************************************/
|
||
|
memset((void*)&path, 0x00, sizeof(struct pnstruct));
|
||
|
path.qlg_struct.CCSID = 37;
|
||
|
memcpy(path.qlg_struct.Country_ID,US_const,2);
|
||
|
memcpy(path.qlg_struct.Language_ID,Language_const,3);
|
||
|
path.qlg_struct.Path_Type = QLG_CHAR_SINGLE;
|
||
|
path.qlg_struct.Path_Length = sizeof(mypath)-1;
|
||
|
path.qlg_struct.Path_Name_Delimiter[0] = '/';
|
||
|
memcpy(path.pn,mypath,sizeof(mypath)-1);
|
||
|
|
||
|
if ((file_descriptor = QlgCreat((Qlg_Path_Name_T *)&path, S_IWUSR)) == -1)
|
||
|
perror("QlgCreat() error");
|
||
|
else {
|
||
|
close(file_descriptor);
|
||
|
QlgStat((Qlg_Path_Name_T *)&path, &info);
|
||
|
printf("original permissions were: %08o\n", info.st_mode);
|
||
|
if (QlgChmod((Qlg_Path_Name_T *)&path, S_IRWXU|S_IRWXG) != 0)
|
||
|
perror("QlgChmod() error");
|
||
|
else {
|
||
|
QlgStat((Qlg_Path_Name_T *)&path, &info);
|
||
|
printf("after QlgChmod(), permissions are: %08o\n", info.st_mode);
|
||
|
}
|
||
|
QlgUnlink((Qlg_Path_Name_T *)&path);
|
||
|
}
|
||
|
}
|
||
|
</pre>
|
||
|
|
||
|
<p><strong>Output:</strong></p>
|
||
|
|
||
|
<pre>
|
||
|
original permissions were: 00100200
|
||
|
after QlgChmod(), permissions are: 00100770
|
||
|
</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>
|
||
|
|