223 lines
5.9 KiB
HTML
223 lines
5.9 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>umask()--Set Authorization Mask for Job</title>
|
|
<!-- 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. -->
|
|
<!-- Begin Header Records ========================================== -->
|
|
<!-- file cleaned -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- Change History: -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- 050414 JTROUS Changes from API Review, V5R4, no change flag -->
|
|
<!-- This file has undergone html cleanup June 2002 by JET -->
|
|
<!--End Header Records -->
|
|
<link rel="stylesheet" type="text/css" href="../rzahg/ic.css">
|
|
</head>
|
|
<body>
|
|
<a name="Top_Of_Page"></a>
|
|
<!-- Java sync-link -->
|
|
<script language="Javascript" src="../rzahg/synch.js" type="text/javascript">
|
|
</script>
|
|
|
|
<h2>umask()--Set Authorization Mask for Job</h2>
|
|
|
|
<div class="box" style="width: 50%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <sys/stat.h>
|
|
|
|
mode_t umask(mode_t <em>cmask</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Yes<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>Every job has a file creation mask. When a job starts, the value of the file
|
|
creation mask is zero. The value of zero means that no permissions are masked
|
|
when a file or directory is created in the job. The <strong>umask()</strong>
|
|
function changes the value of the file creation mask for the current job to the
|
|
value specified in <em>cmask</em>.</p>
|
|
|
|
<p>The <em>cmask</em> argument controls file permission bits that should be set
|
|
whenever the job creates a file. File permission bits set to <samp>1</samp> in
|
|
the file creation mask are set to <samp>0</samp> in the file permission bits of
|
|
files that are created by the job.</p>
|
|
|
|
<p>For example, if a call to <strong>open()</strong> specifies a <em>mode</em>
|
|
argument with file permission bits, the file creation mask of the job affects
|
|
the <em>mode</em> argument; bits that are <samp>1</samp> in the mask are set to
|
|
<samp>0</samp> in the <em>mode</em> argument and, therefore, in the mode of the
|
|
created file.</p>
|
|
|
|
<p>Only the file permission bits of <em>cmask</em> are used. The other bits in
|
|
<em>cmask</em> must be cleared (not set), or the CPFA0D3 message is issued.</p>
|
|
|
|
<br>
|
|
<h3>Parameters</h3>
|
|
|
|
<dl>
|
|
<dt><strong><em>cmask</em></strong></dt>
|
|
|
|
<dd>(Input) The new value of the file creation mask. For a description of the
|
|
permission bits, see <a href="chmod.htm">chmod()--Change File
|
|
Authorizations</a>.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3>Authorities</h3>
|
|
|
|
<p>No authorization is required.</p>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<p><strong>umask()</strong> returns the previous value of the file creation
|
|
mask. It does not return -1 or set the <em>errno</em> global variable.</p>
|
|
|
|
<br>
|
|
<h3>Error Conditions</h3>
|
|
|
|
<p>None.</p>
|
|
|
|
<br>
|
|
<h3>Error Messages</h3>
|
|
|
|
<p>The following messages may be sent from this function:</p>
|
|
|
|
<table width="100%" cellpadding="5">
|
|
<tr>
|
|
<th align="left" valign="top">Message ID</th>
|
|
<th align="left" valign="top">Error Message Text</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td width="15%" valign="top">CPE3418 E</td>
|
|
<td width="85%" valign="top">Possible APAR condition or hardware failure.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td width="15%" valign="top">CPFA0D3 E</td>
|
|
<td width="85%" valign="top">cmask parameter is not valid.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPFA0D4 E</td>
|
|
<td valign="top">File system error occurred. Error number &1.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF3CF2 E</td>
|
|
<td valign="top">Error(s) occurred during running of &1 API.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td valign="top">CPF9872 E</td>
|
|
<td valign="top">Program or service program &1 in library &2 ended.
|
|
Reason code &3.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3><a name="USAGE_NOTES">Usage Notes</a></h3>
|
|
|
|
<ol type="1">
|
|
<li>QNTC File System Differences
|
|
|
|
<p><strong>umask()</strong> does not update the file creation mask for QNTC.
|
|
The settings specified in <em>cmask</em> are ignored.</p>
|
|
</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>sys/stat.h</strong>> file (see <a href="unix13.htm">
|
|
Header Files for UNIX-Type Functions</a>)<br>
|
|
</li>
|
|
|
|
<li><a href="chmod.htm">chmod()</a>--Change File Authorizations<br>
|
|
</li>
|
|
|
|
<li><a href="creat.htm">creat()</a>--Create or Rewrite File<br>
|
|
</li>
|
|
|
|
<li><a href="mkdir.htm">mkdir()</a>--Make Directory<br>
|
|
</li>
|
|
|
|
<li><a href="open.htm">open()</a>--Open File</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 uses <strong>umask()</strong>:</p>
|
|
|
|
<pre>
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <sys/stat.h>
|
|
|
|
main()
|
|
{
|
|
int file_descriptor;
|
|
struct stat info;
|
|
|
|
umask(S_IRWXG);
|
|
|
|
if ((file_descriptor =
|
|
creat("umask.file", S_IRWXU|S_IRWXG)) < 0)
|
|
perror("creat() error");
|
|
else {
|
|
fstat(file_descriptor, &info);
|
|
printf("permissions are: %08x\n", info.st_mode);
|
|
close(file_descriptor);
|
|
unlink("umask.file");
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
permissions are: 000081c0
|
|
</pre>
|
|
|
|
<br>
|
|
<hr>
|
|
API introduced: V3R1
|
|
|
|
<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>
|
|
|