1071 lines
26 KiB
HTML
1071 lines
26 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>creat()--Create or Rewrite File</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 -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- 010314 JTROUS Change due to S_ISGID change, V5R2, DCR 98686 -->
|
|
<!-- 010320 JTROUS Include Journal ERRNOs, should have in V5R1 -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- 020618 EMIG Updates for NFS threadsafety, V5R3 -->
|
|
<!-- This file has undergone html cleanup on 05/14/02 by JET -->
|
|
<!-- 020719 MFENLON: updated for QFileSvr.400 threadsafety, V5R3 -->
|
|
<!-- 020829 RTHEIS : S_ISVTX mode bit, V5R3 -->
|
|
<!-- 020924 VONBERGE: Fix QSYS.LIB auth table entries P9A09413 -->
|
|
<!-- 030505 VONBERGE Remove QSYS.LIB mbr creation restrictions -->
|
|
<!-- 050322 JTROUS: fix enums, no change flag, V5R4 -->
|
|
<!-- 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>creat()--Create or Rewrite File</h2>
|
|
|
|
<div class="box" style="width: 60%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <fcntl.h>
|
|
|
|
int creat(const char <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.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>creat()</strong> function creates a new file or rewrites an
|
|
existing file so that it is truncated to zero length. The function call</p>
|
|
|
|
<pre>
|
|
creat(<em>path,mode</em>);
|
|
</pre>
|
|
|
|
is equivalent to the call
|
|
|
|
<pre>
|
|
open(<em>path</em>, O_CREAT|O_WRONLY|O_TRUNC, <em>mode</em>);
|
|
</pre>
|
|
|
|
<p>This means that the file named by <em>path</em> is created if it does not
|
|
already exist, opened for writing only, and truncated to zero length. For
|
|
further information, see <a href="open.htm">open()</a>--Open File.</p>
|
|
|
|
<p>The <em>mode</em> argument specifies file permission bits to be used in
|
|
creating the file. For more information on <em>mode</em>, 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 the null-terminated path name of the file to be
|
|
created or rewritten.
|
|
|
|
<p>This parameter is assumed to be represented in the CCSID (coded character
|
|
set identifier) currently in effect for the job. If the CCSID of the job is
|
|
65535, this parameter is assumed to be represented in the default CCSID of the
|
|
job.</p>
|
|
|
|
<p>When a new file is created, the new file name is assumed to be represented
|
|
in the language and country or region currently in effect for the job.</p>
|
|
|
|
<p>See <a href="creatu.htm">QlgCreat()--Create or Rewrite File</a> for a
|
|
description and an example of supplying the <em>path</em> in any CCSID.</p>
|
|
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>mode</em></strong></dt>
|
|
|
|
<dd>(Input) The file permission bits to be used when creating the file. The
|
|
S_ISUID (set-user-ID), S_ISGID (set-group-ID), and
|
|
S_ISVTX,
|
|
bits also may be specified
|
|
when creating the file.
|
|
|
|
<p>See <a href="chmod.htm">chmod()--Change File Authorizations</a> for details
|
|
on the values that can be specified for <em>mode</em>.</p>
|
|
</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3><a name="HDRCRTAUTS">Authorities</a></h3>
|
|
|
|
<p><strong>Note:</strong> Adopted authority is not used.</p>
|
|
|
|
<p><strong><a name="TBLACREAT1">Authorization Required for creat() (excluding
|
|
QSYS.LIB, independent ASP QSYS.LIB, and QDLS)</a></strong><br>
|
|
</p>
|
|
|
|
<table border cellpadding="5" width="80%">
|
|
<tr>
|
|
<th align="left" valign="bottom">Object Referred to</th>
|
|
<th align="left" valign="bottom">Authority Required</th>
|
|
<th align="left" valign="bottom">errno</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Each directory in the path name preceding the
|
|
object to be created</td>
|
|
<td align="left" valign="top">*X</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Existing object</td>
|
|
<td align="left" valign="top">*W</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Parent directory of object to be created when
|
|
object does not exist</td>
|
|
<td align="left" valign="top">*WX</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<p><strong><a name="TBLACREAT2">Authorization Required for creat() in the
|
|
QSYS.LIB and independent ASP QSYS.LIB File Systems</a></strong><br>
|
|
</p>
|
|
|
|
<table border cellpadding="5" width="80%">
|
|
<tr>
|
|
<th align="left" valign="bottom">Object Referred to</th>
|
|
<th align="left" valign="bottom">Authority Required</th>
|
|
<th align="left" valign="bottom">errno</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Each directory in the path name preceding the
|
|
object to be created</td>
|
|
<td align="left" valign="top">*X</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Existing object</td>
|
|
<td align="left" valign="top">*W</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
|
|
Existing object when object is a save file</td>
|
|
<td align="center" valign="top">*RWX</td>
|
|
<td align="left" valign="top">EACCES
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Parent directory of object to be created when
|
|
object does not exist</td>
|
|
<td align="left" valign="top">*OBJMGT or *OBJALTER</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
|
|
Parent directory of object to be created when
|
|
object does not exist and object type is *USRSPC or save file</td>
|
|
<td align="left" valign="top">*RX and *Add</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Parent directory of the parent directory of
|
|
object to be created when object does not exist and object being created is a physical file member</td>
|
|
<td align="left" valign="top">*Add</td>
|
|
<td align="left" valign="top">EACCES
|
|
</td>
|
|
</tr>
|
|
|
|
</table>
|
|
|
|
<br>
|
|
<p><strong><a name="TBLACREAT3">Authorization Required for creat() in the QDLS
|
|
File System</a></strong><br>
|
|
</p>
|
|
|
|
<table border cellpadding="5" width="80%">
|
|
<tr>
|
|
<th align="left" valign="bottom">Object Referred to</th>
|
|
<th align="left" valign="bottom">Authority Required</th>
|
|
<th align="left" valign="bottom">errno</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Each directory in the path name preceding the
|
|
object to be created</td>
|
|
<td align="left" valign="top">*X</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Existing object</td>
|
|
<td align="left" valign="top">*W</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Parent directory of object to be created when
|
|
object does not exist</td>
|
|
<td align="left" valign="top">*CHANGE</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<dl compact>
|
|
<dt><em>value</em></dt>
|
|
|
|
<dd><strong>creat()</strong> was successful. The value returned is the file
|
|
descriptor for the open file.</dd>
|
|
|
|
<dt><em>-1</em></dt>
|
|
|
|
<dd><strong>creat()</strong> was not successful. The <em>errno</em> global
|
|
variable is set to indicate the error.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3><a name="HDRCRTERRS">Error Conditions</a></h3>
|
|
|
|
<p>If <strong>creat()</strong> is not successful, <em>errno</em> usually
|
|
indicates one of the following errors. Under some conditions, <em>errno</em>
|
|
could indicate an error other than those listed here.</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="25 75" -->
|
|
|
|
<tr>
|
|
<th align="left" valign="bottom">Error condition</th>
|
|
<th align="left" valign="bottom">Additional information</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EACCES">EACCES</a>]</em></td>
|
|
|
|
|
|
<td align="left" valign="top">
|
|
<p>If you are accessing a remote file through the Network File System, update
|
|
operations to file permissions at the server are not reflected at the client
|
|
until updates to data that is stored locally by the Network File System take
|
|
place. (Several options on the Add Mounted File System (ADDMFS) command
|
|
determine the time between refresh operations of local data.) Access to a
|
|
remote file may also fail due to different mappings of user IDs (UID) or group
|
|
IDs (GID) on the local and remote systems.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EAGAIN">EAGAIN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EBADFID">EBADFID</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EBADNAME">EBADNAME</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EBUSY">EBUSY</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The open sharing mode may conflict with another open of this file, or
|
|
O_WRONLY or O_RDWR is specified and the file is checked out by another
|
|
user.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ECONVERT">ECONVERT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EDAMAGE">EDAMAGE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EEXIST">EEXIST</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EFAULT">EFAULT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EFILECVT">EFILECVT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EINTR">EINTR</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EINVAL">EINVAL</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>For example, unused bits in <em>mode</em> are set and should be cleared.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EIO">EIO</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EISDIR">EISDIR</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EJRNDAMAGE">EJRNDAMAGE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EJRNENTTOOLONG">EJRNENTTOOLONG</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EJRNINACTIVE">EJRNINACTIVE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EJRNRCVSPC">EJRNRCVSPC</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ELOOP">ELOOP</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EMFILE">EMFILE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENAMETOOLONG">ENAMETOOLONG</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENEWJRN">ENEWJRN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENEWJRNRCV">ENEWJRNRCV</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENFILE">ENFILE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOENT">ENOENT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOMEM">ENOMEM</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOSPC">ENOSPC</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOSYSRSC">ENOSYSRSC</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOTAVAIL">ENOTAVAIL</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOTDIR">ENOTDIR</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOTSUP">ENOTSUP</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EOVERFLOW">EOVERFLOW</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>The specified file exists and its size is too large to be represented in a
|
|
variable of type off_t (the file is larger than 2GB minus 1 byte).</p>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EROOBJ">EROOBJ</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ESTALE">ESTALE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>If you are accessing a remote file through the Network File System, the file
|
|
may have been deleted at the server.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EUNKNOWN">EUNKNOWN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<p>If interaction with a file server is required to access the object, <em>
|
|
errno</em> could indicate one of the following errors:</p>
|
|
|
|
<table cellpadding="5">
|
|
<!-- cols="25 75" -->
|
|
|
|
<tr>
|
|
<th align="left" valign="bottom">Error condition</th>
|
|
<th align="left" valign="bottom">Additional information</th>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EADDRNOTAVAIL">EADDRNOTAVAIL</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ECONNABORTED">ECONNABORTED</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ECONNREFUSED">ECONNREFUSED</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ECONNRESET">ECONNRESET</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EHOSTDOWN">EHOSTDOWN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EHOSTUNREACH">EHOSTUNREACH</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENETDOWN">ENETDOWN</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENETRESET">ENETRESET</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENETUNREACH">ENETUNREACH</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ESTALE">ESTALE</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
<p>If you are accessing a remote file through the Network File System, the file
|
|
may have been deleted at the server.</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ETIMEDOUT">ETIMEDOUT</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EUNATCH">EUNATCH</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3>Error Messages</h3>
|
|
|
|
<p>The following messages may be sent from this function:</p>
|
|
|
|
<table width="100%">
|
|
<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 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="HDRCRTUSAG">Usage Notes</a></h3>
|
|
|
|
<ol type="1">
|
|
<li>This function will fail with error code [ENOTSAFE] when all the following
|
|
conditions are true:<br>
|
|
<br>
|
|
<ul>
|
|
<li>Where multiple threads exist in the job.<br>
|
|
</li>
|
|
|
|
<li>The object on which this function is operating resides in a file system
|
|
that is not threadsafe. Only the following file systems are threadsafe for this
|
|
function:<br>
|
|
<br>
|
|
<ul>
|
|
<li>"Root" (/)</li>
|
|
|
|
<li>QOpenSys</li>
|
|
|
|
<li>User-defined</li>
|
|
|
|
<li>QNTC</li>
|
|
|
|
<li>QSYS.LIB</li>
|
|
|
|
<li>Independent ASP QSYS.LIB</li>
|
|
|
|
<li>QOPT</li>
|
|
|
|
<li>Network File System</li>
|
|
|
|
|
|
<li>QFileSvr.400</li>
|
|
|
|
</ul>
|
|
</li>
|
|
</ul>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>"Root" (/), QOpenSys, and User-Defined File System Differences
|
|
|
|
<p>The user who creates the file becomes its owner. If the S_ISGID bit of the
|
|
parent directory is off, the group ID (GID) is set to the effective GID of the
|
|
thread creating the object. If the S_ISGID bit of the parent directory is on,
|
|
the group ID (GID) is copied from the parent directory in which the file is
|
|
created.</p>
|
|
|
|
<p>The owner, primary group, and public object authorities (*OBJEXIST, *OBJMGT,
|
|
*OBJALTER, and *OBJREF) are copied from the parent directory's owner, primary
|
|
group, and public object authorities. This occurs even when the new file has a
|
|
different owner than the parent directory. The owner, primary group, and public
|
|
data authorities (*R, *W, and *X) are derived from the permissions specified in
|
|
the mode (except for those permissions that are also set in the file mode
|
|
creation mask). The new file does not have any private authorities or
|
|
authorization list. It only has authorities for the owner, primary group, and
|
|
public.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>QSYS.LIB and Independent ASP QSYS.LIB File System Differences
|
|
|
|
<p>
|
|
When creating a member, the ownership, group profile, and authorities are all derived from the member's parent physical file. The input <em>mode</em> value is ignored.
|
|
</p>
|
|
|
|
<p>The group ID is obtained from the primary user profile, if a group profile exists.</p>
|
|
|
|
<p>The owner object authorities are set to *OBJEXIST, *OBJMGT, *OBJALTER, and
|
|
*OBJREF. The primary group object authorities are specified by options in the
|
|
user profile of the job. None of the public object authorities are set.</p>
|
|
|
|
<p>The owner, primary group, and public data authorities (*R, *W, and *X) are
|
|
derived from the permissions specified in the mode (except for those
|
|
permissions that are also set in the file mode creation mask). The data
|
|
authorities must match the data authorities of the file in which the member is
|
|
being created.</p>
|
|
|
|
<p>The primary group authorities are not saved if the primary group does not
|
|
exist. When a primary group is attached to the object, the object gets the
|
|
authorities specified in <em>mode</em>.</p>
|
|
|
|
<p>A member cannot be created in a mixed-CCSID file.</p>
|
|
|
|
<p>The file access time for a database member is updated using the normal rules
|
|
that apply to database files. At most, the access time is updated once per
|
|
day.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>QDLS File System Differences
|
|
|
|
<p>The user who creates the file becomes its owner. The group ID is copied from
|
|
the parent folder in which the file is created.</p>
|
|
|
|
<p>The owner object authority is set to *OBJMGT + *OBJEXIST + *OBJALTER +
|
|
*OBJREF.</p>
|
|
|
|
<p>The primary group and public object authority and all other authorities are
|
|
copied from the parent folder.</p>
|
|
|
|
<p>The owner, primary group, and public data authority (including *OBJOPR) are
|
|
derived from the permissions specified in <em>mode</em> (except those
|
|
permissions that are also set in the file mode creation mask).</p>
|
|
|
|
<p>The primary group authorities specified in <em>mode</em> are not saved if no
|
|
primary group exists.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>QOPT File System Differences
|
|
|
|
<p>When the volume on which the file is being created is formatted in Universal
|
|
Disk Format (UDF):<br>
|
|
<br>
|
|
</p>
|
|
|
|
<ul>
|
|
<li>The authorization that is checked for the object and preceding directories
|
|
in the path name follows the rules described in <a href="#TBLACREAT1">
|
|
"Authorization Required for creat()."</a><br>
|
|
</li>
|
|
|
|
<li>The volume authorization list is checked for *CHANGE authority.<br>
|
|
</li>
|
|
|
|
<li>The user who creates the file becomes its owner.<br>
|
|
</li>
|
|
|
|
<li>The group ID is copied from the parent directory in which the file is
|
|
created.<br>
|
|
</li>
|
|
|
|
<li>The owner, primary group, and public data authorities (*R, *W, and *X) are
|
|
derived from the permissions specified in the mode (except those permissions
|
|
that are also set in the file mode creation mask).<br>
|
|
</li>
|
|
|
|
<li>The resulting share mode is O_SHARE_NONE; therefore, the function call
|
|
|
|
<pre>
|
|
creat(<em>path,mode</em>);
|
|
</pre>
|
|
|
|
is equivalent to the call
|
|
|
|
<pre>
|
|
open(<em>path</em>,
|
|
O_CREAT|O_WRONLY|O_TRUNC|O_SHARE_NONE,
|
|
<em>mode</em>);
|
|
</pre>
|
|
|
|
</li>
|
|
|
|
<li>The same uppercase and lowercase forms in which the names are entered are
|
|
preserved. No distinction is made between uppercase and lower case when
|
|
searching for names.</li>
|
|
</ul>
|
|
|
|
<p>When the volume on which the file is being created is not formatted in
|
|
Universal Disk Format (UDF):</p>
|
|
<ul>
|
|
<li>No authorization checks are made on the object or preceding directories in
|
|
the path name.<br>
|
|
</li>
|
|
|
|
<li>The volume authorization list is checked for *CHANGE authority.<br>
|
|
</li>
|
|
|
|
<li>QDFTOWN becomes the owner of the file.<br>
|
|
</li>
|
|
|
|
<li>No group ID is assigned to the file.<br>
|
|
</li>
|
|
|
|
<li>The permissions specified in the mode are ignored. The owner, primary
|
|
group, and public data authorities are set to RWX.<br>
|
|
</li>
|
|
|
|
<li>For newly created files, names are created in uppercase. No distinction is
|
|
made between uppercase and lowercase when searching for names.</li>
|
|
</ul>
|
|
|
|
<p>A file cannot be created as a direct child of /QOPT.</p>
|
|
|
|
<p>The change and modification times of the parent directory are not
|
|
updated.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>Network File System Differences
|
|
|
|
<p>Local access to remote files through the Network File System may produce
|
|
unexpected results due to conditions at the server. The creation of a file may
|
|
fail if permissions and other attributes that are stored locally by the Network
|
|
File System are more restrictive than those at the server. A later attempt to
|
|
create a file can succeed when the locally stored data has been refreshed.
|
|
(Several options on the Add Mounted File System (ADDMFS) command determine the
|
|
time between refresh operations of local data.) The creation can also succeed
|
|
after the file system has been remounted.</p>
|
|
|
|
<p>If you try to re-create a file that was recently deleted, the request may
|
|
fail because data that was stored locally by the Network File System still has
|
|
a record of the file's existence. The creation succeeds when the locally stored
|
|
data has been updated.</p>
|
|
|
|
<p>Once a file is open, subsequent requests to perform operations on the file
|
|
can fail because file attributes are checked at the server on each request. If
|
|
permissions on the file are made more restrictive at the server or the file is
|
|
unlinked or made unavailable by the server for another client, your operation
|
|
on an open file descriptor will fail when the local Network File System
|
|
receives these updates. The local Network File System also impacts operations
|
|
that retrieve file attributes. Recent changes at the server may not be
|
|
available at your client yet, and old values may be returned from
|
|
operations.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>QNetWare File System Differences
|
|
|
|
<p>The user who creates the file becomes the owner. Mode bits are not fully
|
|
supported. See <a href="../rzaef/rzaefoverview.htm">NetWare on iSeries</a> for
|
|
more information.</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>This function will fail with the [EOVERFLOW] error if the specified file
|
|
exists and its size is too large to be represented in a variable of type off_t
|
|
(the file is larger than 2GB minus 1 byte).<br>
|
|
<br>
|
|
</li>
|
|
|
|
<li>When you develop in C-based languages and this function is compiled with
|
|
the _LARGE_FILES macro defined, it will be mapped to <strong>
|
|
creat64()</strong>.</li>
|
|
</ol>
|
|
|
|
<br>
|
|
<h3>Related Information</h3>
|
|
|
|
<ul>
|
|
<li>The <<strong>fcntl.h</strong>> file (see <a href="unix13.htm">Header
|
|
Files for UNIX-Type Functions</a>)<br>
|
|
</li>
|
|
|
|
<li><a href="creat64.htm">creat64()</a>--Create or Rewrite a File (Large File
|
|
Enabled)<br>
|
|
</li>
|
|
|
|
<li><a href="open.htm">open()</a>--Open File<br>
|
|
</li>
|
|
|
|
<li><a href="creatu.htm">QlgCreat()</a>--Create or Rewrite 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 creates a file:</p>
|
|
|
|
<pre>
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
|
|
main() {
|
|
char fn[]="creat.file", text[]="This is a test";
|
|
int fd, rc;
|
|
|
|
if ((fd = creat(fn, S_IRUSR | S_IWUSR)) < 0)
|
|
perror("creat() error");
|
|
else {
|
|
if (-1==(rc=write(fd, text, strlen(text))))
|
|
perror("write() error");
|
|
if (close(fd) != 0)
|
|
perror("close() error");
|
|
if (unlink(fn)!= 0)
|
|
perror("unlink() error");
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<br>
|
|
<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>
|
|
|