819 lines
19 KiB
HTML
819 lines
19 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>lstat()--Get File or Link Information</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 -->
|
|
<!-- file cleaned -->
|
|
<!-- Unix2 SCRIPT J converted by B2H R4.1 (346) (CMS) by V2KEA304 -->
|
|
<!-- at RCHVMW2 on 17 Feb 1999 at 11:05:09 -->
|
|
<!-- 011022 JTROUS Changes from API Review 1, V5R2 -->
|
|
<!-- 020430 JTROUS Fix problem in authority information, V5R3 -->
|
|
<!-- 020618 EMIG: updated for NFS threadsafety, V5R3 -->
|
|
<!-- 020624 RTHEIS: Add fclear() and fclear64(), V5R3 -->
|
|
<!-- 0206?? JET This file has undergone html cleanup -->
|
|
<!-- 020719 MFENLON: updated for QFileSvr.400 threadsafety, V5R3 -->
|
|
<!-- 050404 JTROUS: fix enums, no change flag, V5R4 -->
|
|
<!-- 050406 VONBERGE: Add USRPRF auth requirement -->
|
|
<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>lstat()--Get File or Link Information</h2>
|
|
|
|
<div class="box" style="width: 70%;">
|
|
<br>
|
|
Syntax<br>
|
|
|
|
|
|
<pre>
|
|
#include <sys/stat.h>
|
|
|
|
int lstat(const char <em>*path</em>, struct stat <em>*buf</em>);
|
|
</pre>
|
|
|
|
Service Program Name: QP0LLIB1<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Default Public Authority: *USE<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
Threadsafe: Conditional; see <a href="#HDRLSTAUSG">Usage Notes</a>.<br>
|
|
<!-- iddvc RMBR -->
|
|
<br>
|
|
</div>
|
|
|
|
<p>The <strong>lstat()</strong> function gets status information about a
|
|
specified file and places it in the area of memory pointed to by <em>buf</em>.
|
|
If the named file is a symbolic link, <strong>lstat()</strong> returns
|
|
information about the symbolic link itself.</p>
|
|
|
|
<p>The information is returned in the <samp>stat</samp> structure, referenced
|
|
by <em>buf</em>. For details on the <samp>stat</samp> structure, see <a href=
|
|
"stat.htm">stat()--Get File Information</a>.</p>
|
|
|
|
<p>If the named file is not a symbolic link, <strong>lstat()</strong> updates
|
|
the time-related fields before putting information in the <samp>stat</samp>
|
|
structure.</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.
|
|
|
|
<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>See <a href="lstatu.htm">QlgLstat()--Get File or Link Information</a> for a
|
|
description and an example of supplying the <em>path</em> in any CCSID.</p>
|
|
|
|
<br>
|
|
</dd>
|
|
|
|
<dt><strong><em>buf</em></strong></dt>
|
|
|
|
<dd>(Output) A pointer to the area to which the information should be
|
|
written.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3><a name="HDRLSTAAUT">Authorities</a></h3>
|
|
|
|
<p><strong>Note:</strong> Adopted authority is not used.</p>
|
|
|
|
<p><strong><a name="TBLALSTAT">Authorization Required for
|
|
lstat()</a></strong></p>
|
|
|
|
<table border cellpadding="5">
|
|
<!-- cols="40 40 20" -->
|
|
<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</td>
|
|
<td align="center" valign="top">*X</td>
|
|
<td align="left" valign="top">EACCES</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Object, if object type is not *USRPRF</td>
|
|
<td align="center" valign="top">None</td>
|
|
<td align="left" valign="top">None</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">Object, if object type is *USRPRF</td>
|
|
<td align="center" valign="top">Any authority greater than *EXCLUDE</td>
|
|
<td align="left" valign="top">ENOENT</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<h3>Return Value</h3>
|
|
|
|
<dl compact>
|
|
<dt><em>0</em></dt>
|
|
|
|
<dd><strong>lstat()</strong> was successful. The information is returned in
|
|
<em>buf</em>.</dd>
|
|
|
|
<dt><em>-1</em></dt>
|
|
|
|
<dd><strong>lstat()</strong> was not successful. The <em>errno</em> global
|
|
variable is set to indicate the error.</dd>
|
|
</dl>
|
|
|
|
<br>
|
|
<h3><a name="HDRLSTAERR">Error Conditions</a></h3>
|
|
|
|
<p>If <strong>lstat()</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">
|
|
|
|
</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#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">
|
|
|
|
</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#ELOOP">ELOOP</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#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#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#ENOSPC">ENOSPC</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#ENOTSAFE">ENOTSAFE</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 file size in bytes cannot be represented correctly in the structure
|
|
pointed to by <em>buf</em> (the file is larger than 2GB minus 1 byte).</p>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">
|
|
<em>[<a href="unix14.htm#EPERM">EPERM</a>]</em></td>
|
|
|
|
<td align="left" valign="top">
|
|
|
|
</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%" cellpadding="5">
|
|
<!-- cols="15 85" -->
|
|
<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 align="left" valign="top">CPFA0D4 E</td>
|
|
<td align="left" valign="top">File system error occurred. Error number
|
|
&1.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">CPF3CF2 E</td>
|
|
<td align="left" valign="top">Error(s) occurred during running of &1
|
|
API.</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td align="left" valign="top">CPF9872 E</td>
|
|
<td align="left" valign="top">Program or service program &1 in library
|
|
&2 ended. Reason code &3.</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<br>
|
|
<br>
|
|
<h3><a name="HDRLSTAUSG">Usage Notes</a></h3>
|
|
|
|
<ol>
|
|
<li>This function will fail with error code [ENOTSAFE] when both of the
|
|
following conditions occur:<br>
|
|
<br>
|
|
<ul>
|
|
<li>Where multiple threads exist in the job.<br>
|
|
</li>
|
|
|
|
<li>The object this function is operating on 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>QOPT File System Differences<br>
|
|
<p>The value for st_atime will always be zero. The value for st_ctime will
|
|
always be the creation date and time of the file or directory.</p>
|
|
|
|
<p>If the object exists on a volume formatted in Universal Disk Format (UDF),
|
|
the authorization that is checked for the object and each directory in the path
|
|
name follows the rules described in <a href="#TBLALSTAT">Authorization Required
|
|
for lstat()</a>. If the object exists on a volume formatted in some other media
|
|
format, no authorization checks are made on the object or each directory in the
|
|
path name. The volume authorization list is checked for *USE authority
|
|
regardless of the volume media format.</p>
|
|
|
|
<p>The user, group, and other mode bits are always on for an object tha exists
|
|
on a volume not formatted in Universal Disk format (UDF).</p>
|
|
|
|
<p><strong>lstat()</strong> on /QOPT will always return 2,147,483,647 for size fields.</p>
|
|
|
|
<p><strong>lstat()</strong> on optical volumes will return the volume capacity or 2,147,483,647,
|
|
whichever is smaller.</p>
|
|
|
|
<p>The file access time is not changed.</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. 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. (Several options on the
|
|
Add Mounted File System (ADDMFS) command determine the time between refresh
|
|
operations of local data.)</p>
|
|
|
|
<br>
|
|
</li>
|
|
|
|
<li>QNetWare File System Differences
|
|
|
|
<p>The QNetWare file system does not fully support mode bits. 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 file size in
|
|
bytes cannot be represented correctly in the structure pointed to by buf (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
|
|
_LARGE_FILES defined, it will be mapped to <strong>lstat64()</strong>. Note
|
|
that the type of the buf parameter, <samp>struct stat</samp>, also will be
|
|
mapped to type <samp>struct stat64</samp>.</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>)
|
|
</li>
|
|
|
|
<li>The <<strong>sys/types.h</strong>> file (see <a href="unix13.htm">
|
|
Header Files for UNIX-Type Functions</a>)
|
|
</li>
|
|
|
|
<li><a href="chmod.htm">chmod()</a>--Change File Authorizations
|
|
</li>
|
|
|
|
<li><a href="chown.htm">chown()</a>--Change Owner and Group of File
|
|
</li>
|
|
|
|
<li><a href="creat.htm">creat()</a>--Create or Rewrite File
|
|
</li>
|
|
|
|
<li><a href="dup.htm">dup()</a>--Duplicate Open File Descriptor
|
|
</li>
|
|
|
|
|
|
<li>
|
|
<a href="fclear.htm">fclear()</a>--Write (Binary Zeros) to Descriptor
|
|
</li>
|
|
|
|
<li><a href="fclear64.htm">fclear64()</a>--Write (Binary Zeros) to Descriptor
|
|
(Large File Enabled)
|
|
</li>
|
|
|
|
<li><a href="fcntl.htm">fcntl()</a>--Perform File Control Command
|
|
</li>
|
|
|
|
<li><a href="fstat.htm">fstat()</a>--Get File Information by Descriptor
|
|
</li>
|
|
|
|
<li><a href="link.htm">link()</a>--Create Link to File
|
|
</li>
|
|
|
|
<li><a href="mkdir.htm">mkdir()</a>--Make Directory
|
|
</li>
|
|
|
|
<li><a href="open.htm">open()</a>--Open File
|
|
</li>
|
|
|
|
<li><a href="lstatu.htm">QlgLstat()</a>--Get File or Link Information
|
|
</li>
|
|
|
|
<li><a href="read.htm">read()</a>--Read from Descriptor
|
|
</li>
|
|
|
|
<li><a href="readlink.htm">readlink()</a>--Read Value of Symbolic Link
|
|
</li>
|
|
|
|
<li><a href="stat.htm">stat()</a>--Get File Information
|
|
</li>
|
|
|
|
<li><a href="symlink.htm">symlink()</a>--Make Symbolic Link
|
|
</li>
|
|
|
|
<li><a href="unlink.htm">unlink()</a>--Remove Link to File
|
|
</li>
|
|
|
|
<li><a href="utime.htm">utime()</a>--Set File Access and Modification Times
|
|
</li>
|
|
|
|
<li><a href="write.htm">write()</a>--Write to Descriptor</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 provides status information for a file:</p>
|
|
|
|
<pre>
|
|
#include <sys/types.h>
|
|
#include <sys/stat.h>
|
|
#include <stdio.h>
|
|
#include <fcntl.h>
|
|
#include <unistd.h>
|
|
#include <time.h>
|
|
#include <stdio.h>
|
|
|
|
main() {
|
|
char fn[]="temp.file", ln[]="temp.link";
|
|
struct stat info;
|
|
int file_descriptor;
|
|
|
|
if ((file_descriptor = creat(fn, S_IWUSR)) < 0)
|
|
perror("creat() error");
|
|
else {
|
|
close(file_descriptor);
|
|
if (link(fn, ln) != 0)
|
|
perror("link() error");
|
|
else {
|
|
if (lstat(ln, &info) != 0)
|
|
perror("lstat() error");
|
|
else {
|
|
puts("lstat() returned:");
|
|
printf(" inode: %d\n", (int) info.st_ino);
|
|
printf(" dev id: %d\n", (int) info.st_dev);
|
|
printf(" mode: %08x\n", info.st_mode);
|
|
printf(" links: %d\n", info.st_nlink);
|
|
printf(" uid: %d\n", (int) info.st_uid);
|
|
printf(" gid: %d\n", (int) info.st_gid);
|
|
}
|
|
unlink(ln);
|
|
}
|
|
unlink(fn);
|
|
}
|
|
}
|
|
</pre>
|
|
|
|
<p><strong>Output:</strong></p>
|
|
|
|
<pre>
|
|
lstat() returned:
|
|
inode: 3022
|
|
dev id: 1
|
|
mode: 00008080
|
|
links: 2
|
|
uid: 137
|
|
gid: 500
|
|
</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>
|
|
|